Log in

View Full Version : Problem using the camera.


Teh1337Bix
18-01-2010, 22:39
I've been trying out the camera in the vision assistant and it works great. Now I wanna put ellipse detection into our robot. The code below is the code straight from the documentation but it isn't working though because it doesn't know where any of the mentioned classes are (mono image, color image). I've been looking around in WPI LIB and stuff trying to find where the classes are so I can reference them properly, but to know avail. Anyone got any working code that they'd be happy to show me? Or at least tell me where the classes are?

ColorImage *image;

MonoImage *luminancePlane = image->getLuminancePlane();
vector<EllipseMatch> *results = luminancePlane->DetectEllipses(&ellipseDescriptor, &curveOptions, NULL, NULL);
printf("Found %d ellipses\n", results->size());
delete luminancePlane;

TheDominis
18-01-2010, 23:22
The header files are under WPILib/Vision

You should be able to import them without adding an include directory. If not, right-click your project, select properties, and then one of the build options will have a tab about includes (I'm at home and lack the dev tools) add the path:


-I$(WIND_BASE)/target/h/WPIlib/Vision

Teh1337Bix
18-01-2010, 23:57
I don't follow. My WPI LIB must be a different version or something because it isn't set up like that. It doesn't have a WPILib/Vision folder. Could you send me a link to the latest version?

Alan Anderson
19-01-2010, 01:33
I don't follow. My WPI LIB must be a different version or something because it isn't set up like that. It doesn't have a WPILib/Vision folder. Could you send me a link to the latest version?

http://www.usfirst.org/frccontrolsystem includes a section of required Software updates. You probably want http://first.wpi.edu/FRC/frcupdates.html specifically.

Teh1337Bix
19-01-2010, 02:00
Great! I had the wrong version. Now I'm just wondering how in WindRiver it knows which folder to go to to import WPI LIB when you write #include <WPIlib> or whatever that is.

EDIT: The script to update the WPI lib that wind river uses is broken. It does everything in a folder called WorkbenchUpdate which doesn't exist YET my WPI LIB is working fine.

EDIT: After manually updating EVERYTHING (I took a while) I'm pretty sure to access vision classes I need to include a different .h file. Anyone know what it is?

TheDominis
19-01-2010, 09:05
The update tool is only slightly "broken" if you install Windriver somewhere other than c:/windriver. Cut and paste fixes this.

Your c:/windriver/vxworks-6.3/target/h/WPIlib should have a "Vision" directory as well as a "Vision2009" directory (and some other miscellaneous directories).

You must tell the project to use the "Vision" directory as an addition source of includes.


Right-Click Your Project's Name ->
Properties ->
On the Left, Click "Build Properties" ->
Select the tab "Build Paths" ->
Click "Add" use the path: "-I$(WIND_BASE)/target/h/WPIlib/vision"
Click "OK"


"AxisCamera2010.h" or "PCVideoServer.h" will get you started.

Take a look at the manual:
http://first.wpi.edu/Images/CMS/First/WPI_Robotics_Library_Users_Guide.pdf

Teh1337Bix
19-01-2010, 22:20
Yeah I did all that stuff before you posted it. What I'm asking is do I have to include all the .h files myself or can I just include one which would include them all. All this stuff would be soooooooooooooooooooooooooooooooooooo much easier if we could use C#.

TheDominis
19-01-2010, 22:31
Yeah I did all that stuff before you posted it. What I'm asking is do I have to include all the .h files myself or can I just include one which would include them all. All this stuff would be soooooooooooooooooooooooooooooooooooo much easier if we could use C#.

Yes. C#. Invest in a .NET VM to run on VxWorks PPC

Also AxisCamera2010.h would be what you want. You have to explicitly import image types ColorImage, HSLImage, etc.

Teh1337Bix
19-01-2010, 22:33
Yes. C#. Invest in a .NET VM to run on VxWorks PPC

Also AxisCamera2010.h would be what you want. You have to explicitly import image types ColorImage, HSLImage, etc.

Oh yay! Now I can start doing my work instead of spending most of the time with my team on facebook.

Teh1337Bix
20-01-2010, 00:14
Ok everything is awesome cool BUT the documentation tells me that I need give it "curve options".

luminancePlane->DetectEllipses(&ellipseDescriptor, &curveOptions, NULL, NULL);

The Vision Assistant helped me choose what I should set the values to in the EllipseDescriptor struct because it shows what settings it uses but it doesn't tell me what settings it use for CurveOptions and as a result, I can't make a CurveOptions struct and therefore I can't use ellipse detection.

Greg McKaskle
20-01-2010, 08:14
Perhaps you can look at the sample code, the code in WPILib, or the documentation to fill in that struct.

Greg McKaskle

Teh1337Bix
20-01-2010, 21:51
What sample code where?!?! I have the documentation but it doesn't have what's in the struct written down.

Greg McKaskle
21-01-2010, 09:20
All languages come with 2010 specific sample code. I'm sure a search of CD would give you the exact path. The documentation could include things like the NI Vision header file, or perhaps the NI Vision manuals. The Start menu>>National Instruments>>Vision>>Manuals, or a similar menu will contain in depth documentation for each language and even some conceptual stuff.

Greg McKaskle

byteit101
21-01-2010, 11:34
from 2010ImageDemo:
// These parameters set ellipse finding in the NI imaq (Image Aquisition) library.
// Refer to the CVI Function Reference PDF document installed with LabVIEW for
// additional information.
static EllipseDescriptor ellipseDescriptor = {
3, // minMajorRadius
200, // maxMajorRadius
3, // minMinorRadius
100 // maxMinorRadius
};

static CurveOptions curveOptions = { IMAQ_NORMAL_IMAGE, // extractionMode
40, // threshold
IMAQ_NORMAL, // filterSize
25, // minLength
15, // rowStepSize
15, // columnStepSize
10, // maxEndPointGap
1, // onlyClosed
0 // subpixelAccuracy
};
static ShapeDetectionOptions shapeOptions = {
IMAQ_GEOMETRIC_MATCH_SHIFT_INVARIANT, // mode
NULL, // angle ranges
0, // num angle ranges
0, // scale range
500 // minMatchScore
};

Teh1337Bix
21-01-2010, 19:52
Oh thanks, I'll try this when I meet up with my team later today.