Line Following - Blob Spotting/Decoding robot

OpenMV related project discussion.
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Line Following - Blob Spotting/Decoding robot

Postby trevorb » Sat Jul 09, 2016 2:41 pm

From my post on "MV Primer" in the tech discussion area of the forum - I want to start a project HERE.

"I have the idea that I would like to make a line following robot for a grid. At each grid intersection could be a symbol so it would have the idea of which node it was approaching and its pose relative to the node. The robot could take instruction to get to the next node or waypoint. In this way it could go from point to point and know where it was and where it is going".

I have the open mv functioning running example scripts, I have purchased a robot base, AS-2wd from amazon.com. The robot base accepts 5 AA cells- 5 x 1.5v =7.5 volts and has a switch that connects battery + terminal to robot motors charging plug depending on direction of switch.

I am thinking I just to wire a 3.7 lipo battery to power the openmv and operating the robot base from the intended 7.5V.

Can I connect the lipo battery and robot base negative terminals together? I would then route pin 7&8 to the signal pin of each servo. The servos would be powered to the common "-" terminal and the +7.5. The charging switch when flipped I believe would simply charge the 7.5 battery and I would remove and charge the 3.7 lipo. Any commentary would be helpful.

Thanks,

Trev
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Sat Jul 09, 2016 3:00 pm

Yep, you can always connect grounds to each other. In fact, you have to do this. That said, please connect the lipo (+) to the VIN pin on the OpenMV Cam. Anyway, this all said, 7.5 V sounds kinda high for the servos. Please make sure to check the voltage rating on the servos. As for the OpenMV Cam it should power on with the 3.7V battery source. However, a 4.5V source would be better.
Nyamekye,
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby trevorb » Sat Aug 27, 2016 4:51 pm

Nyamekye,

Thank you, I got the robot to move by common grounding and running one battery to openmv and the other to power the servos of the robot base (used the servo example). I took the python course at codeacademy - yay me! I think I am ready to try to do this! With the markers example, I took some circles of colored construction paper of red, green, and blue and was playing with them to see if they would make a marker when close enough and got results of placing reds, greens, and blues in close proximity to one another. I need to get inside the two functions to try and understand how this really works - I could see the color number identifier change as the targets were placed closer together and merged into a single blob.

I am trying to come up with a scheme that would be reliable and based on "first principals". One of the previous post indicated to make a pac-man like marker to take advantage of a blobs direction. I am assuming for my application that only one marker will be in the field of view at a time, but random colored objects might show up in the field of view - like people walking by with similarly colored shoes. I was thinking to have one circle larger than the others with a direction that would always face north. That way the robot will always know its pose. I was thinking of placing smaller circular markers around the periphery of the large circle that were spaced such that they never be interpreted as a single blob. Always with the same number of small circles, but contrasting color from the larger circle. I quickly experimented and found that three small circles of the same color around the bigger circle would not appear as a single blob. I figure I can get 12 distinct markers with either a larger red, green, or blue circle, and three smaller circles around it in the other two contrasting colors - always four blobs visible and interpreted in the field of view. I have not figured out how many more distinct markers I could get by incorporating the directions of a pac man like smaller marker. I am thinking of checking to verify a marker by checking to see if there are exactly four blobs in the field of view, then checking to see if the three smaller blobs are nearly 1/4 the area of the primary blob. After these checks were passed, the machine would know it had seen an intentional marker and the marker would be uniquely identified by the list of four colors with the first color being the larger one. I could expand this to include variations of the directions of the smaller blobs if I needed more markers. Lastly, even though I got the bot to move, I have no idea how to start executing a line following routine. I googled "PID control python" and became quickly overwhelmed. Some more basic questions:

1) question deleted. I found the https://openmv.io/docs/library/omv.image.html
2)Are the three best colors to sense red green and blue?
3)Does it make sense from a false positive standpoint to check relative blob areas and total number of blobs before reporting a marker has been sensed?
4)Do you have any additional guidance for the line following part of the application? (ok if not - I will just try harder)
5)Is there a more efficient way to work with the bot to play with the pid parameters other than loading the main file from pc then mounting the board on the bot and observing what happens? I am not sure if it is ok to have the usb connected to the bot at the same time the servos are hooked up without the 3.7v lipo.

