Using jitter (cv.jit) to track a square

Mar 13, 2009 at 4:21pm

Using jitter (cv.jit) to track a square

Hi all,

I am trying to use the cv.jit objects, or anything I can, to be able to recognize a simple squre being seen on the live camera feed. I have tried a few variations and get the best results with the cv.jit.lines object. That can do a crude outline but it doesn’t give me the data I need.

My goal is to be able to show a rectangle object (like a shoe box) and then have it recognize that it IS a square, and then tell me location and scale of it.

I am pretty sure, after looking through as many help files and posts as I can, that jitter and probably cv.jit can do do this but I can’t get there. Any help would be very much apreciated.

thanks

jon

p.s.

I think I am being mental about the format of pasting my patch in here. I must have missed the boat on some detail to have it look like everyone else’s.

– Pasted Max Patch, click to expand. –

[mod: replaced with compressed version]

#42840
Mar 14, 2009 at 11:58pm

when posting patches, use the “copy compressed” option in the file menu.
If you can isolate the rectangle from its environment by making it a particular color, you could use jit.chromakey in mode 1 to generate a b/w image of only the rectangle, and use jit.findbounds to describe it’s perimeter, from which you can get the location and size.
If you isoloate it by brightness, you could use jit.op @op >p or jit.lumakey, and again use jit.findbounds.
You may also be able to use a cv.jit object (don’t know which off the top of my head…blob or heads or something like that?…to isolate it, and, once again, use findbounds.

#153355
Mar 15, 2009 at 4:49pm

Hey.

thanks a lot for the reply. Those seem like great ways to achieve my goal, the problem though is that my video feed is in black and white, and the square appears much more like a wire frame than an opaque square. With cv.jit.canny I can get it to make a clear outline of the square but with broken edges. The biggest issue is that when I compress/mask/and remove the background of my feed, I more often than not see 3 edges clearly and 4 edges like 50% of the time.

The size of the object will be the same so I was hoping to have jitter search out a specific square shape and then give location, size, etc., when it has a ” best fit” type finder. I can get outlines with cv.jit.lines also but i don’t know how to give jitter a shape to search for.

Also thanks for the copy compress tip.

Any other suggestions would be great. I’ll also include an image so you can see what i am working with.

thanks

j

– Pasted Max Patch, click to expand. –
#153356
Apr 9, 2009 at 5:48pm

cv.jit.undergrad?

#153357
Apr 10, 2009 at 5:03am

It is in a paid library, but [tap.jit.colortrack] may be of some use as well (there is a demo of tap.tools).

#153358
Apr 10, 2009 at 2:50pm

hey guys,

thanks for the replies.

One issue is that the object I am trying to detect is not opaque and is from a black and white video. The square appears much more like a wire frame with a white perimeter.

I tried to dig around the help files for the undergrad and learn objects but had trouble getting them to work. Any suggestions? As for the tap tools, I had the demo installed and it ran out so I’m not sure how I can try it out…..I will look into it though.thanks a lot

j

#153359
Apr 10, 2009 at 5:45pm

I’ve never used undergrad, but I considered using it once. My guess is that you use cv.jit.moments to save a list of numbers associated with different aspects of the shape (the ideal square.) Undergrad compares the list from the ideal shape with the shape it sees and gives you a number representing the aspects that are similar enough. If the number is greater than x, assume it’s a square?

You can do the cv.jit.canny processing first and then undergrad. If have specific questions about how undergrad works, it might be easier to help, but it seems like it might be the “best fit” object that you said you were looking for.

#153360
Jan 2, 2010 at 3:14am

Hi, it might help a lot if you provided a sample image. Normally, if you could filter your image to get an opaque square, I would recommend using cv.jit.shift in mode 1, which would provide you with a set of vertices for the tracked region. You could then compare the image mass of the region with the expected value from the vertices. Since you only have partial edges, though, that’s going to be much more difficult. I think cv.jit.lines is your best bet in a situation like this but you’re going to have to do some work on the data. (I hope you like math.) Essentially, you need to find where the lines cross (if they do) and measure the angle. If you have a line segment that’s crossed by two other lines at more or less 90 degrees, you might have a box.

Anyway, in my experience, it’s always better to try to solve a vision problem in hardware first, and then work on the software. Using infrared lighting, for instance, you might be able to get a much better separation between the box and the background.

#153361

You must be logged in to reply to this topic.