Go to Post It would be better as the software person to preach to your team early on for non-reliance on software. - Tom Bottiglieri [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-02-2010, 08:17
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Camera code does not recognize target

The VisionDemo code seems to give us good video on the dashboard but when we ask it to find the target (which we have put in plain sight) it is not very good at it. The majority of the time it says there are no valid targets although some times it will find it. We thought this might be a lighting issue and tried changing the brightness but this did not seem to help. Are there other parameters we need to modify?
Reply With Quote
  #2   Spotlight this post!  
Unread 25-02-2010, 09:46
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,562
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Camera code does not recognize target

Have you reviewed the FRC Vision Whitepaper?
Reply With Quote
  #3   Spotlight this post!  
Unread 26-02-2010, 08:21
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,750
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Camera code does not recognize target

If you don't get the hang of it, post images and I can suggest what the problem may be. BTW, the default dashboard saves images from the camera into the documents directory.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 26-02-2010, 12:10
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Re: Camera code does not recognize target

Thanks for the suggestions. I looked up the Whitepaper and will try some variations. Although I had a little time last night I did not get very far and it will be a few days before I again have a set up where I can play with the camera. I also looked at the LabView code to see how it differed and noticed they were using a different compression and brightness (and possibly minimum line length).

We did notice that when the target analysis drew a purple display circle around the target that the normalized score was too low to be considered a target. So if we lowered the minimum score we could of course get it to detect the target, but I doubt that is the best way to go since that would likely find extraneous things too. I think we were probably about 10 to 12 feet away from the target and we may get better results in general when we are farther away. Again we still have a lot of things to check out.

I will post again when I have some more information. But if anyone else has been playing with this issue it would be great to know what they found to work best.
Reply With Quote
  #5   Spotlight this post!  
Unread 26-02-2010, 14:12
Zme Zme is offline
Registered User
FRC #2619
 
Join Date: Jan 2009
Location: Michigan
Posts: 83
Zme is on a distinguished road
Re: Camera code does not recognize target

it may just be our lighting but i increase the minimum match score significantly, then again, we also work in what used to be a school so there are a lot of white lockers with black knobs around and we weren't picking any up so

anyway: try setting up methods to modify the values of the target detection so that you don't have to rebuild, undeploy, download, and reboot, just set up a few buttons to change things around and away you go,


good luck with it,
Reply With Quote
  #6   Spotlight this post!  
Unread 02-03-2010, 09:33
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Re: Camera code does not recognize target

Thanks again for the suggestions. I have tried changing some of the settings and found a somewhat better match for our lighting (lowered compression to 10 and raised brightness to 25). It seemed like lowering compression does affect the video response time making it lag more, so I am not sure I want to go to the setting of 5 which labView uses.

There is still a problem, however, in the near target region where the target is not consistently recognized. I believe the ellipse routine is finding the target circle but the overall score value is too low to be recognized as a target. I plan to do some more testing by printing out the radii and score values to see what is happening but I believe the circle may be slightly distorted such that it significantly lowers the raw score enough to keep it from being detected as a target.

We also have issues of a low ceiling causing the lights to be in view at long distances. I noticed that was discussed in another thread and the suggestion was to use automatic white balance. I will try that as I have currently been using flixed fluorescent 1.

We did try to get the stored images from the classmate but could never find them so please give us more info on where they are located.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-03-2010, 22:52
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,750
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Camera code does not recognize target

The stored images should be placed into the Documents directory and named 1.jpg through 59.jpg. The default is to same one image per second and retain the image for sixty seconds before overwriting.

The sample images will help determine it the low scores are due to a glare problem or a distortion problem.

Greg McKaskle
Reply With Quote
  #8   Spotlight this post!  
Unread 04-03-2010, 23:27
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Re: Camera code does not recognize target

Having spent a good bit of time trying to get good target detection, I have found that there seems to be a problem with the C++ code. In the target.cpp file the sort function does not seem to actually sort the targets. So if the real target happens to be first on the list the program will appear successful but otherwise the program will either find something that is not the real target or not find any valid targets.

Another team mentor looked up information about the sort function and thinks the function is looking for a boolean comparison rather than a 1 or -1 integer. I have not had a chance to try changing to a boolean comparison but expect that will likely fix the problem.
Reply With Quote
  #9   Spotlight this post!  
Unread 05-03-2010, 00:03
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera code does not recognize target

Are you referring to this function in target.cpp? It looks fine to me.
Code:
/**
 * Compare two targets.
 * Compare the score of two targets for the sort function in C++.
 * @param t1 the first Target
 * @param t2 the second Target
 * @returns (1, 0, or -1) for the scores of t1 > t2, t1 == t2, and t1 < t2
 */
int compareTargets(Target t1, Target t2)
{
        if (t1.m_score > t2.m_score) return 1;
        if (t1.m_score < t2.m_score) return -1;
        return 0;
}
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 05-03-2010, 23:25
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Re: Camera code does not recognize target

I tried changing the compareTargets function to boolean as follows:

bool compareTargets(Target t1, Target t2) {
return (t1.m_score > t2.m_score)
}

This solved the problem. Apparently the sort function is looking for a true/false rather than -1/0/1. Both -1 and 1 were considered true (only 0 is considered false) so no sorting was actually being done.
Reply With Quote
  #11   Spotlight this post!  
Unread 05-03-2010, 23:46
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Camera code does not recognize target

Thanks! Hopefully this will resolve of the strange behaviour we were seeing when smaller, seemingly lower quality targets were being identified as the primary target! Our robot seems to like to track random circular objects in the room =).
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #12   Spotlight this post!  
Unread 06-03-2010, 00:12
Lucie365 Lucie365 is offline
Registered User
FRC #0365
 
