Isolating Targets
Carter from United States  [12 posts]
7 year
 Hello again, I have a .robo file similar to the tutorials for targeting and tracking and have attached it here. It works for a lot of scenarios, but I'm in the process of trying to make it more robust. When I try an image such as the one attached it looks like I'm getting 1 BFR, but when I look at the BFR_Coordinates it's actually seeing something like 8 different ones. Is there a way that I can clarify that if it's seeing multiple rectangles and if those rectangles are within a larger one, I just want the larger one? ie. A way to remove contours contained within another? Thanks!  program.robo
Steven from United States  [1445 posts] 7 year
 Carter, 8 numbers = 4 points (x and y) = 1 BFR entry. The numbers are for the 4 corners of the polygon that creates the result. Based on the fact that you are doing the convex hull you will not get any inner rectangles. Since you are ending by eliminating all but the largest object you will only ever get one BFR entry or those 8 numbers. If you look at the numbers in sets of 2 and mouse over to the corners of your resulting image you will see the coordinates of the mouse in the lower status bar of RR. They will be very close to the numbers in that variable ... assuming x1,y1,x2,y2,x3,y3,x4,y4 as the legend for those numbers. Does that make sense? STeven.
Carter from United States  [12 posts] 7 year
 Hi STeven, I understand that each BFR has 8 coordinates, which is how I knew there were 8 BFRs it found (because the length of the BFR array was 64). The problem is that the convex hull doesn't always fill everything in and it leaves small unfilled holes. This results BFRs being calculated for these holes in addition to the BFR of the larger target. This doesn't happen super often, but there are definitely cases that exist such as this (and probably about another 10-15 or so I'm aware of so far as I've been testing sample images). I attached a picture showing the 8 BFRs drawn from the coordinates given. As you can see, there are several inside a larger one resulting in interior contours. (Note the black rectangle just shows the camera field of view and its the red one that is the external contour) I'm all set now because I fixed the problem by writing a function to calculate the area of each and then picking the one or two that makes most sense with the data, but it might be cool in the future if RoboRealm had a choose external contours function that is more robust than what I wrote.
Steven from United States  [1445 posts] 7 year
 Carter, Thanks for the confirmation ... what you can do is use the Fill module just before the Blob_Replace module which will remove any smaller inner parts from the BFR calculation. The default values for Fill should just work for your situation. Attached is an updated robofile. I also removed the hue module since the RGB Filter can create the same results without it. Its always good to use the least modules as possible to keep the frame rate up and debugging as easy as possible. :-) STeven. program.robo
Carter from United States  [12 posts] 7 year
 Thanks so much STeven! That works much better than what I had and is shorter. I've really impressed with all of the support RoboRealm provides; thanks again!

 This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.