Ask Your Question
0

Detect an object on known color on a green surface?

asked 2016-03-12 00:12:46 -0600

rkotwani gravatar image

updated 2016-03-12 20:09:26 -0600

On a white surface, the object can be detected by providing a color threshold to filter the image. Then the image is converted gray scale and passed through a medianBlur + Canny filter.

The green surface is actually artificial turf so its shiny and has texture.

image description

I've tried looking at only the green plane instead of graying out the picture. In addition, it helped to remove the Canny filter.

The image can be scanned for the width of the object (if the red color is above a certain threshold). The, the max amount of the red color pixels in a row can be saved into a variable (giving position and size). However, I'm still not sure the correct thresholds to check for and am getting inconsistent results. On the white surface I am getting slightly bigger widths than on the green surface.

new_image = cv2.add(cv2.add(image[:,:,2],-image[:,:,1]/2),-image[:,:,0]/2)

image description

edit retag flag offensive close merge delete

Comments

1

an example image would be helpful.

berak gravatar imageberak ( 2016-03-12 00:49:25 -0600 )edit

Thanks, this was posted kind of late last night, and I didn't think about it.

rkotwani gravatar imagerkotwani ( 2016-03-12 10:50:53 -0600 )edit

It sounds like you are using object detection, which would explain why the texture is giving you problems. If the color is known, why not just scan the image for that color pixel..or group of pixels?

jmbapps gravatar imagejmbapps ( 2016-03-12 11:10:06 -0600 )edit

@jmbapps Thanks! I can totally do that. I'm having a hard time scanning for the right thresholds. Let me update my post.

rkotwani gravatar imagerkotwani ( 2016-03-12 14:59:46 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-03-12 16:47:11 -0600

Tetragramm gravatar image

If it's always Red you're looking for it's pretty easy. It's BGR, so split the channels, and take Result = R - 0.5B - 0.5G

That gives you something that looks like this: image description

Otherwise, convert to HSV, and choose your thresholds in the H channel around the color you're looking for.

edit flag offensive delete link more

Comments

Actually I have a yellow object to detect also. Are you thresholding before performing the operation above? I posted what I did above.

rkotwani gravatar imagerkotwani ( 2016-03-12 19:23:22 -0600 )edit

No, I just did

multiply(G, 0.5, G)
multiply(B, 0.5, B)
subtract(R, G, R)
subtract(R, B, R)

Since you have other color objects you probably want to do filtering in on the H channel. Use the inRange function to set the bounds of what you're looking for.

Tetragramm gravatar imageTetragramm ( 2016-03-12 20:09:54 -0600 )edit

Awesome! I found that if I subtract 25% of red, 25% of yellow, and 50% of blue from red: I'll be able to detect both yellow and red objects.

What I mean is that this method gives me enough contours to find the image (this works). I'll probably experiment more with the framework you gave me.

Actually, I'll try the HSV inRange when I have time.

rkotwani gravatar imagerkotwani ( 2016-03-12 20:51:21 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-11 23:50:39 -0600

Seen: 1,095 times

Last updated: Mar 12 '16