Simple line following executed on an android camera phone?

asked 2013-10-31 03:53:56 -0600

KeenanEmpire gravatar image

updated 2020-11-02 15:26:26 -0600

I am trying to implement simple line following on a robot that uses an android camera as its sensor. My idea is to take any given frame and search only a horizontal strip for the color black, then get information on how far left/right that black is from center. For example, if the input frame is this:

alt text

then the program should search some thin horizontal strip (like the blue one in the picture) for black. When it finds it it reports that the black line is to the right of center by x amount.

I think that this should be written into the onCameraFrame() method, but i am not sure where to go from there. Specifically i need to know how to search a submat for a concentration of black and report its position.

edit retag flag offensive close merge delete

Comments

A suggestion

  • Threshold the image to create a binary image
  • Look for edges, using the Houghlines approach
  • Define the distance between two following line segments
StevenPuttemans gravatar imageStevenPuttemans ( 2013-10-31 07:41:42 -0600 )edit

So houghlines is another common approach i saw but i wasnt sure how to implement it. Do you know any good examples that show it being implemented in javaCV? I have an input frame (from the onCameraFrame() method) so i will research how to threshold that image.

What do you mean by define the distance between two following line segments? are you saying compare 2 results from the houghline approach? So like if one the following line is an inch to the right of the previous line then you know you need to turn to the right to follow it?

KeenanEmpire gravatar imageKeenanEmpire ( 2013-10-31 15:22:27 -0600 )edit

JavaCV is not an official distribution of the openCV library, so support here is limited. Houghlines returns a set of points that defines lines. You can calculate a distance between lines right? I suggest putting your question here

StevenPuttemans gravatar imageStevenPuttemans ( 2013-11-04 04:42:29 -0600 )edit