Go to Post If all goes well (cross fingers) we'll have a joystick for driving and one - count it, one - button: FIRE - DonRotolo [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
  #16   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
  #17   Spotlight this post!  
Unread 13-01-2012, 09:57
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,171
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by davidthefat View Post
I am able to write the code in Java and port it into C++, but the C++ port will not be tested because I do not want to risk flashing the cRio too much.
Don't worry about it - it will take at least 10000 erase cycle to wear out any one block.
Reply With Quote
  #18   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
  #19   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
  #20   Spotlight this post!  
Unread 13-01-2012, 20:33
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
I believe opencv and the axiscamera's JPEG is your best shot
Reply With Quote
  #21   Spotlight this post!  
Unread 15-01-2012, 15:54
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++

basicxman, I tried the code you suggested and I found that we were finding a ridiculous amount of rectangles(around 42 million). Do you have any idea why this is happening? Also, is there any documentation for the imaqDetectRectangles function?
Reply With Quote
  #22   Spotlight this post!  
Unread 15-01-2012, 16:02
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 991
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by scottbot95 View Post
basicxman, I tried the code you suggested and I found that we were finding a ridiculous amount of rectangles(around 42 million). Do you have any idea why this is happening? Also, is there any documentation for the imaqDetectRectangles function?
You probably want to filter by brightness (luminance) or color (probably in HSL or HSV space) before trying to detect rectangles.
Reply With Quote
  #23   Spotlight this post!  
Unread 15-01-2012, 16:11
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++

I have a sheet of printer paper with the target(with correct proportions) printed on it except where the retro-reflective tape would be, we just printed green. I am then extracting the green plane and going from there.
Reply With Quote
  #24   Spotlight this post!  
Unread 15-01-2012, 17:37
Ross3098's Avatar
Ross3098 Ross3098 is offline
Programmer
AKA: Colin Ross
FRC #3098 (The Captains)
Team Role: Programmer
 
Join Date: Sep 2011
Rookie Year: 2010
Location: Waterford
Posts: 41
Ross3098 will become famous soon enoughRoss3098 will become famous soon enough
Re: Tracking Rectangles with Java/C++

Our team is also trying to figure out how to track the rectangles. Ive been spending a few hours or so looking over nivision.h as well as a few white papers and i seem to have gotten this far:

Code:
	
m_ModifiedImage = m_HSLImage->ThresholdHSL(80,125,45,60,115,130);
	
ImaqImage = m_ModifiedImage->GetImaqImage();
The white paper about the vision targets talks about applying a convex hull operation to really help those rectangles pop out. The main problem I have at the moment is that I have no idea how to apply said operation in C++. Ive found the imaqConvexHull() operation but have no clue how to start it.
__________________
2012 FRC Championship: 4th pick, Quarterfinalist: Thanks 1507, 51!
2012 Michigan State Championship: 4th Seed, 3rd Alliance Captain, Semifinalist: Thanks 33 and 2137!
2012 Northville District: 3rd Pick, Quarterfinalist. Thanks 302, 4405!
2012 Waterford District: 2nd Pick, Finalist. Thanks 573, 3601!
2011 Waterford District: 8th seed, 1st pick, Semi Finalist. Thanks to 573 and 3770
2011 Ann Arbor District: 2nd seed, Finalist. Thanks to 548 and 247.
2011 Michigan State Championship: Semi Finalist. Thanks to 548 (Again) and 74.
2011 FIRST World Championship: 8th seed, Quarterfinalist. Thanks to 74(Again) and 846.
Reply With Quote
  #25   Spotlight this post!  
Unread 15-01-2012, 17:54
PriyankP's Avatar
PriyankP PriyankP is offline
Registered User
FRC #0188 (Woburn Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Toronto, Canada
Posts: 87
PriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud ofPriyankP has much to be proud of
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by Ross3098 View Post
I have no idea how to apply said operation in C++. Ive found the imaqConvexHull() operation but have no clue how to start it.
This should help you get started! I'll be more helpful more once I see what the code I wrote does when I get it to run on a robot.
__________________
Champs Schedule Highlighter App [CD Thread]

#### XYZ Regional Finalists
Reply With Quote
  #26   Spotlight this post!  
Unread 15-01-2012, 18:06
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
basicxman, I tried the code you suggested and I found that we were finding a ridiculous amount of rectangles(around 42 million). Do you have any idea why this is happening? Also, is there any documentation for the imaqDetectRectangles function?
Quote:
Originally Posted by RufflesRidge View Post
You probably want to filter by brightness (luminance) or color (probably in HSL or HSV space) before trying to detect rectangles.
Aye, if you generate C code from Vision Assistant it will call imaqThreshold too - something I forgot about in my original snippet.
Reply With Quote
  #27   Spotlight this post!  
Unread 15-01-2012, 18:14
rudun's Avatar
rudun rudun is offline
Registered User
FRC #0496 (Royals)
Team Role: Coach
 
Join Date: Jan 2009
Rookie Year: 2005
Location: Babylon
Posts: 47
rudun is an unknown quantity at this point
Re: Tracking Rectangles with Java/C++

Would this be how to use the detectRectangles function in java. We looked at the ellipseDetect and I am thinking that hey do the same thing just based on different descriptors.

