I have JAI-FS-3200D camera (GigE version) and I want to save images from the camera using CVB.
I am using the following code:
2 #
3 # 1. Open the GenICam.vin driver.
4 # 2. Acquire images.
5 #
6 # Requires: -
7
8 import os
9 import cvb
10
11 with cvb.DeviceFactory.open(
12 os.path.join(cvb.install_path(), "drivers", "CVMock.vin"),
13 cvb.AcquisitionStack.Vin) as device:
14
15 stream = device.stream()
16 stream.start()
17
18 for i in range(10):
19 image, status = stream.wait()
20 if status == cvb.WaitStatus.Ok:
21 print("Acquired image: " + str(i) + " | Timestamp: " + str(image.raw_timestamp))
22
23 stream.abort()```
But I cannot able to capture the images.
Can you please advise me how can I save or read the images using CVB with JAI-FS-3200D camera?
Thanks in advance.
Your posted code in itself should be working. If not please check your installation and post your error.
To use the actual camera, not the mock camera, either configure the camera in the GCBrowser by adding the device to the right side and saving the file. Then change the CVMock.vin to GenICam.vin and the camera should load.
Or you can discover the device and open it directly (see e.g. %CVB%Tutorial\Image Manager\CVBpy\DiscoverDevices\discover_devices.py). By discovering you search for all available devices on the network or USB bus. You can then search each access_token in the discovery list (of found devices) for a phrase, most useful would be the name of the device, and open the device by access_token.
import os
import cvb
with cvb.DeviceFactory.open(
os.path.join(cvb.install_path(), "drivers", "CVMock.vin"),
#os.path.join(cvb.install_path(), "drivers", "GenIcam.vin"),
cvb.AcquisitionStack.Vin) as device:
stream = device.stream()
stream.start()
for i in range(10):
image, status = stream.wait()
if status == cvb.WaitStatus.Ok:
#print("Acquired image: " + str(i) + " | Timestamp: " + str(image.raw_timestamp))
#src_image = cvb.Image(os.path.join(cvb.install_path(), "tutorial", "Clara.bmp"))
#print("Loaded image size: " + str(src_image.width) + " x " + str(src_image.height))
dst_image = image.map(image.bounds, cvb.Size2D(image.size.width * 2, image.size.height * 3))
print("Mapped image size: " + str(dst_image.width) + " x " + str(dst_image.height))
dst_image.save("test.png")
stream.abort()
The installation is ok.
When I use CVMock.vin it prints
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
Mapped image size: 1280 x 1440
But the image is not saved. However, when I changed CVMock.vin to GenICam.vin it gives the following error.
Traceback (most recent call last):
File "test.py", line 4, in <module>
with cvb.DeviceFactory.open(
RuntimeError: C-API call failed
You just need the image.save(“ImAgE.bmp”) call on the image you waited for. The rest from the image load and save tutorial emulates the camera by loading the image which you would normally get by sream.wait().
The GenICam.vin loads the device configured in the %CVBDATA%Drivers\GenICam.ini file. You can configure it using the GenICamBrowser:
I want to run a script and save image. Now I can save 1 image with the below code:
# CVBpy Example Script
#
# 1. Discover all devices.
# 2. Load the first device found.
# 3. Acquire images.
#
import cvb
discover = cvb.DeviceFactory.discover_from_root()
mock_info = next((info for info in discover if "GenICam.vin" in info.access_token), None)
if mock_info is None:
raise RuntimeError("unable to find GenICam.vin")
with cvb.DeviceFactory.open(
mock_info.access_token, cvb.AcquisitionStack.Vin) as device:
stream = device.stream()
stream.start()
for i in range(10):
image, status = stream.wait(5000)
#if status == cvb.WaitStatus.Ok:
#print("Acquired image: " + str(i))
dst_image = image.map(image.bounds, cvb.Size2D(image.size.width * 2, image.size.height * 3))
print("Mapped image size: " + str(dst_image.width) + " x " + str(dst_image.height))
dst_image.save("test.png")
stream.abort()
But another problem is coming. We have 2 streams in our camera. One is RGB and another one is IR. The code can save one image from IR stream. How can I get two stream together?