Go to Post I guess we're going amish this year. - Jon Anderson [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 4.80 average. Display Modes
  #1   Spotlight this post!  
Unread 09-01-2012, 20:05
Derek012's Avatar
Derek012 Derek012 is offline
I miss my frisbees
FRC #4564 (Orange Chaos)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Maine
Posts: 25
Derek012 is on a distinguished road
Re: Tracking Rectangles with Java/C++

If your team isnt 100% against using labview at all you could do the image processing from the Classmates Dashboard by connecting the camera through the bridge instead of the cRio.
Reply With Quote
  #2   Spotlight this post!  
Unread 09-01-2012, 20:13
vinnie's Avatar
vinnie vinnie is offline
Registered User
FRC #3309 (Friarbots)
Team Role: College Student
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Los Angeles / Anaheim
Posts: 107
vinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond reputevinnie has a reputation beyond repute
Re: Tracking Rectangles with Java/C++

My team is going to be putting a small Atom powered computer on our robot to do vision processing and other high-level functions. We are going to be using the javacv library to utilize OpenCV in Java. We experimented with vision processing on the cRIO last year, but we found that it was very slow and often lagged the rest of the robot functions. You can easily (I wrote a demo program in ~10 minutes) detect edges/contours with OpenCV and from there decide whether or not the contours make the rectangle you're looking for or not.
Reply With Quote
  #3   Spotlight this post!  
Unread 09-01-2012, 20:19
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by vinnie View Post
My team is going to be putting a small Atom powered computer on our robot to do vision processing and other high-level functions. We are going to be using the javacv library to utilize OpenCV in Java. We experimented with vision processing on the cRIO last year, but we found that it was very slow and often lagged the rest of the robot functions. You can easily (I wrote a demo program in ~10 minutes) detect edges/contours with OpenCV and from there decide whether or not the contours make the rectangle you're looking for or not.
Good luck doing that.

May I suggest using linux without xserver and just going with C++ to bypass the JVM.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.

Last edited by davidthefat : 09-01-2012 at 20:25.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-01-2012, 05:18
cesaros cesaros is offline
César Javaroni
FRC #1382 (ETEP Team)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Brazil
Posts: 21
cesaros is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

My Question now is:
Will OpenCV work normally on cRIO, and, will it take a lot of processing from it ?

We often write some huge programs to avoid errors, and it already take a little of cRIO, but, if exits anything that we can use to process this images :/

Using any kind of notebook,netbooks, whatever... Are out of our mind, since our money isn't enough for it.

Thanks.
Reply With Quote
  #5   Spotlight this post!  
Unread 10-01-2012, 07:24
abrightwell abrightwell is offline
Lead Software Engineer
FRC #0342 (Burning Magnetos)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Charleston, SC
Posts: 20
abrightwell is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

Have you read through this whitepaper?

http://firstforge.wpi.edu/sf/docman/...n.root/doc1302

While it doesn't talk specifically to functions or specific library calls, it does talk about different techniques specifically related to this years game.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-01-2012, 08:00
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,752
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: Tracking Rectangles with Java/C++

Just so there is no misunderstanding, the vision libraries that LabVIEW uses are equally accessible from C/C++. The NI product for C development is called LabWindows CVI, so the vision documentation with the CVI suffix is all about the C/C++ entry points.

C:\Program Files\National Instruments\Vision\Documentation contains general documentation about vision processing and LV and C/C++ specific documents and others specific to Vision Assistant. It also has a calibration grid file if you need to correct the images for lens distortion.

The libraries are installed on the cRIO and if you have installed Vision Assistant, I believe you have them on the laptop as well.

It has been a while since I've looked at the WPI wrappers, and at least initially, they tended to hide the imaq entry point rather than simplify them. Perhaps the Examples for C based image processing will be helpful. They are located at C:\Program Files\National Instruments\Vision\Examples\MSVC.

NI doesn't have Java wrappers for the C libraries or for much else. I know some have been added to WPILib, but it is far from complete. If you are more familiar with OpenCV, that is certainly a good option. I wouldn't expect it to be that much difference in performance or capabilities, but both libraries have their specializations and benefits. If you search online, you can probably find some comparisons.

Once again, I'd also encourage you to take advantage of vision assistant, its code generation features and the vision concept manual.

Greg McKaskle
Reply With Quote
  #7   Spotlight this post!  
Unread 11-01-2012, 19:22
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by Greg McKaskle View Post
Just so there is no misunderstanding, the vision libraries that LabVIEW uses are equally accessible from C/C++. The NI product for C development is called LabWindows CVI, so the vision documentation with the CVI suffix is all about the C/C++ entry points.
So I've spent the morning looking around nivision.h, the "NI Vision for LabWindows/CVI Function Reference Help", and the old ellipsis tracking code to figure out tracking rectangles in C++. Here's a snippet of [entirely untested as I don't currently have access to a cRio] code.

Code:
void Camera::FindRectangles() {
    HSLImage  *rawImage  = camera.GetImage();
    MonoImage *monoImage = rawImage->GetLuminancePlane();
    Image     *image     = monoImage->GetImaqImage();
    workingImageWidth  = monoImage->GetWidth();
    workingImageHeight = monoImage->GetHeight();
    delete monoImage;
    delete rawImage;

    RectangleDescriptor *rectangleDescriptor = new RectangleDescriptor;
    rectangleDescriptor->minWidth  = 0;
    rectangleDescriptor->minHeight = 0;
    rectangleDescriptor->maxWidth  = workingImageWidth;
    rectangleDescriptor->maxHeight = workingImageHeight;

    int numCurrentMatches;
    RectangleMatch *temp;
    temp = imaqDetectRectangles(image,
                                rectangleDescriptor,
                                NULL, // Default curve options as per manual.
                                NULL, // Default shape detection options.
                                NULL, // (ROI) Whole image should be searched.
                                &numCurrentMatches);
    matches->erase(matches->begin(), matches->end());
    matches = new vector<RectangleMatch>;
    for (int i = 0; i < numCurrentMatches; i++)
        matches->push_back(temp[i]);
    
    imaqDispose(temp);
}
EDIT: CVI manual located at C:\Program Files (x86)\National Instruments\Vision\Documentation\VDM_CVI_User_Manu al.pdf
Reply With Quote
  #8   Spotlight this post!  
Unread 12-01-2012, 19:37
scottbot95 scottbot95 is offline
Registered User
FRC #1388 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Arroyo Grande, CA
Posts: 46
scottbot95 is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

Would I be correct in assuming that in your example code, Camera is a class you made?
Reply With Quote
  #9   Spotlight this post!  
Unread 13-01-2012, 09:47
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by scottbot95 View Post
Would I be correct in assuming that in your example code, Camera is a class you made?
Yes, once we have our tracking code working completely and performing as we'd like, I'll likely post the full source code and an accompanying whitepaper.
Reply With Quote
  #10   Spotlight this post!  
Unread 21-01-2012, 17:37
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by basicxman View Post
Here's a snippet of [entirely untested as I don't currently have access to a cRio] code.
Do not use this snippet! After I finally got to experiment with the camera for a while today, I've fixed some flaws in that script and found a better way of doing it entirely.
Reply With Quote
  #11   Spotlight this post!  
Unread 10-01-2012, 09:29
JamesBrown JamesBrown is offline
Back after 4 years off
FRC #5279
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Lynchburg VA
Posts: 1,280
JamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond reputeJamesBrown has a reputation beyond repute
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by vinnie View Post
My team is going to be putting a small Atom powered computer on our robot to do vision processing and other high-level functions. We are going to be using the javacv library to utilize OpenCV in Java. We experimented with vision processing on the cRIO last year, but we found that it was very slow and often lagged the rest of the robot functions. You can easily (I wrote a demo program in ~10 minutes) detect edges/contours with OpenCV and from there decide whether or not the contours make the rectangle you're looking for or not.
I won't say that this is a bad idea but I have seen quite a few teams try something like this and have it cause them more trouble than it is worth. The cRIO is powerful enough to handle vision and motor control, there are thousands of industrial manipulators doing both on the same hardware FIRST uses.

Quote:
Originally Posted by davidthefat View Post
Good luck doing that.

May I suggest using linux without xserver and just going with C++ to bypass the JVM.
While it will reduce the complexity of setting up the board (computer) they use to some degree it is probably far easier to spend an extra hour configuring their OS of choice than it would be to switch from JAVA to C++.

Quote:
Originally Posted by cesaros View Post
My Question now is:
Will OpenCV work normally on cRIO, and, will it take a lot of processing from it ?

We often write some huge programs to avoid errors, and it already take a little of cRIO, but, if exits anything that we can use to process this images :/

Using any kind of notebook,netbooks, whatever... Are out of our mind, since our money isn't enough for it.

Thanks.
Look at the files mentioned in Greg's posts they will give you a good idea of what is available for you to use on the cRIO.

Derek mentioned above that you could try to do the vision processing on the classmate or whatever computer you use for an OI. This may be an option for offloading some of the processing, however I'd imagine it would not work for Autonomous.
__________________
I'm Back


5279 (2015-Present)
3594 (2011)
3280 (2010)
1665 (2009)
1350 (2008-2009)
1493 (2007-2008)
1568 (2005-2007)
Reply With Quote
  #12   Spotlight this post!  
Unread 13-01-2012, 14:23
shuhao shuhao is offline
Registered User
FRC #4069 (Lo-Ellen Robotics)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Sudbury
Posts: 138
shuhao is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by vinnie View Post
My team is going to be putting a small Atom powered computer on our robot to do vision processing and other high-level functions. We are going to be using the javacv library to utilize OpenCV in Java. We experimented with vision processing on the cRIO last year, but we found that it was very slow and often lagged the rest of the robot functions. You can easily (I wrote a demo program in ~10 minutes) detect edges/contours with OpenCV and from there decide whether or not the contours make the rectangle you're looking for or not.

How exactly are you guys accomplishing that? Power connection, networking? Not sure how that would be done as we're also thinking of doing that.
Reply With Quote
  #13   Spotlight this post!  
Unread 13-01-2012, 17:18
JacobGH JacobGH is offline
Registered User
FRC #1849
 
Join Date: Nov 2011
Location: Bethesda, MD
Posts: 18
JacobGH is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

I'm working on this problem in Java. Am I crazy or do they only make a method available for detcting ellipses and nothing else? Can we, at least, access the values for individual pixels? That way, if they give us nothing else, we could at-least write our own image processing algorithms.
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


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

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