How to get frame out
I see that Handler() has frame in asynchronous_grab_opencv. But I am not sure how to get it out and pass it on to a different part of the code. Do I need to add another method to Handler() so I can do something like frame.Handler.returnFrame()? or is there a smarter way to get the image frame out?
I am not quite sure what you mean by "get the image frame out". The frame callback function is called by Vimba when a new frame is available and is the place where you would ideally perform your image processing before handing the frame object back to be refilled by requeuing it for the camera. This means that you would then simply pass out the result of your image processing from the frame callback via some thread safe object (e.g. a queue).
If you must to use the image data somewhere else one way to do this would be to copy the image data (for example as a numpy array) into a processing queue from which your code would take it. One example of how you might achieve this can be found in the multithreading_opencv example. Here you have a FrameProducer class, which contains the frame callback function. In this function the received frame is copied and the copy placed in a queue.Queue. By creating a copy of the frame the original frame object can be requeued for the camera to capture more images.
A second class, the FrameConsumer takes the copied frame object from the processing queue and performs whatever analysis you need. In the case of this example the image is simply resized if it is too large and then displayed.
I hope this helps you in finding an approach for your particular problem. If you can give further details of what you want to accomplish I might be able to provide more concrete suggestions on what you could try to get the image data into your processing system.
Are you just looking for a more basic example? Maybe this help:
from vimba import *
import cv2
with Vimba.get_instance () as vimba:
cams = vimba.get_all_cameras ()
with cams [0] as cam:
# Aquire single frame synchronously
frame = cam.get_frame ()
frame.convert_pixel_format(PixelFormat.Bgr8)
cv2.imshow("test", frame.as_opencv_image ())
cv2.waitKey(0)
Edits: Figuring out how to post code.