Closed thomaseude3 closed 12 months ago
Hi Thomas,
let me try a pseudo code to see if I understand your problem correctly:
enumerate and open camera
call "update_video"
while user dont click okay:
detach and destroy cam,
enumerate and open camera
call "update_video"
Is there a reason why you need to close the camera between shots? And if so, it might be easier to close the camera right after capturing the image to be sure the camera is closed. Also, you have chosen a very hard method to close the camera. It should be enough to just call camera.Close() instead of detaching and destroying the object, and just call "Camera.Open" if you want the camera back opened.
Hi ! thanks for your response, finally, I did for the live video stream :
'if self.camera.IsOpen():
grab = self.camera.RetrieveResult(1000, pylon.TimeoutHandling_ThrowException)`
and
else: self.camera = pylon.InstantCamera() self.camera.Attach(pylon.TlFactory.GetInstance().CreateFirstDevice()) self.camera.Open() self.camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) grab = self.camera.RetrieveResult(1000, pylon.TimeoutHandling_ThrowException)
As the camera was already opened in each case, I could take the pictures with the function :
grab = self.camera.RetrieveResult(1000, pylon.TimeoutHandling_ThrowException) image_folder = "acquisition_image" if grab.GrabSucceeded(): ..........
Thank you my problem is resolved !
Hello !
I am currently working on an application with PyQt6, using a Basler acA2500-14gc camera. I have built a framework that displays the live video stream from the camera on a PyQt6 window, and I have also successfully implemented buttons to capture images from this video stream with the following functions:
To open the camera:
To take a photo:
grab = self.camera.RetrieveResult(1000, pylon.TimeoutHandling_ThrowException)
I do this for two different buttons, and then display these two photos on a new PyQt6 window. In this new window, I want to ask the user if the images are satisfactory, so they have two options (yes and no). The "yes" option will process the image with OpenCV image processing functions, and the "no" option should return to the initial window to capture a new image. Here is where my problem arises because it tells me that the camera is already in use:
However, I have connected the "no" option to the following lines to make sure to close the camera and reopen it later:
This function is supposed to close and then reopen the camera to resume the live video stream in the first window. However, I still get the error message, even though my live video code is as follows:
Could you help me with this issue? Thanks to everyone!