- Progress:
- I downloaded the jimp module, an alternative/complement to opencv whose library seems to be documented and explained more thoroughly.
- The file I required in the node test program is weird, called index.js or something. I couldn’t find a file named jimp.js, which would usually signal the file with all the others required. However, it seems to work; I’ve tried a few methods w/o error-"not a function".
- I created a rudimentary tracking function given an single image (the image type [.png] matches the images which the drone should feed to the computer):
- 1) I use opencv to threshold the image for red
- 2) Then I feed that output to jimp
- 3) I use jimp to analyze the pixels and their neighbors (for now, horizontally) at a set distance
- 4) I use jimp to find average X and Y of retained pixels
- 5) I now have the marker’s location in the image, along with its horizontal and vertical limits (I draw a point at that location).
- 6) I can now approximate the radius of the marker by finding the average difference between each limit and the center.
- Problems: (Crossed out, because I resolved the problem)
- I tried testing jimp, but the png image I read which was the output of an opencv method came up undefined in pixel color when I tried to read pixel(0,0).
- I think it’s because png images can be formatted in different ways, with different numbers of bytes per pixel.
- I also tried jpg, but that also came up as undefined. I haven’t researched jpg formatting, but perhaps there’s a similar problem.
- Perhaps there’s a way to convert an image to rgba before reading it with jimp.
- Perhaps there’s a way to output an image with a specific data format.
- Solution:
- the color RGBA values returned are not stored in a matrix; they are stored as properties of the color object.
- So color[0] = undefined, but color.r = the amount of red in the image
- :)
- Plans:
- Test
- stream = new opencv.ImageStream()
- stream.on(‘data’, function(matrix) {
- //image conversion
- //image analysis (retrieve marker location)
- }
- ardrone.createPngStream().pipe(stream)
- //Perhaps learn how to output the imageStream to a window display OR send the imageStream to a web browser to display. I know for a fact that the latter is possible; I’ve seen it done.
- Improve Tracking Function
- Incorporate vertical neighbors
- Check neighboring pixels at intermediate distances to improve erosion function’s accuracy, so I can lower the distance
- Incorporate ardrone.createPngStream() to input video
- Display video output in browser?
- This isn't really necessary, but would be nice
- Drone
- Test command loops in the drone by putting land() and takeoff() in a repeating loop
- Use location and marker radius in command sequence for drone
- put location.x in center of image by setting yaw value
- move until marker.radius is greater than a certain value
- I assume marker.radius graphed per distance from marker would be a “1/x” kind of function...
- Fix leaning in drone flight
- HOW???
- Try another drone?
- Perhaps leaning is OK, once the drone starts following a marker path to correct is drifting
- Pseudocode for Final Program
- Store command string specified by user
- Take off
- variable: Image = empty
- variable: radius = 0
- variable: Y = constant //used to spin un a direction until marker is found
- for (command in command string) {
- while (no marker is detected in the following image) {
- Get image from drone
- Detect marker location, using the tracking function
- Send image to user //Maybe; not necessary
- Yaw += Y
- }
- while (radius < R) {
- if (location.y is too far from equator) change height
- if (location.x is too far from meridian) change yaw
- if (neither of the above) move forward
- while no marker is detected in the following image {
- Get image from drone
- Detect marker location
- Send image to client
- Yaw += Y
- }
- }
- Stop
- if (command == end) {
- Land
- }
- else if (command == left/right) {
- Change yaw left/right
- }
No comments:
Post a Comment