basler / pypylon

The official python wrapper for the pylon Camera Software Suite
http://www.baslerweb.com
BSD 3-Clause "New" or "Revised" License
565 stars 207 forks source link

BUG: Arguments exception when convert numpy to pylon image #790

Open wind0952 opened 1 day ago

wind0952 commented 1 day ago

Describe the issue:

The user want to use vTools and OpenCV together. The workflow as follows.

It got arguments exception when convert numpy to pylon image by pylonimage.AttachUserBuffer. But it seems worked in Unable to Decompress Images in ROS2 using Pylon SDK in Python · Issue #778 · basler/pypylon (github.com Could you check it, please?

Reproduce the code example:

import os
from pypylon import pylon
from pypylon import genicam
import cv2
import sys
# Simulate pre-processing
img = cv2.imread("barcode01.png",-1)

pylonImg = pylon.PylonImage()
# Got arguments exception
pylonImg.AttachUserBuffer(
    img.ctypes.data,
    img.shape[1]*img.shape[0],
    pylon.PixelType_Mono8,
    img.shape[1],
    img.shape[0],
    0,
    pylon.ImageOrientation_TopDown
)

Error message:

Wrong number or type of arguments for overloaded function 'PylonImage_AttachUserBuffer'.
  Possible C/C++ prototypes are:
    Pylon::CPylonImage::AttachUserBuffer(void *,size_t,Pylon::EPixelType,uint32_t,uint32_t,size_t,Pylon::EImageOrientation,CPylonImageUserBufferEventHandler *)
    Pylon::CPylonImage::AttachUserBuffer(void *,size_t,Pylon::EPixelType,uint32_t,uint32_t,size_t,Pylon::EImageOrientation)
    Pylon::CPylonImage::AttachUserBuffer(void *,size_t,Pylon::EPixelType,uint32_t,uint32_t,size_t)

Is your camera operational in Basler pylon viewer on your platform

Yes

Hardware setup & camera model(s) used

Runtime information:

windows 11, pylon 8.0
python: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:17:27) [MSC v.1929 64 bit (AMD64)]
platform: win32/AMD64/11
pypylon: 4.0.0 / 8.0.0.10

windows 10, pylon 7.5
python: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
platform: win32/AMD64/10 
pypylon: 4.0.0 / 8.0.0.10
SMA2016a commented 1 day ago

We need to workaround this issue. I will send you a solution directly