Thanks, Trev
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Sat Aug 27, 2016 11:32 pm

Good work so far.

2) Depends on the lighting in the area. But, yest, primary colors are the best.
3) Yes, that's a good kind of check. Of course, you'll have to figure out how to deal with no blobs being there... anyway, at this point your application dependent. Basically you have to test whatever you're doing a lot and refine.
4) See the line-flowing script under the color tracking examples. You should be able to see what's going on. It show's you how to do P control (the P part of PID control).
5) It's okay to have USB connected while the lipo is connected. The OpenMV Cam will try to power itself from the USB voltage source however since it has a higher voltage.
Nyamekye,
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby trevorb » Sun Aug 28, 2016 7:48 pm

You Rock, Thanks- T.
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby trevorb » Mon Sep 26, 2016 7:55 am

It follows a black line now- Thanks gents!
Attachments
image.jpeg
image.jpeg (479.17 KiB) Viewed 10423 times
User avatar
iabdalkader
Posts: 497
Joined: Sun May 24, 2015 3:53 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby iabdalkader » Mon Sep 26, 2016 8:05 pm

Nice work :) If you have any images/videos please share them here, could always use material for the website/tutorials :)
rescueops
Posts: 8
Joined: Thu Dec 29, 2016 4:54 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby rescueops » Thu Dec 29, 2016 5:00 pm

So I got the line following code down pat it follows a straight line. But now say there was a curved line how would I get it to follow or say if the line ends can I tell it to stop driving. because as of right now it just follows a straight line and will keep on going on and on.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Thu Dec 29, 2016 5:20 pm

See your other post. Thanks,
Nyamekye,
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby trevorb » Tue Jan 03, 2017 8:39 pm

making some progress :)
https://youtu.be/YR_s-6SLo4Q
trevorb
Posts: 15
Joined: Sun Jun 19, 2016 6:20 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby trevorb » Sun Feb 19, 2017 4:46 pm

Kwebana,
Can I Resolder white leds where the ir leds are without overloading the circuit? I still have been having difficulty with reliable line detection. My home has a bunch of windows and overhead lights so there is lots of reflections off my floor. I'm thinking of trying another approach now that cam m7 will have AprilTags. I am thinking to use retroreflective tape for the line and AprilTag white field. I am thinking these headlights will allow me turn up my threshold to 240,255 so everything else will be ignored. I did a test in the basement by turning on the red led and it seems to brighten the tape a little so I think I am on the right track.

Thanks,

Trev
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Sun Feb 19, 2017 10:22 pm

Yes, you can do that. I'd recommend not modifying the OpenMV Cam itself but instead just attaching a transistor driving circuit with some white LEDs.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Tue Feb 21, 2017 2:47 pm

Trevor, I'm trying to do the same, but it's not working as well as yours. My code is here: https://github.com/zlite/OpenMVrover. Can you share yours?
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Tue Feb 21, 2017 3:20 pm

Trevor is just following a line on the ground. It looks like your trying to see parallel lines in the field of view.

Do you have some debug info I can look at? Like, a picture of what the OpenMV Cam sees (unmodified) and the output after you do the edge detection followed by the line detection?
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Tue Feb 21, 2017 5:02 pm

Yes, I'm trying to implement a "vanishing point" approach to staying within the lines on either side of a track, on the assumption that roads tend to have features (lines, walls, contrast) that register as "lines" with the edge-detection libraries and can be averaged to lead to a steering angle. I'll upload some sample shots tonight.
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Wed Feb 22, 2017 6:32 pm

Here's a screenshot of it looking at black tape on a gray floor.
Screenshot_2017-02-22_23-24-28.png
Screenshot_2017-02-22_23-24-28.png (194.72 KiB) Viewed 10069 times
BTW, a picture of the car is also attached
Attachments
IMG_20170222_152821.jpg
IMG_20170222_152821.jpg (3.74 MiB) Viewed 10069 times
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Wed Feb 22, 2017 6:55 pm

Okay, um, quick question. How good is the line lock? Is it jittery or pretty stable?
Nyamekye,
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Wed Feb 22, 2017 7:28 pm

K, looked through your script. I think the math calculation part is done wrong. It looks like your accessing variables that are only variable in the loop above outside of that said loop:

Code: Select all

for l in lines:
        img.draw_line(l, color=(127)) # Draw lines
    if lines:
        if (l[2]-l[0]) != 0: # don't allow vertical lines (infinite slope)
Doesn't make any sense. l is only valid in the loop. I think you want to remove "if lines:". Then the bottom part:

Code: Select all

if counter != 0:
            steer_angle = 1/(totalslope/counter) # 1/(average slope), to compensate for the inverse slope curve
            print (steer_angle)
#           s1.pulse_width(cruise_speed) # move forward at cruise speed
            s2.pulse_width(1500 - int(steer_angle*steering_gain)) # steer
            pyb.delay(10)
Needs to be moved up to the same indentation as "totalslope = 0".

Anyway, it looks like after the above fixes your code can't deal with the line being straight. Because if it is straight then counter == 0 and you never set the steering angle to 0.

...

So, thinking about doing this at a higher level... so, when the line is off center the perspective will cause it to look like it's curving. I think you're going to need to find_lines in different parts of the image. Like the top, middle, and bottom parts. Otherwise I don't think you're going to get usable outputs.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Wed Feb 22, 2017 8:07 pm

Great feedback. I'll review those bugs and fix.

As for the line lock, it really depends on lighting and reflections. For example, with lighting from sunlight, I can tune the thresholds to find lines with the sun behind the car, but looking into the sun the reflections confuse it. Hard to find settings that work everywhere.

Interestingly, the blob-detection approach in your grayscale line following example works much better at spotting the lines under different lighting conditions.
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Wed Feb 22, 2017 8:11 pm

As for the problem of driving *between* the lines rather than along them, I agree it would be best to divide the image into right and left sides and look for lines in each. But if I can only see one of them, my problem is that I don't know if it's the left or the right side.

I'm also going to experiment with optical flow, which might lead to more statistical results and less dependency on distinct features. My assumption is that the flow vector field of a road is broadly correlated with position in the road and angle. But there's only one way to find out ;-)
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Wed Feb 22, 2017 8:20 pm

Update: I don't know what I was thinking. Optical Flow only gives motion, not position. Needs to be fused with an absolute, not relative, measurement.

That said, the Optical Flow example is super cool and it was fun playing with before I realized my mistake ;-)
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Wed Feb 22, 2017 11:05 pm

Oh, I was talking about cutting the image horizontally into three pieces. Like a top piece, a middle piece, and a bottom piece. I think you need to do that because the camera perspective is going to skew lines that are far off. Like, think about how far away the part of the line that is near the top of the image from the bottom part of the image. I don't think you can tread them as one thing and get good results.
Nyamekye,
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Wed Feb 22, 2017 11:06 pm

Going to make the optical flow a lot better soon. But, other things to work on first.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Thu Feb 23, 2017 12:35 am

Ok, I think I fixed that logic problem. I need to keep the "If lines" conditional to trap cases where no lines are found and we can't calculate a slope. But you were right that I had the flow wrong. I think this commit fixes it:
https://github.com/zlite/OpenMVrover/bl ... r/rover.py
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Thu Feb 23, 2017 1:07 am

Okay... other thoughts... I'd work on your activation function:

steer_angle = 1/(totalslope/counter)

Maybe try to determine the angle from thinking about the slope as if it were the slop of the hypotenuse on a right triangle and you're trying to find an angle? Not exactly sure what the math should be.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Thu Feb 23, 2017 1:18 am

Normally you'd use an inv tangent function there, but given the distortion effect in slope between the line close to you and that far away, I'm thinking of just implementing a regular PID and see if I can tune the distortion away with damping functions.

Still, we're making some progress. Now it weaves its way drunkenly through the track, but at least stays on the track.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Thu Feb 23, 2017 11:27 am

I think it's the arctan(delta_y/delta_x) = pheta. Where delta_y is the average of y deltas and delta x is the average of x deltas.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Sat Feb 25, 2017 9:47 pm

I've now updated the code with the arctan function you suggested and a basic PID loop to control the steering. Seems to work better!

https://github.com/zlite/OpenMVrover/bl ... idrover.py
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Sun Feb 26, 2017 12:26 am

BTW, here's the built-in line-following code with a PID motor controller added. Works great!

https://github.com/zlite/OpenMVrover/bl ... llowing.py
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Sun Feb 26, 2017 8:27 pm

I've now updated the code to follow lines of any color, so you can switch lanes on a FormulaPi track. Here's the code:
https://github.com/zlite/OpenMVrover/bl ... llowing.py

I need to tweak my PIDs a bit, but it works.

https://youtu.be/NhN7Fl57sHE
Last edited by zlite on Sun Feb 26, 2017 8:30 pm, edited 1 time in total.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Sun Feb 26, 2017 8:29 pm

Seems to need a lot of PID update. Well, the M7 will give you double the FPS so this should help a lot.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Mon Apr 03, 2017 2:13 am

This code with the new M7 OpenMV cam did great this weekend at the Thunderhill Self Racing Cars/DIY Robocars race (https://www.meetup.com/DIYRobocars/events/237232241/). Came in 2nd, beating out nVidia TX2 cars and a lot of RaspberryPi 3s. Here's a practice lap:

https://youtu.be/3ANMg0j5BNE

The code is here: https://github.com/zlite/OpenMVrover/bl ... Arduino.py

The secret to the good performance was weighting the top third of the frame the highest. These were the ROIs that worked best for us:

ROIS = [ # [ROI, weight]
(0, 100, 160, 20, 0.1), # You'll need to tweak the weights for your app
(0, 050, 160, 20, 0.3), # depending on how your robot is setup.
(0, 000, 160, 20, 0.7)
]
Last edited by zlite on Mon Apr 17, 2017 5:52 pm, edited 1 time in total.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Mon Apr 03, 2017 10:23 am

OMG that is fast.

Like a druken sailor. You're definitely pushing the PID loop out of it's control zone. But, hey, it still works. If you went slower I bet you could lock perfectly on the line.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Mon Apr 03, 2017 12:59 pm

Going fast was the point of the race ;-) Winning drunk is still winning!
rescueops
Posts: 8
Joined: Thu Dec 29, 2016 4:54 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby rescueops » Mon Apr 17, 2017 10:40 am

zlite wrote:
Tue Feb 21, 2017 2:47 pm
Trevor, I'm trying to do the same, but it's not working as well as yours. My code is here: https://github.com/zlite/OpenMVrover. Can you share yours?
Hello Zlite I am working on this project with my uncle who is Trevor we been tackling this for a while this was our version 1.0 I know he has revised it but this code does follow the line well. I can help you out a bit to if you let me know what your issues are in the coding, I sense it can be little confusing for some people I code a lot and it was even little tricky for me. But I am more then willing to help as well. https://github.com/E-V-G-N/OpenMV-Line- ... %20V%201.0
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Mon Apr 17, 2017 6:15 pm

Thanks for sharing that! Any particular reason why you didn't add a PID control loop to smooth it?
rescueops
Posts: 8
Joined: Thu Dec 29, 2016 4:54 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby rescueops » Tue May 16, 2017 5:09 pm

Yeah, we were going to go that route, but we decided to not for some reason. We are focusing on more like you were how to get it to lock onto the line. We are looking into adding a little headlight to help with the contrast and shadow issues. I just got the new board so I am going to take a look at your code and see what I can tweak for me and my uncle's application a bit.
rescueops
Posts: 8
Joined: Thu Dec 29, 2016 4:54 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby rescueops » Sun May 21, 2017 5:50 pm

Hey did something happen when the new cameras came out? We had a fully functional code and now gettings lots of undefined errors and what not. here is a view of the code
https://github.com/E-V-G-N/OpenMV-Line- ... Code%202.0
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Sun May 21, 2017 7:04 pm

The find blobs API was updated a while back. That code needs to be tweaked for the new Find blobs method. Only minor changes are necessary to the script.

