Open LanXtai opened 1 year ago
Hi, the convert_pixel_format() function returns a new frame object. The original frame object remains unchanged, so it still has the same pixel format that the camera is set to.
Change the code like this and it should work:
from vmbpy import *
import cv2
with VmbSystem.get_instance () as vmb:
cams = vmb.get_all_cameras ()
with cams [0] as cam:
frame = cam.get_frame ()
new_frame = frame.convert_pixel_format(PixelFormat.Bgr8)
print(frame)
cv2.imwrite('frame.jpg', new_frame.as_opencv_image ())
The available Opencv pixel formats are the following (from the source code):
OPENCV_PIXEL_FORMATS = (
PixelFormat.Mono8,
PixelFormat.Bgr8,
PixelFormat.Bgra8,
PixelFormat.Mono16,
PixelFormat.Bgr16,
PixelFormat.Bgra16
)
Thank you very much, it worked well !
Hi ! I work on Windows 10, using python 3, and I ensured my version of opencv-python is up to date. I'm trying the minimal example given in VimbaX documentation to get a simple picture :
However, all I get is the print :
Frame(id=0, status=FrameStatus.Complete, buffer=0x2a7b34cd040)
, then an error :I tried using version 1.0.2 of vmbpy, but when importing the package I got another error, saying the version did not match the expected 1.0.0.
Using
PixelFormat.Bgr8
inframe.convert_pixel
didn't change anything to the situation, and I run out of options. Is there a way to fix this ?