Join Date: Feb 2010
Location: Wilmington, DE
Posts: 13
Lucie365 has a spectacular aura aboutLucie365 has a spectacular aura about
Re: Camera code does not recognize target

Oops...there should be a ";" at the end of the "return" line.
Reply With Quote
  #13   Spotlight this post!  
Unread 06-03-2010, 00:37
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera code does not recognize target

Quote:
Originally Posted by Lucie365 View Post
I tried changing the compareTargets function to boolean as follows:

bool compareTargets(Target t1, Target t2) {
return (t1.m_score > t2.m_score)
}

This solved the problem. Apparently the sort function is looking for a true/false rather than -1/0/1. Both -1 and 1 were considered true (only 0 is considered false) so no sorting was actually being done.
You are right. I don't know about WindRiver C++ but apparently the standard Microsoft C++ sort function is expecting a bool compare function as well. I didn't realize this either. Long time ago in C, I believe the sort function in C runtime expects a compare function to return +1, 0 or -1. Apparently, C++ expects bool. Good catch.

http://msdn.microsoft.com/en-us/libr...h1(VS.71).aspx
__________________
Reply With Quote
  #14   Spotlight this post!  
Unread 06-03-2010, 17:00
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Camera code does not recognize target

I tried deciphering the headers of <algorithm> as implemented in the WindRiver libraries, but I still can't 100% put this issue to bed. Can anyone else with more intricate knowledge of <algorithm> as implemented in WindRiver c++ comment on whether the sorting predicate expects a bool or -1,0,1 return?
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #15   Spotlight this post!  
Unread 06-03-2010, 19:42
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera code does not recognize target

In the old days with C, the sorting algorithm did use a compare function that returns 0, -1 or 1. Apparently, in C++, it is expecting a bool return. I don't know for sure for Wind River C++ but I checked with the Microsoft Visual C++ and it does say the compare function is expected to return bool. I did change the compare function to return bool and it is much more reliable now.

http://msdn.microsoft.com/en-us/libr...h1(VS.71).aspx

Quote:
_Comp
User-defined predicate function object that defines the comparison criterion to be satisfied by successive elements in the ordering. A binary predicate takes two arguments and returns true when satisfied and false when not satisfied.
__________________

Last edited by mikets : 06-03-2010 at 19:45.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Solenoid Code Does Not Work! superstretch C/C++ 8 23-02-2010 10:30
Default Code does not run usbcd36 Java 1 15-01-2010 15:27
driver station does not recognize usb 3 or 4... aksharma Technical Discussion 0 07-02-2009 12:57
Camera does not search in autonomous mode after reset Keith Watson Programming 17 07-03-2006 00:42
camera jerks and does not lock on when tracking kirkio Programming 2 10-02-2006 23:43


All times are GMT -5. The time now is 18:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi