
larschrjensen
Denmark
Asked
— Edited

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:
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:
BOOL camOK = ezbCam->Camera::IsActive;
cout << "Camera on? " << camOK << "\n";
What am I missing here?
Best, Lars
What version of the SDK are you using? I think it's a really old one. I would try updating to a recent SDK package. I recall there being an issue with saving in the SDK quite a few months ago.
Really old, depends on you definition I guess. The SDK i was using was downloaded on January 4th this year. I just downloaded the latest and updated my references. The SaveImageAsJPEG error disappears, but is replaced with this one:
which I just find plain odd. And no, still no jpg file saved to disc.
Hmm - the jan 6th shouldn't have been that bad. That is a very very odd message! It's really strange and wouldn't think that a simple console app would cause so many challenges.
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
Okay, when running :
rather than using an absolute path I get this error:
which I find a bit odd since the string evidently is not empty.
Lars,
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.
Lars,
To help brainstorm the problem:
Describe the Camera device in use.
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.
yeah - the filename must contain a path because it will create the folder if it doesn't exist, as ptp mentioned.
Try the mono.dll - i think you will have better luck because it has less overhead
Ptp and Sures, thank you for all your advice and efforts, I appreciate it. 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