alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

No Frame Update #140

Closed smitshah-19 closed 1 year ago

smitshah-19 commented 1 year ago

I am new to python and as a project, I have to make a GUI which can be used with Allied Vision Camera in order to capture pictures, store it and adjust some features like exposure, white balance and gain. I have created a small code for fetching frames from the camera but it stays still when I move the camera and not updating the frames. My code:

import cv2 
from vimba import * 
from queue import SimpleQueue 

global is_streaming
is_streaming = True

queue = SimpleQueue

with Vimba.get_instance() as vimba:
    cams = vimba.get_all_cameras()
    with cams[0] as cam:
        while is_streaming:
            cam.set_pixel_format(PixelFormat.BayerRG8)
            frame = cam.get_frame()
            frame = frame.as_numpy_ndarray()
            frame = cv2.cvtColor(frame, cv2.COLOR_BAYER_RG2RGB)

            cv2.imshow('image', frame)
            #queue.put(frame)
            key = cv2.waitKey()
            if key == ord('q'):
                break
        cv2.destroyAllWindows()

Any help is appreciated.