
SaadJareer
Egypt
Asked
— Edited
Kindly I am having an inquiry about how to use the Camera.GetCurrentBitmap to get the current frame that is shown by a camera device on a PictureBox Control in a C# Form?
When I use the C# code to access the current frame from camera stream, to get a captured image, It always give me a NullReferenceException that the Bitmap Object that is returned from Camera.GetCurrentBitmap method call is just not instantiated.
@Saadjareer:
post #1 (3 weeks ago):
https://synthiam.com/Community/Questions/9259
post #2 (1 day ago):
https://synthiam.com/Community/Questions/9321
ensure you have the latest sdk
read the help summary for the method. The bitmap is only available in the event.
@Saadjareer:
post #1 (3 weeks ago)
I've created an Example Project and is publicly available, if you study/spend some time understanding the project you see the following code:
i wait 10 seconds for a frame before saving the picture, when you connect to the camera, the execution is async, there other things going after and when the call returns the camera is not ready.
if you try immediately to get a bitmap or save an image you will get an exception
post #2 (1 day ago)
DJ's wrote:
i was surprised with DJ's comment and if that was the reason to start post #2:
Yeah - the onNewFrame event is when a new frame arrives. There cannot be an image before that event is raised. The point to the event is as the name implies, a new frame exists. So attempting to get the bitmap/image outside of that event does not provide any verification that a frame exists. Does that make sense?
Not sure how else to explain it - the event is raised for every new frame. If you try to read a bitmap image outside of the frame event, there is no way to know if a frame is actually there or not.