Stripes on image

Hello,

I’m trying to acquire some images using a DAHUA MV-A7500MG20E camera.
The issue I’m facing is that when I take an image, sometimes it has horizontal stripes (I uploaded an image for reference).
What am I doing wrong?

The code I’m using is this one:

import cv2
import cvb
import numpy as np

# Camera settings
CAMERA_EXPOSURE = 7000
if __name__ == '__main__':
    vin_device = cvb.DeviceFactory.open(cvb.install_path() + "/drivers/GenICam.vin")
    vin_device.stream.ring_buffer.change_count(1, 0)
    dev_node_map = vin_device.node_maps["Device"]
    exposure_node = dev_node_map["ExposureTime"]
    exposure_node.value = CAMERA_EXPOSURE
    stream = vin_device.stream
    stream.start()
    try:
        while True:
            trigger = input('Press o to acquire: ')
            if trigger == 'o':
                trigger = ''
                
                for ii in range(0, 2): # I use this method to empty the ring buffer
                    image, status = stream.wait()
                np_image = cvb.as_array(image, copy=False)
                cv2.imwrite('image_' + str(0) + '.png', np_image)
                if status == cvb.WaitStatus.Ok:
                    print("Acquired image " + " into buffer " + 
                    str(image.buffer_index) + ".")
                else:
                    raise RuntimeError("timeout during wait" 
                        if status == cvb.WaitStatus.Timeout else 
                            "acquisition aborted")
    except KeyboardInterrupt:
        pass
    
    finally:
        stream.try_abort()

Hi @pare,

please have a look at the tutorial StreamingSimple which comes with your full CVB installation. It can be found under %CVB%Tutorial\Image Manager\CVBpy\StreamingSimple.py

We highly recommend to have at least three buffers available for the ringbuffer. You only need to call stream.wait() once every time a new image is needed. If you only need to acquire an image once in a while, you could also use image, status = stream.get_snapshot() but without starting the stream. This will start the stream, aquire one image and stop the stream again.

To save the image, you can just use image.save( 'image_' + str(0) + '.png') which is part of CVB.

Regarding the striped image, please refer to our GEV setup guide for the recommended settings of your network card etc. https://help.commonvisionblox.com/GenICam-User-Guide/html_english_nac_configuration_english.htm
You can also check your camera setup using the GenICam browser which should help tweaking the camera configuration until the image is normal.Saving the configuration there will keep your changes and the camera will produce the same result when loaded in code e.g. using the StreamingSimple.py example.

I hope this helps! :slight_smile:

Best
Nico

Thank you for your reply.

First of all I changed my code to just take one snapshot (I don’t need a continuous data stream).

Then I checked the link you suggested and I tried to setup new values for the MTU. Unfortunately when I try MTU values above 1500, my Rasperry giver back an error.

$ sudo ip link set eth0 mtu 8192
> Error: mtu greater than device maximum.

So I decided to lower the width and height of the image from 2448x2048 to 1748x1748 and now I obtain a better image, without frame loss or stripes.

Just one more thing: how can I change the width and height of the image provided by the device through python code?

Hi @pare,

normally you should be able to send the full image over the network but if changing the resolution works fine for you, you can change the resolution using the device node map:

device_node_map = device.node_maps['Device']
device_node_map['Std::Width'].value = 64

The same goes for the image height (Std::Height).