genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
501 stars 86 forks source link

HikRobot cti file (MVS) #442

Open abogadi opened 4 months ago

abogadi commented 4 months ago

Describe the Issue Harvesters raises LogicalErrorException when trying to use HikRobot cti file. I would like to understand if this is a Hikrobot driver issue or something that can be resolved in Harvesters. I am keen to help resolve this issue, if further or specific tests are needed please let me know!

To Reproduce Steps to reproduce the behavior: Se sample code below

Sample Code I can show a piece of code that demonstrates the reported phenomenon:

If yes, please provide a sample code:

from harvesters.core import Harvester
import sys
import traceback
import cv2
import time

def main():
    h = Harvester()
    h.add_file("C:\\Program Files (x86)\\Common Files\\MVS\\Runtime\\Win64_x64\\MvProducerGEV.cti") 
    h.update()
    time.sleep(1)
    print(len(h.device_info_list))
    for onedevice in h.device_info_list:
        print(onedevice)
        print('next')
    ia = h.create(0)
    #ia.device.node_map.PixelFormat.value = 'BayerRG8'
    #ia.device.node_map.TestPattern = 'HorizontalColorBar'
    try:
        ia.start()
        i = 0
        done = False
        while not done:
            with ia.fetch() as buffer:
                img = buffer.payload.components[0].data
                img = img.reshape(buffer.payload.components[0].height, buffer.payload.components[0].width,3)
                img_copy = img.copy()
                img_copy = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
                cv2.namedWindow("window", cv2.WINDOW_KEEPRATIO | cv2.WINDOW_NORMAL)
                cv2.imshow("window", img_copy)
                fps = ia.statistics.fps
                print("FPS: ", fps)
                if cv2.waitKey(10) == ord('q'):
                    done = True
                    print('break')
                i = i + 1
    except Exception as e:
        traceback.print_exc(file=sys.stdout)
    finally:
        ia.stop()
        ia.destroy()
        cv2.destroyAllWindows()
        print('finally')
        h.reset()

if __name__ == "__main__":
    main()

If applicable, please paste the actual output (its whole traceback, etc) here:

E:\vis\newvenv310\Scripts\python.exe E:\vis\harvester.py 
Traceback (most recent call last):
  File "E:\vis\harvester.py", line 62, in <module>
    main()
  File "E:\vis\harvester.py", line 24, in main
    h.update()
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 3446, in update
    self._open_systems()
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 3341, in _open_systems
    self._systems.append(System(module=raw_system, parent=producer))
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 515, in __init__
    super().__init__(module=module, parent=parent, port=module.port)
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 281, in __init__
    self._node_map = self._create_node_map(
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 320, in _create_node_map
    clean_up_required, file_path = self._retrieve_file_path(
  File "E:\vis\newvenv310\lib\site-packages\harvesters\core.py", line 378, in _retrieve_file_path
    raise LogicalErrorException(
_genapi.LogicalErrorException: The target port does not hold any URL.

Process finished with exit code 1

Expected Behavior Open camera and acquire images

Screenshots

Configuration

Reproducibility

This phenomenon can be stably reproduced:

If applicable, please provide your observation about the reproducibility.

Actions You Have Taken

Additional context Add any other context about the problem here.

ardainanc commented 4 months ago

Hi. I am having the same issue with MVS and harvesters on Ubuntu x64. Were you able to find a solution? I tried to update MVS and sdk form hikvision website but unfortunately it didnt work.

abogadi commented 4 months ago

No, I am still waiting to hear back from Hikrobot on the same topic

ardainanc commented 4 months ago

Hi again. I found a temporary solution for our case. I used mvGenTL_Acquire as it doesn't block the other producers products. You can find the relevent info here: https://harvesters.readthedocs.io/en/latest/INSTALL.html#installing-a-gentl-producer . This worked with my mv-cs060 gige camera. It would also be great if you can notify me when you here back from Hikrobot on their own .cti file.