Closed shaizae10 closed 1 year ago
somting get rong whit the copy of the data
Hello, please edit the code to show the right format, for Python the formatting shows context, so it is necessary. Try copying the code first, then select the text and then click the <> button. Other than that, please make sure that the camera.get_frame() command is within the with statement of Vimba, like for example so:
def take_single_measurement(self)->np.ndarray:
with Vimba.get_instance():
with self.camera:
frame = self.camera.get_frame()
For reference on how to manage the with statement, you can also look at the code, that Niklas did in this issue: #143 That code is for a different method of acquiring frames, so it is not an example you can use directly, but just to see how to structure the context with the with statement.
def _stream_frames(self):
with vimba.Vimba.get_instance():
with self.camera:
self._stop_streaming_event.clear()
_handler = FrameHandler(self.handler)
self.camera.start_streaming(_handler)
self._stop_streaming_event.wait()
self.camera.stop_streaming()
tenx i'll fix the code :) there is no option to connect to the camera and then just read the buffer? i have no need to live streem
Yes, of course you don't need to stream, you can keep with synchronous acquisition with get_frame()
to get one single image when you need it. Just add the with Vimba.get_instance() ....
part to your code.
The second example from Niklas is only for the structure of the def, not for the actual code. Because the example from Niklas uses asynchronous acquisition/streaming.
I'm not sure what you mean with reading the buffer.
Synchronous acquisition functions like this:
For an easier example, please use synchronous_grab.py to see an implementation of getting frames synchronously (as you are doing right now).
hi thare there is example of my code:
import numpy as np from matplotlib import pyplot as plt
from HW.vimba import Vimba
evry time it is show me the next error RuntimeError: Called 'Camera.get_frame()' outside of 'with' - statement scope. there is any wey that i can take frame any time whit out the need to reconecr to the camera?