Code:
    private static final BlockingFunction imaqDetectRectanglesFn =
            NativeLibrary.getDefaultInstance().getBlockingFunction("imaqDetectRectangles");
    static { imaqDetectRectanglesFn.setTaskExecutor(NIVision.taskExecutor); }
    private static Pointer numberOfRectanglesDetected = new Pointer(4);
    
     public static RectangleMatch[] detectRectangles(MonoImage image, RectangleDescriptor rectangleDescriptor,
            CurveOptions curveOptions, ShapeDetectionOptions shapeDetectionOptions,
            RegionOfInterest roi) throws NIVisionException {

        int curveOptionsPointer = 0;
        if (curveOptions != null)
            curveOptionsPointer = curveOptions.getPointer().address().toUWord().toPrimitive();
        int shapeDetectionOptionsPointer = 0;
        if (shapeDetectionOptions != null)
            shapeDetectionOptionsPointer = shapeDetectionOptions.getPointer().address().toUWord().toPrimitive();
        int roiPointer = 0;
        if (roi != null)
            roiPointer = roi.getPointer().address().toUWord().toPrimitive();

        int returnedAddress =
                imaqDetectRectanglesFn.call6(
                image.image.address().toUWord().toPrimitive(),
                rectangleDescriptor.getPointer().address().toUWord().toPrimitive(),
                curveOptionsPointer, shapeDetectionOptionsPointer,
                roiPointer,
                numberOfRectanglesDetected.address().toUWord().toPrimitive());

        try {
            NIVision.assertCleanStatus(returnedAddress);
        } catch (NIVisionException ex) {
            if (!ex.getMessage().equals("No error."))
                throw ex;
        }

        RectanglesMatch[] matches = RectanglesMatch.getMatchesFromMemory(returnedAddress, numberOfRectanglesDetected.getInt(0));
        NIVision.dispose(new Pointer(returnedAddress,0));
        return matches;
    }
Reply With Quote
  #28   Spotlight this post!  
Unread 15-01-2012, 18:20
Ross3098's Avatar
Ross3098 Ross3098 is offline
Programmer
AKA: Colin Ross
FRC #3098 (The Captains)
Team Role: Programmer
 
Join Date: Sep 2011
Rookie Year: 2010
Location: Waterford
Posts: 41
Ross3098 will become famous soon enoughRoss3098 will become famous soon enough
Re: Tracking Rectangles with Java/C++

Quote:
Originally Posted by PriyankP View Post
This should help you get started! I'll be more helpful more once I see what the code I wrote does when I get it to run on a robot.
Correct me if I am wrong but does this mean that the integer that the imaqConvexHull() operation returns to is the score? And also I am wondering if the destination image is actually modified within the operation.
__________________
2012 FRC Championship: 4th pick, Quarterfinalist: Thanks 1507, 51!
2012 Michigan State Championship: 4th Seed, 3rd Alliance Captain, Semifinalist: Thanks 33 and 2137!
2012 Northville District: 3rd Pick, Quarterfinalist. Thanks 302, 4405!
2012 Waterford District: 2nd Pick, Finalist. Thanks 573, 3601!
2011 Waterford District: 8th seed, 1st pick, Semi Finalist. Thanks to 573 and 3770
2011 Ann Arbor District: 2nd seed, Finalist. Thanks to 548 and 247.
2011 Michigan State Championship: Semi Finalist. Thanks to 548 (Again) and 74.
2011 FIRST World Championship: 8th seed, Quarterfinalist. Thanks to 74(Again) and 846.
Reply With Quote
  #29   Spotlight this post!  
Unread 15-01-2012, 21:29
Ross3098's Avatar
Ross3098 Ross3098 is offline
Programmer
AKA: Colin Ross
FRC #3098 (The Captains)
Team Role: Programmer
 
Join Date: Sep 2011
Rookie Year: 2010
Location: Waterford
Posts: 41
Ross3098 will become famous soon enoughRoss3098 will become famous soon enough
Re: Tracking Rectangles with Java/C++

What is imaqConvexHull() returning to? I have it returning to an integer but what value does the integer have?
__________________
2012 FRC Championship: 4th pick, Quarterfinalist: Thanks 1507, 51!
2012 Michigan State Championship: 4th Seed, 3rd Alliance Captain, Semifinalist: Thanks 33 and 2137!
2012 Northville District: 3rd Pick, Quarterfinalist. Thanks 302, 4405!
2012 Waterford District: 2nd Pick, Finalist. Thanks 573, 3601!
2011 Waterford District: 8th seed, 1st pick, Semi Finalist. Thanks to 573 and 3770
2011 Ann Arbor District: 2nd seed, Finalist. Thanks to 548 and 247.
2011 Michigan State Championship: Semi Finalist. Thanks to 548 (Again) and 74.
2011 FIRST World Championship: 8th seed, Quarterfinalist. Thanks to 74(Again) and 846.
Reply With Quote
  #30   Spotlight this post!  
Unread 15-01-2012, 21:45
Greg McKaskle Greg McKaskle is online now
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,756
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++

From the CVI documentation,

Return Value
Type

Description


int On success, this function returns a non-zero value. On failure, this function returns 0. To get extended error information, call imaqGetLastError().


Greg McKaskle
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 21:39.

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