See the line following example code. That was updated with how the new find blobs script accepts arguments.
Nyamekye,
rescueops
Posts: 8
Joined: Thu Dec 29, 2016 4:54 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby rescueops » Mon May 22, 2017 9:53 pm

Code: Select all

# Tracks a black line. Use [(128, 255)] for a tracking a white line.
GRAYSCALE_THRESHOLD = [(0, 64)]

sl = Servo(2) # P8
sr = Servo(1) # P7

# Camera setup...
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # use grayscale.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(30) # Let new settings take affect.
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock() # Tracks FPS.

def linerobot(turnangle, turnvelocity):
    wheelwidth = 6
    turnradius = wheelwidth/(math.sqrt(2 - 2 * math.cos(math.radians(turnangle)))+.0000001)
    if turnangle <= 0:
        vl = turnvelocity / turnradius * ( turnradius - wheelwidth / 2)
        vr = turnvelocity / turnradius * ( turnradius + wheelwidth / 2)
        sl.speed(vl)
        sr.speed(-vr)
    else:
        vl = turnvelocity / turnradius * ( turnradius + wheelwidth / 2)
        vr = turnvelocity / turnradius * ( turnradius - wheelwidth / 2)
        sl.speed(vl)
        sr.speed(-vr)

def check_stop():
            GRAYSCALE_THRESHOLD = [(0, 64)]
            stopROI = [(0, 000, 160,20)]
            blobs = img.find_blobs(GRAYSCALE_THRESHOLD, roi=r[0:4], merge=True) # r[0:4] is roi tuple.



merged_blobs = img.find_markers(blobs)
            
if blobs:
    # Find the index of the blob with the most pixels.
    most_pixels = 0
    largest_blob = 0
    for i in range(len(merged_blobs)):
        if merged_blobs[i].pixels() > most_pixels:
            most_pixels = merged_blobs[i].pixels()
            largest_blob = i
           
if merged_blobs[largest_blob][2] > 80:
                # Draw a rect around the blob.
                img.draw_rectangle(merged_blobs[largest_blob][0:4]) # rect
                img.draw_cross(merged_blobs[largest_blob][5], # cx
                               merged_blobs[largest_blob][6]) # cy
                sl.speed(0)
                sr.speed(0)
                print("false")
                return True

              # Draw a rect around the blob.
    img.draw_rectangle(blobs[largest_blob].rect())
    img.draw_cross(blobs[largest_blob].cx(),
                   blobs[largest_blob].cy())


# Each roi is (x, y, w, h). The line detection algorithm will try to find the
# centroid of the largest blob in each roi. The x position of the centroids
# will then be averaged with different weights where the most weight is assigned
# to the roi near the bottom of the image and less to the next roi and so on.
ROIS = [ # [ROI, weight]
        (0, 100, 160, 20, 0.7), # You'll need to tweak the weights for you app
        (0, 050, 160, 20, 0.3), # depending on how your robot is setup.
        (0, 000, 160, 20, 0.1)
       ]

# Compute the weight divisor (we're computing this so you don't have to make weights add to 1).
weight_sum = 0
for r in ROIS: weight_sum += r[4] # r[4] is the roi weight.

centroid_sum += blobs[largest_blob].cx() * r[4] # r[4] is the roi weight.
 center_pos = (centroid_sum / weight_sum) # Determine center of line.

     print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
    # connected to your computer. The FPS should increase once disconnected.


Will this work now I changed it up a bit
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Tue May 23, 2017 12:22 am

The find markers method doesn't exist anymore. See the find blobs method new API.
Nyamekye,
zlite
Posts: 70
Joined: Sun Feb 05, 2017 9:26 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby zlite » Tue May 23, 2017 10:19 am

Will you be updating the IDE's included examples to work with the new APIs? Right now a few of them are broken, including Find Lines.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Line Following - Blob Spotting/Decoding robot

Postby kwagyeman » Tue May 23, 2017 10:30 am

Yeah, but, I just moved to SF Bay area and my stuff isn't here so I can't work right now.
Nyamekye,

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests