<< return to Pixycam.com

How to view the line tracking algorithm source code


#1

I want to learn your line tracking algorithm but I can’t find the location of the source code. Can you tell me which file it is in?


#2

Hi, the Arduino source code for the line tracking algorithm is here: https://github.com/charmedlabs/pixy2/blob/master/src/host/arduino/libraries/Pixy2/Pixy2Line.h

You might also find these references useful:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:protocol_reference#line-tracking-packet-reference

Hope this helps!


#3

Well thanks for reply I find those files,but there are only some send and receive requests. I want some line tracking algorithm about Image Processing in other words can i get the pixy->sendPacket() target’s code?


#4

Hello,
The core line tracking code is here:

I’ve looked at the code. It’s not the simplest code!

Edward


#5

Hello Pixy ,I want to learn this line tracking algorithm but I can’t understand it by looking at the code.
Can you provide some details about the algorithm? Such as how to deal with each frame of the picture, how to judge a line.
Thank for your help~


#6

Hello,
Happy to help. The line algorithm starts by taking a simple difference between horizontal pixels spaces 2 or 3 pixels apart and thresholding the difference. (differencing pixels across a line results in larger differences than if the difference is across a uniform section of image.) This creates a thresholded image where lines are likely – these are essentially line edges. A fairly simple algorithm then assembles the line edges into continuous lines. A final stage of the algorithm determines if there are intersections (how many and how many branches).

Hope this helps!

Edward


#7

WOW !
Thanks lot for your words,it is very helpful and I want to ask if you judge the edge only based on green pixels? I only see g_dist g_thresh in code.


#8

That is correct. The other pixels (red and blue) are tossed out at the acquisition phase (within the M0 core), and only the green pixels are considered.