Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Capture Photos From Camera Stream

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.

AI Support Bot
Related Content
1) ensure you have the latest sdk

2) read the help summary for the method. The bitmap is only available in the event.

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:


//wait 10 seconds for the first camera frame
if (this.frameEventObject.WaitOne(10000))
this.WriteDebug("Picture done!");

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:


The camera.GetCurrentBitmap() is only available within the CameraOnOnNewFrame() event. Because until CameraOnOnNewFrame() is raised, there are no images to "get".

i was surprised with DJ's comment and if that was the reason to start post #2:


private void CameraOnOnNewFrame()
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.