-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete Frames with Raspberry Pi 5 and MER2-160-75GC-P #3
Comments
I used Daheng cameras a long time ago and I'll have to dive back in to see where your problem could be. I'll try to have a look if I have time this afternoon. Also, I'm not the developer of the Python API. Daheng made it and I only copied it and published it on PyPi to simplify installation. So I'm just a former user and not an expert on these cameras. Therefore, I can't guarantee that I'll be of much help. |
Okay, thanks for being willing to take a look! |
To use the Daheng Python API with the Camera # library for daheng camera
import gxipy as gx
class daheng_usb_cam:
"""
usb_cam is a class to give access to an external USB camera
"""
def __init__(self, dev_id):
"""
initialize the device manager
open the communication with the camera
"""
self.device_manager = gx.DeviceManager()
self.dev_num, self.dev_info_list = self.device_manager.update_device_list()
assert self.dev_num!=0,"[start_acquisition] E no camera found."
print(f"[start_acquisition] I number of devices: {self.dev_num}")
for device_index in range(self.dev_num):
print(f"[start_acquisition] I device {device_index+1} : index={self.dev_info_list[device_index]['index']}")
self.cam = self.device_manager.open_device_by_index(self.dev_info_list[dev_id]['index'])
if self.cam.PixelColorFilter.is_implemented()==False :
print("[start_acquisition] I This sample does not support mono camera.")
def config(self,exposure_time_us,gain):
"""
configuration of the camera
"""
self.cam.TriggerMode.set(gx.GxSwitchEntry.OFF)
# set exposure
self.cam.ExposureTime.set(exposure_time_us)
# set gain
self.cam.Gain.set(gain)
self.cam.BalanceWhiteAuto.set(1)
# get param of improving image quality
if self.cam.GammaParam.is_readable():
gamma_value = self.cam.GammaParam.get()
gamma_lut = gx.Utility.get_gamma_lut(gamma_value)
else:
gamma_lut = None
if self.cam.ContrastParam.is_readable():
contrast_value = self.cam.ContrastParam.get()
contrast_lut = gx.Utility.get_contrast_lut(contrast_value)
else:
contrast_lut = None
if self.cam.ColorCorrectionParam.is_readable():
color_correction_param = self.cam.ColorCorrectionParam.get()
else:
color_correction_param = 0
def start(self):
"""
start the camera stream
"""
self.cam.stream_on()
def stop(self):
"""
stop the camera stream
"""
self.cam.stream_off()
def get_image(self):
"""
acquire an image from the camera and return it as a array
"""
self.raw_image = self.cam.data_stream[0].get_image()
if self.raw_image is None:
print("[get_image] E Unable to get an image.")
self.f=0
else:
self.rgb_image = self.raw_image.convert("RGB")
#rgb_image.image_improvement(.cam.color_correction_param, contrast_lut, gamma_lut)
self.f = self.rgb_image.get_numpy_array()
return self.f
def close(self):
"""
close the device
"""
self.cam.close_device() And then, I was using the camera like that: from daheng_cam import daheng_usb_cam
cam=daheng_usb_cam(0)
exposure_time=100000 # [µs]
gain=1
cam.config(exposure_time,gain)
cam.start()
img_rgb=cam.get_image()
cam.stop()
cam.close() It is for a USB camera, but I'm pretty sure it can be the same for an Ethernet camera, just changing the init function of the class, in order to connect to an IP, and not the camera index. |
I'm running on a Raspberry Pi 5, and am connected to Daheng Imaging MER2-160-75GC-P. I am able to connect to the camera, open/close the stream, and get some frame data, but I'm not able to get the image. I get an error when trying to do the following:
That gives me the following output:
RawImage.convert: This is a incomplete image
See below for some details:
I need to deploy this setup for a project this weekend, so any help would be appreciated!
The text was updated successfully, but these errors were encountered: