can you provide some more code to reproduce the error?
Please note that this usually happen when accessing already closed device resources.
E.g:
import cvb
with cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "Tutorial", "ClassicSwitch.emu")) as dev:
# dev and all dependent resources like stream and ring buffer will only be available inside the with statement
device = dev
# no error
device.stream.start()
device.stream.stop()
# this will produce the above error
device.stream.start()
class Cameracontrol():
"""
The :class: Cameracontrol contains many functions to set up a camera in the genicam-standard via CVBpy.
The functions can be divided into the following classes:
1. setters for all used and useful nodes
2. "useful" functions like starting/stopping Aquisition or acquiring images
Before using this class u need to set the Ip-adress of your camera manually
"""
def __init__(self):
self.device = None
def _discover(self):
"""
Thos Function discovers all devices which are connected to the computer and returns
a list with all of them in it.
:return: a list with all devices. You may print() it to see details about the camera like ip-adress or model
"""
return cvb.DeviceFactory.discover_from_root(flags=cvb.DiscoverFlags.FindAll, time_span=300)
def connect(self, ip: str):
"""
This function discovers all devices and connects to the the device with the given ip as a String
:param ip: String of the ip-adress
:return: The connected device
"""
disco = self._discover()
for i in disco:
if ip in i.access_token:
return cvb.DeviceFactory.open(i.access_token)
def startacquisition(self):
# starts the Aquistion via grabber
self.device.stream.start()
def acquireimage(self):
"""
Starts the stream, sends a softwaretrigger to get an image and save it. After that the acqusition stops
:return:
"""
nodemap = self.device.node_maps["Device"]
triggernode = nodemap["TriggerSoftware"]
self.startacquisition()
for i in range(10):
triggernode.execute()
sleep(1)
image, status = self.device.stream.wait()
print(image)
if (image.buffer_index==2):
print ("hallo")
self.stopacquisition()
With this class im running in my main:#
Camera = Cameracontrol()
Camera.device = Camera.connect('192.168.5.2')
Camera.acquireimage()
stream.start()
for i in range (0,10):
triggersoftware_node.execute()
image, status = stream.wait()
print(image.buffer_index)
if image.buffer_index == 1:
image.save('image%d.png' %(i))
print(image.buffer_index)```
this after connecting to the device works though in a separate program
Thanks for the feedback.
Can you please post some details about the difference between your working soulution and the error message above.
I’m still quite puzzled about what you actually changed?
Hi there
I have a similar problem with a 3d camera:
3D Vendor: LMI
3D Model: Gocator 2420
3D Version: 5.2.18.11
I am using python and Pycharm and the latest CVb software. After setting the number of buffers to 3, or 10 or 100 or 1000 after the last buffer image (if buffer size = 3, at image 4) i get (i have removed a try catch to find the error):
Traceback (most recent call last):
File "C:/Users/User/PycharmProjects/base-valve/base_valve_GUI.py", line 816, in run
np_array3D = cvb.as_array(image3D)
File "C:\Users\User\AppData\Local\conda\conda\envs\base-valve\lib\site-packages\cvb\__init__.py", line 281, in as_array
if not image.plane_data_types_identical:
RuntimeError: failed to extract type - resource might be gone
I am using two cameras (the other one a Jai GO-5000M-PGE, no problem with it at any buffer size).
I have optimized the network card setting as per instructions to maximize performance on both cards. The 3D camera is using the GenTl protocol.
I looked into it and found that there is bug in CVBpy. It is fixed in the current development branch.
If you contact our support I can provide you with a patch.
Please keep in mind that the patch is development version that might contain other/new bugs.
Here is some code that should fail with your version but run with that patch.
import os
import cvb
dev = cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "GenICam.vin"))
#asuming that the vin driver configures 3 buffers by default.
dev.stream.ring_buffer.change_count(5, cvb.DeviceUpdateMode.UpdateDeviceImage)
with dev:
dev.stream.start()
for i in range(10):
print("Image: " + str(i))
image, status = dev.stream.wait(10000)
if status == cvb.WaitStatus.Ok:
print("Buffer: " + str(image.buffer_index))
dev.stream.abort()
print("test over")
@Andreas
I am too working with buffers and I think I can’t achieve the results due to being unable to set the proper buffer count. Could you share the development version of the python library?
the above issue has been fixed. What is your CVB and CVBpy version?
Do you have issues with the above spinet? You might have run int something different.
Oh sorry! I haven’t realized it was 2019. There are still some errors in py doc (I dont think RIngBufferImage has “unlock()”) so I thought its still under development. Or maybe I just don’t quite get how to access the RingBuffer. I have started a separate thread for the issue I am encountering. Thanks for the response!