Check the FAQ section at the bottom.
- Hint: check the hover function
- BEFORE you run anything, check with us.
- If you have red underlined code anywhere in the file, fix it.
- The command is NOT flytoAltitude.
- Make sure there’s a wait command after movement.
- Make sure you land.
Pygame and Joystick
Banana Hat and Mustache Webcam Filters
- Teaches you how to use coordinates, use it for placing the object in the filter where you want it
- Other things to consider: what if the image is too big?
- Understand hat.py and mustache.py
- Challenge: overlay an image on the drone video stream.
- We will see how to match features in one image with others. Please reference the link below. http://docs.opencv.org/master/dc/dc3/tutorial_py_matcher.html#gsc.tab=0
- We will use something called the Brute-Force or BFMatcher. It takes the descriptor of one feature in the first set and is matches it with all other features in the second set using some distance calculation. The closest match is returned.
- If you take a look at matcher.py, we have created a Matcher class where we have specified a minimum percentage of keypoints needed to determine if the two images are a match.
- For us, this happens if 20% of features are matching keypoints.
- In line 12 of our code, we create something called a SIFT detector. You can learn more about it in the link below. http://docs.opencv.org/3.1.0/da/df5/tutorial_py_sift_intro.html#gsc.tab=0
- In line 15, we create the matcher object.
- Inside of the match function on line 25, we check for best matches!
- As stated in the tutorial, we can use the function BFMatcher.knnMatch() to get k number of best matches and draw k match-lines for each keypoint.
- If the match ratio of the original image and the image shown is greater than our minimum percentage (which in our case is 20), then our function will return the name of the image matched and will print out the name and number of keypoints matched.
- In the file test_object_detection.py, we took the pictures of the logos we wanted to use and used the matcher to test for image recognition.
- Hit run and show one of the logos to the screen to see what happens.
- (Also try test_object_detection_flann.py - it uses a different algorithm, but does the same thing)
- Open barcode_camera_test.py. If you show one of the QR codes to your video camera, it should show you details about the what the code is.
- Get QR code recognition working for drone video.
- How do we give it different commands when it sees a code? (i.e. taking off or landing when it sees a specific code)
- How can we try to make the drone land on a code?
Contours and Colors
- OpenCV has classes to detect color ranges and create contours in images
- OpenCV understands RGB colors as BGR arrays
- Our codes will only use RGB and grayscale, but there are other color spaces available
- Look at section 6.6 on Practical Python and OpenCV for more information
- Numpy is used to store colors as arrays which are passed to openCV
- Contours are how openCV detects curves in an image
- Identify a color, then identify the curves that bound the color and store them as contours
- Read sections about image basics, image processing, contours
- Fly through the hoops (forwards, backwards, up, etc.) according to the QR codes.
- Fly through the maze with colored walls, take a picture of the trapped people (faces), scan QR codes for points and return to base within the time limit.
- Make sure all processes are stopped before you try to run a file.
- “I’m getting some kind of socket error”
- You are running too many files inside of pycharm. It is likely they’re both trying to connect to your drone. Stop all processes, right click and quit the python windows, or open terminal and type “killall -9 python.”
- If that doesn’t work, turn your drone off and on. Somebody may be connected to it.
- “My wifi says it’s disconnected and I can’t find any wifi networks”
- Open terminal and type in “systemctl restart NetworkManager”
- When prompted for the password type in user1. If that doesn’t work, restart your computer.
- “I can’t go on any webpage”
- Your internet was disconnected from fauguest. You need to sign in again with the username and password “techrunway”
- “My drone automatically drifts in xxxx direction”
- If you are using joystick, change the range your joystick is at “zero” to be a greater number (i.e. instead of “if joystick.get_axis(3) > 0.05” use something like 0.1 or 0.3)
- If that doesn’t work (and you’re sure there’s nothing else that’s wrong), you can offset the movement by constantly sending the command to move in the opposite direction it’s drifting.
- “I deleted a file or edited something that I needed”
- “When I run face detection I get an error that looks like this: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale.”
- It can’t find the xml file for your Haar-Cascades. Specify the file path by typing /cascades/ before the name of the xml file (i.e. ‘/cascades/haarcascade_frontalface_default.xml').
- If that doesn’t work, try ‘home/user1/camp-student-2016/opencv/cascades/haarcascade_frontalface_default.xml’ and make sure you’re working in the opencv folder.