Color Filter Technique OpenCV

谁都会走 提交于 2019-12-06 13:47:14

Since your drone can move in 3D-space, I will suggest some pseudo-code steps in the 2D realm to get you started with a simple line follower. Then you can extrapolate to 3D and add more degrees of freedom to meet your needs.

  1. Perform Erosion/Dilation Operations on your image to get rid of extra space, if necessary.
  2. Call cv::findContours() to get a trace around the edges of the white regions in your image.
  3. Sort your found contours by pixel area to find the contour you want to follow. I'd guess that you'd most often want to follow the largest pixel area. Try using the contour moments.
  4. Fit a line to the contour using cv::fitline() or your own approach.
  5. Take the angle of the line and map it to your drone controller to adjust the yaw.

From here, you can do several other basic things to control the motion of your drone:

  • Set a contour pixel mass threshold. If the contour area > threshold, move up.
  • Look at the shape of the threshold area. If it is more like a trapezoid than a rectangle, you can adjust your roll/pitch.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!