Rotating camera images breaks Snapshot-Method

Greetings,

I’ve been using the stream.get_snapshot() method to acquire single images. This works fine until the camera image rotation is set to 90° or 270° in the driver via the CVB Management Console. Setting it to 180° works also without a problem.
The error created is “{C-API call failed} ({CreateImageFromPointer})”.

Manually calling stream.start(), stream.wait(), stream.stop(), which from my understanding is what stream.get_snapshot() is doing in the background, works and doesn’t create the error.

Regards,
Jens

Hi @j.wilhelm

which CVB version did you use for that?

I tested on 13.4.0 with a GevServer and Snap works with RotateImage by 90° without any problems.
Maybe you could test this as well.
To get a GevServer just go to

%cvb%\Tutorial\GEVServer\CSharp\CSGEVServer\bin\Release>
and start the exe.
Set the drivertype to “Socket” and start the server.
Now you can search for this GevServer as if it was a camera connected to your system, add it to the configured devices, select the rotate image you want and click the snap button.

Cheers
Chris

I’ve tried in 13.04.002 and 13.04.005, both produce the same error.

Since this is posted in the PythonAPI section it would be more helpful if you check the error with the Python API and not C#.

Hi @j.wilhelm

I did not check this with C#, I just used the C# GevServer example to simulate a camera.
The part on the “Code” side is what the ManagementConsole or GenICam Browser (whatever you prefer) does.
This is a way of checking, whether or not this error happens with onboard CVB tools as well.
As I cannot reproduce you error with CVB tools out of the box it would be great if you could be so kind and check what happens if you do the same on your machine.

Cheers
Chris

The error happens in Python, your CVB tools are not written in Python, but in C#, so the error can’t be tested there.
I did what you asked for and of course there is no problem with rotating the image and using the snap button in the Management Console. But there also wasn’t a problem with the regular cameras and the snap button in the Management Console.

Please test the get_snapshot() method in python with a rotated camera image.

Hi @j.wilhelm
I did not have the information, that the error does not occur in the management console until now.

I will test the behaviour in Python and come back at you as soon as I have any news.

Hi @j.wilhelm ,

we are seeing the issue with the get_sapshot and the rotated image as well.
The problem is reported as a bug and will be fixed.

For now we need a workaround for you.
First up, I question, if you really need to go with the get_snapshot method.
This is usually not the best approach and having a running stream if you are about to wait for images should always be preferred.

In your case, starting the stream and having it run until you dont need it anymore might be the better approach.
To get an image you simple use the cameras nodemap, set the triggermode to software triggerer once on initialization and then execute a softwaretrigger via the NodeMap everytime you actually need an image (and then get it with wait()).

This should be only little changes in your code but keep your acquisition stable and also fix your problem with the roated images.

Example:

import os 
import cvb    

#Tested With Dalsa Genie Nano, names of Nodes may be different on other devices  
# Load driver  
device = cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"), port=0)    

#Load NodeMap for the device  
dev_node_map = device.node_maps["Device"]     

#First set the TriggerMode  
triggerModeNode = dev_node_map["TriggerMode"]  
triggerModeNode.value = "On"     

#Then choose TriggerSource (not available if TriggerMode not set)  
triggerSourceNode = dev_node_map["TriggerSource"]  
triggerSourceNode.value = "Software"     

# Get the commandnode to execute a trigger later
softwareTrigger = dev_node_map["TriggerSoftware"]  

# Start stream to be able to get an image 
device.stream().start()   
for i in range(0, 10): 
   #Then execute a SoftwareTrigger  
   softwareTrigger.execute()     

   #Now wait for the image and process it... 
   image = device.stream().wait().

device.stream().abort()

Cheers
Chris

What’s the reason for setting a software trigger and executing it instead of setting no trigger and calling just device.stream().wait()?

I dont get your point here.
You cant call wait() without the stream running.
Obviously you dont want to take care of all images but only the images at a given moment.

So having the camera in freerun would fill up your buffer leaving you with old images if you call wait() sporadically.

Using the GetSnapshot is not ideal as aready discussed.

Starting the stream but manually taking care of when a image is actually written into the buffer to receive it with wait() is what I suggested to you (Softwaretrigger).

As I dont know what you actually want to do and what your demands are, I can only try to guess what you might have tried to do and lead you into the right direction of how this is usually done.

So if you need hints for how to do certain things with CVB let me know what exactly you want to do and we will find a way. In any case, feel free to exeperiment with diffent ways of acquisiton and ask back, if you would have expected a different outcome.

Cheers
Chris