Issues when connecting a new camera

I used for a few time the following setup:

  1. DH-MV-A7500MG20E camera
  2. Raspberry Pi 4 with Ubuntu 20.04

Now I’d like to switch to a new camera (DH-MV-A5501MG20E), but when I connect it, I have this exception {C-API call failed} ({LoadImageFile}).

I tried these two setups (the connected camera, the PC and the Raspberry are always in the same subnet):

  1. Direct connection with the Raspberry using its ethernet port.
  2. Connection through a network switch: in this case I’m able to see and use the camera from my Windows 10 PC (using the GenICam Browser), but not from my Raspberry, even if I can ping it.

What do you thing I’m doing wrong? Do I have to reset some settings before connecting the new camera?

This is the code I’m using:

from config import *
import cv2
import cvb
import time
import numpy as np
import sys


if __name__ == '__main__':

    while True:
        try:
            with cvb.DeviceFactory.open(cvb.install_path() + "/drivers/GenICam.vin") as vin_device:

                dev_node_map = vin_device.node_maps["Device"]
                dev_node_map['Std::Width'].value = CAMERA_WIDTH
                dev_node_map['Std::Height'].value = CAMERA_HEIGHT
                exposure_node = dev_node_map["ExposureTime"]
                exposure_node.value = CAMERA_EXPOSURE
                stream = vin_device.stream
                
                while True:
                    trigger = input('Press o to acquire: ')
                    if trigger == 'o':
                        trigger = ''

                        image, status = stream.get_snapshot()
                        np_image = cvb.as_array(image, copy=False)
                        cv2.imwrite('image' + '.png', np_image)
                    else: time.sleep(0.01)

        except Exception as e:
            print(e)
            time.sleep(2)

Hi @pare,
have you followed the instructions in https://help.commonvisionblox.com/GenICam-User-Guide/html_english_genicam_inifile_english.htm with generating a configuration file (GeniCam.ini)? It seems, that this one is missing.
Regards,
Bea

Thank you for your reply, is it possible to configure it on Ubuntu without using the GUI?

Today I made some tests with this setup:

  • Raspberry Pi with Raspberry OS (works better than Ubuntu): desktop version so that I could configure my device (and save all the settings) through the GUI (I saved the configuration for both the cameras using the GenICamBrowser)
  • Dahua camera A5501MG20E
  • Dahua camera A7500MG20E

After few fixes I was able to make CVB run on the RPi and I could see and configure both my cameras. Then I installed the Python libraries and I was able to run my test script:

import cvb
from config import *
import cv2
import time
import numpy as np
import sys

if __name__ == '__main__':

    try:
        with cvb.DeviceFactory.open(cvb.install_path() + "/drivers/GenICam.vin") as vin_device:

            dev_node_map = vin_device.node_maps["Device"]
            dev_node_map['Std::Width'].value = 2592
            dev_node_map['Std::Height'].value = 2048
            exposure_node = dev_node_map["ExposureTime"]
            exposure_node.value = CAMERA_EXPOSURE
            stream = vin_device.stream
            
            if True:
                trigger = input('Press o to acquire: ')
                if trigger == 'o':
                    trigger = ''

                    image, status = stream.get_snapshot()
                    image.save('image' + '.png')
                    np_image = cvb.as_array(image, copy=False)
                    cv2.imwrite('image_np' + '.png', np_image)
                else:
                    time.sleep(0.01)

    except Exception as e:
        print(e)

When I run the script I left opened the GenICamBrowes window and I could access the camera, but after closing that window, I was not able to reopen it and now if I try to open it through the terminal, I receive this error:

* failed to add service - already in use?
==============================
  CVB Leaked Handles Summary
==============================
  @0xb2626860
  @0xb261d638
  @0xb261d4a0
   ...
  @0xb26105a0
  @0xb26091c8
  :> 53 CVB handles.

And now also the other camera gives back the {C-API call failed} ({LoadImageFile}) error.

What could have caused this issue?

I think you are opening the camera multiple times simultaneously. When your script is running, the GenICam.vin is loaded all the time ( with cvb.DeviceFactory.open(cvb.install_path() + "/drivers/GenICam.vin") as vin_device:). When you access the camera using the GenICam Browser, it fails loading the same driver.

I’m sorry, I forgot to specify that the problem remains even after rebooting the Raspberry Pi and without running the Python script; if I try to run the GenICamBrowser I still have the * failed to add service error. I also checked the running processes and there are no Python processes running.

So you cannot open the GenICam Browser at all? Or does it open and you see the camera but cannot open the camera?
Could you please open the LogGui and set

  • View --> Configuration (tick)
  • Configuration --> default --> debug
  • Save settings
  • Start logging
  • Open the GenICam Browser
  • After it crashes, stop logging, save the log as .json and attach it here or send it to the de.support@stemmer-imaging.com, ideally referencing this post.

We will then check why you get the error and get back to you.

In the meantime, you can also disconnect the cameras, reconnect them and open the %CVBDATA%Drivers\GenICam.ini, remove all but

;utf8
[SYSTEM]
CreateAutoIni=1```

and open the %CVB%Drivers\GenICam.vin with the Common Vision Blox Viewer (or a simple example code). The camera should be found (if in the correct net) and opened.