|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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?
|
|
#2
|
||||
|
||||
|
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);
Code:
EllipseMatch *e = imaqDetectEllipses(m_imaqImage, ellipseDescriptor, curveOptions, shapeDetectionOptions, roi, &numberOfMatches); 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 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
}
Good luck Last edited by Dave Scheck : 14-09-2010 at 09:27. |
|
#3
|
||||
|
||||
|
Re: Modifying The 2010 Image Demo
I'm sorry but how would we make the implementations and of what would we implement.
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||||
|
|||||
|
Re: Modifying The 2010 Image Demo
It's now 2012. The thread is about code from two years ago.
|
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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?
|
|
#9
|
||||
|
||||
|
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.
|
|
#10
|
|||
|
|||
|
Re: Modifying The 2010 Image Demo
Wow, this helps... Thanks guys! (Sorry if I caused any facepalms)
|
|
#11
|
|||
|
|||
|
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! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |