[testXJIG QR 코드 인식 고도화 #2-2] uEye XC(U3-36L0XC) 카메라 환경 구축

2023. 7. 13. 20:41프로젝트 로그/테스트x솔루션 JIG 개발기

반응형

U3-36L0XC를 사용하기 위한 드라이버와 Python 코드와 연동해서 사용하기 위한 Python Biniding 설치 방법을 설명 한다.

 

Windows와 Linux-PC, Linux-Embedded 보드에서 각각 설정 가능 하도록 Windows 버전과 Linux 버전 설치 방법을 설명한다.

U3-36L0XC 드라이버 및 툴 다운로드

아래 다운로드 링크에서 IDS peak 소프트웨어를 다운로드 한다. IDS peak 소프트웨어는 U3-36L0XC의 설정 및 카메라 영상을 확인 할 수 있는 IDS 소프트웨어 이며, 해당 소프트웨어를 설치 하면 Python Binding까지 포함하고 있다.

IDS peak 설치 및 Python 모듈 설치

windows 환경 

Python Binding 위치 및 설치 명령

  • generic_sdk api
    • Path : C:\Program Files\IDS\ids_peak\generic_sdk\api\binding
    • pip 명령 ( Python 3.9버전 기준 ) : pip install "C:\Program Files\IDS\ids_peak\generic_sdk\api\binding\python\wheel\x86_64\ids_peak-1.6.0.0-cp39-cp39-win_amd64.whl"
  • IDS peak IPL(Image Processing Library)
    • Path : C:\Program Files\IDS\ids_peak\generic_sdk\ipl\binding\python\wheel\x86_64
    • pip 명령 (Python 3.9버전 기준 ) : pip install "C:\Program Files\IDS\ids_peak\generic_sdk\ipl\binding\python\wheel\x86_64\ids_peak_ipl-1.7.0.0-cp39-cp39-win_amd64.whl"
  • IDS peak AFL(Auto Features for IDS cameras)
    • Path : C:\Program Files\IDS\ids_peak\generic_sdk\afl\binding\python\wheel\x86_64
    • pip 명령 (Python 3.9버전 기준) : pip install "C:\Program Files\IDS\ids_peak\generic_sdk\afl\binding\python\wheel\x86_64\ids_peak_afl-1.1.0.0-cp39-cp39-win_amd64.whl"
  • IDS_PEAK_GENRIC_SDK_PATH 지정 필요

 

 

Linux 환경

IDS Peak S/W 설치

$ sudo apt-get install ./ids-peak-linux-armhf-2.4.0.0.deb

Python Binding 설치 ( python 3.9 버전 기준 )

/usr/local/share/ids/bindings/python/wheel 폴더에 가면 python 버전 별로 ids_peak, ids_peak_ipl, ids_peak_afl를 설치 하기 위한 whl 파일이 존재 하므로, 설치된 python 버전에 맞는 파일을 인스톨 하면 된다.

$ pip install /usr/local/share/ids/bindings/python/wheel/ids_peak-1.6.0.0-cp39-cp39-linux_armv7l.whl
$ pip install /usr/local/share/ids/bindings/python/wheel/ids_peak_ipl-1.7.0.0-cp39-cp39-linux_armv7l.whl
$ pip install /usr/local/share/ids/bindings/python/wheel/ids_peak_afl-1.1.0.0-cp39-cp39-linux_armv7l.whl

 

 

테스트

Library 초기화 및 테스트

from ids_peak import ids_peak
from ids_peak_ipl import ids_peak_ipl
from ids_peak import ids_peak_ipl_extension

ids_peak.Library.Initialize()

Sample Full Code

from ids_peak import ids_peak

def main():
    ids_peak.Library.Initialize()

    device_manager = ids_peak.DeviceManager.Instance()

    try:
        device_manager.Update()

        if device_manager.Devices().empty():
            print("No device found. Exiting Program.")
            return

        for i, device in enumerate(device_manager.Devices()):
            print(str(i) + ": " + device.ModelName() + " ("
                + device.ParentInterface().DisplayName() + "; "
                + device.ParentInterface().ParentSystem().DisplayName() + "v."
                + device.ParentInterface().ParentSystem().Version() + ")")
        

        # select a device to open
        selected_device = None
        while True:
            try:
                selected_device = int(input("Select device to open: "))
                if selected_device in range(len(device_manager.Devices())):
                    break
                else:
                    print("Invalid ID.")
            except ValueError:
                print("Please enter a correct id.")
                continue


        # # Open the first openable device in the managers device list
        # for device in device_manager.Devices():
        #     if device.IsOpenable():
        #         device = device.OpenDevice(ids_peak.DeviceAccessType_Control)
        #         break
        # open selected device
        device = device_manager.Devices()[selected_device].OpenDevice(ids_peak.DeviceAccessType_Control)

        # get the remote device node map
        nodemap_remote_device = device.RemoteDevice().NodeMaps()[0]

        # print model name and user ID
        print("Model Name: " + nodemap_remote_device.FindNode("DeviceModelName").Value())
        try:
            print("User ID: " + nodemap_remote_device.FindNode("DeviceUserID").Value())
        except ids_peak.Exception:
            print("User ID: (unknown)")

        # print sensor information, not knowing if device has the node "SensorName"
        try:
            print("Sensor Name: " + nodemap_remote_device.FindNode("SensorName").Value())
        except ids_peak.Exception:
            print("Sensor Name: " + "(unknown)")

        # print resolution
        try:
            print("Max. resolution (w x h): "
                  + str(nodemap_remote_device.FindNode("WidthMax").Value()) + " x "
                  + str(nodemap_remote_device.FindNode("HeightMax").Value()))
        except ids_peak.Exception:
            print("Max. resolution (w x h): (unknown)")

    except Exception as e:
        print("Exception: " + str(e) + "")

    finally:
        input("Press Enter to continue...")
        ids_peak.Library.Close()


if __name__ == '__main__':
    main()

실행 결과

아래 내용과 같이 카메라 정보들이 출력되면, python에서 IDS 카메라를 연결해서 사용 가능 하다.

(testx_64) D:\Workspace\testxStdJig_V2>python unitTest\Camera\qrCamera.py
0: U3-36LxXC-C (IDS USB3 Vision; IDS GenICam Producer (U3VK)v.1.11.0.0)
Select device to open: 0
Model Name: U3-36LxXC-C
User ID:
Sensor Name: onsemi AR1335
Max. resolution (w x h): 4200 x 3120
Press Enter to continue...
반응형