
larschrjensen

Has any one had success with setting up a camera stream and saving a snapshot to a file using c++?
This is what I have so far:Code:
EZ_B::EZB ^ezb;
ezb = gcnew EZ_B::EZB("MyEZB");
EZ_B::Camera ^ezbCam;
ezbCam = gcnew EZ_B::Camera(ezb);
ezbCam->StartCamera(EZ_B::Camera::GetVideoCaptureDevices()[1], 320, 240);
ezbCam->SaveImageAsJPEG("c:\test.jpg");
I can confirm that the camera is on by running:Code:
BOOL camOK = ezbCam->Camera::IsActive;
cout << "Camera on? " << camOK << "\n";
What am I missing here?
Best,
Lars
'test.jpg alone would try to save an image to the current default directory, whatever that may be at any time. Who knows, there may be one there. Unlike, c:\test.jpg which would try to place an image in the root directory of the C-drive, c:test.jpg will try to put one in whatever directory is currently active on the C-drive. The whole idea is to not have a slash of any kind in the path to eliminate the possibility of the slash causing an inadvertent escape to be generated. The image could even be in the directory where your ARC files are.
Basically, what I'm saying is that there may be a test.jpg image on your computer, just that it may not be in the root directory of the C-drive. Thereby leading you to conclude the image has not been stored.
Are you using VS to compile & run the code or using cmake to compile and run the program in the command prompt ?
1) EZB relies on windows libraries, one of them is the System.Drawing, if not in your dll references, please add.
2) If is still not working, check the current bitmap and try to save:
c# code, convert to equivalent c++/cli:
Code:
let me know if you got success with any of the steps.
Get it from this property...
Code:
@Sures: This is the output from GetLastErrorMsg:
Code:
Using this source:
Code:
So I tried this:
Code:
which compiles fine, but gives an unhandles exception and complains that object reference is not set to instance of an object at:
Code:
Thus, more or less the same error I get when running SaveAsJPEG.
Code:
which I just find plain odd. And no, still no jpg file saved to disc.
If you are u using the ez-robot camera, maybe the mono.dll would be a better fit for a console app because it doesn't have form dependencies
Code:
rather than using an absolute path I get this error:
Code:
which I find a bit odd since the string evidently is not empty.
Regarding the last post "System.ArgumentException: Path cannot be the empty string or all whitespace."
is correct, i'm familiar with that message...
guessing... the ezb code obtains the path from the file you specified, and then calls the CreateDirectory with an empty path generating the error/exception you got.
To help brainstorm the problem:
1) Describe the Camera device in use.
2) To isolate if the issue: sdk related, form vs console application or cmake/compiler options:
2.1 ) isolate EZ code in a console application, compile, run, debug with Visual Studio,
2.2) if 2.1 still does not work, create a Form application with the same code.
Try the mono.dll - i think you will have better luck because it has less overhead
I have for the time being given up using the camera in the current context.
Unfortunately, C# and mono is incompatible with other components in the project. I am working with a group of roboticists on adapting a gaze spotter to be used with a JD-bot. The spotter is originally developed for the iCub robot, but has been adapted to other platforms as well. We should have a working system within a few days, I'll throw up a video once it does