ONVIF snapshot
To get only a JPEG image from an IP camera, instead of starting the camera live stream, a JPEG snapshot can be requested; it is returned as a JPEG file, as a pointer to the JPEG memory buffer, or both.
Sample code to get a JPEG file:
VideoGrabber.VideoSource = vs_IPCamera;
VideoGrabber.OpenURLAsync = true; // so the connection does not block the main thread (it's the default anyway)
VideoGrabber.IPCameraURL = "onvif://192.168.0.25:80"; // if the port is not specified the default port 80 is used
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.ONVIFSnapShot (false, true, "c:\\folder\\snapshot.jpg");
Sample code to access the JPEG snapshot buffer in memory:
VideoGrabber.VideoSource = vs_IPCamera;
VideoGrabber.OpenURLAsync = true; // default, so the connection does not block the main thread
VideoGrabber.IPCameraURL = "onvif://192.168.0.25:80"; // if the port is not specified the default port 80 is used
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.OnRawVideoSample += OnRawVideoSampleCallback;
VideoGrabber.ONVIFSnapShot (true, false, "");
In the OnRawVideoSampleCallback handler of the OnRawVideoSample event, the pSampleBuffer parameter returns a pointer to the JPEG snapshot in memory, whose size is given by SampleBufferSize.
Both the memory callback and the JPEG file can be obtained as follows:
VideoGrabber.ONVIFSnapShot (true, true, "c:\\folder\\snapshot.jpg");