Go to Post In engineering, it's important to use the appropriate tools and not more resources than are required. - AdamHeard [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 13-09-2010, 19:53
Rangel(kf7fdb)'s Avatar
Rangel(kf7fdb) Rangel(kf7fdb) is offline
John Rangel
FRC #0842 (Falcon Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Phoenix, AZ
Posts: 725
Rangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond repute
Modifying The 2010 Image Demo

Hello, we want to start modifying the 2010 image demo on windriver. We want to make it so that the robot detects a square instead of a circle. How would we do that and where would we change the code?
__________________
2012 Dean's List Winner
2011-2014 Arizona Regional Winners
2016 Las Vegas Regional Winner
2014-? Mentor


Reply With Quote
  #2   Spotlight this post!  
Unread 14-09-2010, 09:24
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Modifying The 2010 Image Demo

I don't have the demo in front of me, but I have some test code that we wrote that was based on it. We moved some things around, so you'll have to do a little legwork to find the exact files that the corresponding code is in.

To detect elipses, the DetectEllipses of the MonoImage class is called from somewhere in the demo code
Code:
    results = luminancePlane->DetectEllipses(&ellipseDescriptor,
                                             &curveOptions, &shapeOptions,
                                             roi);
If you look at the what DetectEllipses is doing, you'll see this among some other code
Code:
	EllipseMatch *e = imaqDetectEllipses(m_imaqImage, ellipseDescriptor, curveOptions, shapeDetectionOptions, roi, &numberOfMatches);
This is the call to the IMAQ library that is doing the vision processing. If you look in nivision.h in the section where imaqDetectEllipses is defined, you'll see this prototype (kept the ellipse one here for reference)
Code:
IMAQ_FUNC EllipseMatch*             IMAQ_STDCALL imaqDetectEllipses(const Image* image, const EllipseDescriptor* ellipseDescriptor, const CurveOptions* curveOptions, const ShapeDetectionOptions* shapeDetectionOptions, const ROI* roi, int* numMatchesReturned);

IMAQ_FUNC RectangleMatch*           IMAQ_STDCALL imaqDetectRectangles(const Image* image, const RectangleDescriptor* rectangleDescriptor, const CurveOptions* curveOptions, const ShapeDetectionOptions* shapeDetectionOptions, const ROI* roi, int* numMatchesReturned);
So, you'll see that other than the second parameter, the calls are identical in terms of inputs.

So where does that leave you? What I would do is create a new class that inherits from MonoImage. I would do this in the team code instead of making the change directly in WPILib. This makes it easier to update WPILib in the future. In that class I would have a DetectRectangles method that mirrors what DetectEllipses is doing. Something like
Code:
class WsMonoImage : public MonoImage
{
    vector<RectangleMatch> * MonoImage::DetectRectangles(
		RectangleDescriptor *rectangleDescriptor, CurveOptions *curveOptions,
		ShapeDetectionOptions *shapeDetectionOptions, ROI *roi);
};

vector<RectangleMatch> * WsMonoImage::DetectRectangles(
		RectangleDescriptor *rectangleDescriptor, CurveOptions *curveOptions,
		ShapeDetectionOptions *shapeDetectionOptions, ROI *roi)
{
       // I'm just showing the IMAQ call here.  You'll need to complete the implementation
	RectangleMatch *e = imaqDetectRectangles(m_imaqImage, rectangleDescriptor, curveOptions, shapeDetectionOptions, roi, &numberOfMatches);
       // more implementation would be here
}
As a C++ takeaway for the day, this demonstrates the importance of inheritance. The MonoImage does some things that are really good, but it doesn't quite do what we want and it's in a file that we don't really want to modify if we can avoid it. So, by using inheritance, we can make a class that does everything that MonoImage does plus what we want.

Good luck

Last edited by Dave Scheck : 14-09-2010 at 09:27.
Reply With Quote
  #3   Spotlight this post!  
Unread 14-09-2010, 19:00
Rangel(kf7fdb)'s Avatar
Rangel(kf7fdb) Rangel(kf7fdb) is offline
John Rangel
FRC #0842 (Falcon Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Phoenix, AZ
Posts: 725
Rangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond reputeRangel(kf7fdb) has a reputation beyond repute
Re: Modifying The 2010 Image Demo

