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/NextGen/14.0/md_theory_of_operation_hardware__gen_i_cam__c_v_b__user_guide.html#gcug_chmtopic12 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.

I tried to open the LogGui, but it gives me back this error:

QFontDatabase: Cannot find font directory /opt/cvb-13.02.002/qt/lib/fonts.
Note that Qt no longer ships fonts. Deploy some (from https://dejavu-fonts.github.io/ for example) or switch to fontconfig.
* failed to add service - already in use?
Segmentation error

Hi @pare,

this should be fixed in the latest CVB version. So you can either update, or do this: (Jetson Nano) Quick Fix for invisible fonts with GenicamBrowser

Kind regards
Arno

1 Like

Thank you for your answer, this solved the first problem, but I still have:

* failed to add service - already in use?
 Segmentation error

Ubuntu 20.04 is not yet supported. Can you try 18.04?

I installed Ubuntu 18.04 (x64), but when I try to open GenICamBrowser I have the following error:

GenICamBrowser: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libGLESv2.so:cannot open shared object file: No such file or directory

Do you have the libgles2-mesa package installed?

Yes, if I run:

sudo apt-get install libgles2-mesa

It gives back:

Reading package lists... Done
Building dependency tree
Reading state information... Done
libgles2-mesa is already the newest version (20.0.8-0ubuntu1~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

But if I run:

sudo find / -iname libGLESv2.so

It does not find the file.

Can you please also try:
sudo apt-get install libgles2-mesa libsdl2-dev

1 Like

Thank you, I installed the libraries you suggested and now all works fine (I just had to fix the missing fonts as @Arno suggested).

1 Like