I'm sorry but how would we make the implementations and of what would we implement.
__________________
2012 Dean's List Winner
2011-2014 Arizona Regional Winners
2016 Las Vegas Regional Winner
2014-? Mentor


Reply With Quote
  #4   Spotlight this post!  
Unread 15-09-2010, 00:52
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Modifying The 2010 Image Demo

Look at DetectEllipses inside MonoImage.cpp. That should be the foundation for your DetectRectangles. Just copy/paste the entire guts of DetectEllipses into DetectRectangles. At this point, all you need to do is replace references to ellipse with rectangle. The EllipseMatch will become RectangleMatch. The vector type will change, the vector variable name should be changed to rectangles.

Along the way, I would suggest reading and understanding exactly what the function is doing. That's the only way you'll really learn. Copy/Paste never taught anybody anything.

Give that a shot and if you really can't figure it out, send me a PM and I'll clarify more.
Reply With Quote
  #5   Spotlight this post!  
Unread 06-02-2012, 22:33
Jake Harmon Jake Harmon is offline
Registered User
FRC #3284
 
Join Date: Feb 2012
Location: Camdenton, MO
Posts: 3
Jake Harmon is an unknown quantity at this point
Re: Modifying The 2010 Image Demo

Hey, thanks for the info on this thread, but how do you access the MonoImage.cpp file? We're having trouble finding it.
Thanks.
Reply With Quote
  #6   Spotlight this post!  
Unread 06-02-2012, 23:04
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Modifying The 2010 Image Demo

It's now 2012. The thread is about code from two years ago.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2012, 15:48
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Modifying The 2010 Image Demo

If your just getting started with the 2010 Image Demo, I would recommend updating your WPILib and using the new 2012 image demo sample.

See: http://www.chiefdelphi.com/forums/sh...d.php?t=101991
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2012, 17:35
Jake Harmon Jake Harmon is offline
Registered User
FRC #3284
 
Join Date: Feb 2012
Location: Camdenton, MO
Posts: 3
Jake Harmon is an unknown quantity at this point
Re: Modifying The 2010 Image Demo

I understand that this is the code from 2010, but our team was considering examining this image demo to understand how to detect the squares above the goals this year. We have the 2010 image demo, how can we access the MonoImage.cpp file? Or are you saying that this is not a good way to go about image tracking?
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2012, 18:13
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: Modifying The 2010 Image Demo

There is a new vision sample for 2012. If you have installed the latest update (http://firstforge.wpi.edu/sf/frs/do/...2_update_for_c), you will see the vision tracking sample.
__________________
Reply With Quote
  #10   Spotlight this post!  
Unread 07-02-2012, 18:31
Jake Harmon Jake Harmon is offline
Registered User
FRC #3284
 
Join Date: Feb 2012
Location: Camdenton, MO
Posts: 3
Jake Harmon is an unknown quantity at this point
Re: Modifying The 2010 Image Demo

Wow, this helps... Thanks guys! (Sorry if I caused any facepalms)
Reply With Quote
  #11   Spotlight this post!  
Unread 07-02-2012, 18:55
DavisC DavisC is offline
Registered User
FRC #0539 (Titans)
Team Role: College Student
 
Join Date: Jul 2011
Rookie Year: 2010
Location: Virginia
Posts: 200
DavisC is just really niceDavisC is just really niceDavisC is just really niceDavisC is just really nice
Re: Modifying The 2010 Image Demo

Actually I thank you, cause I want to get the camera working and didn't know there is a 2012 sample! I thought I would have to change it around when I don't even understand how to do it on my own.

Thanks!
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
2010 Image Demo Rangel(kf7fdb) C/C++ 15 07-09-2010 19:55
Decoupling the image acquisition from the Image Processing Tom Line Programming 8 09-03-2010 17:52
Modifying the Piston Threads JMillar Pneumatics 1 20-02-2010 19:11
Anyone modifying the stock gearboxes? Swampdude Technical Discussion 17 04-02-2005 13:15


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

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