I'm using python 3.4 with a raspberry pi camera connected through csi port on a Pi3.
I'm trying to write a program which should control the PiCamera settings through a webpage with Flask. I'm trying to update the vflip
and hflip
settings (toggling from False to True and back again).
The code seems to work from the initial switch from False to True. I get the updated image stream with the flipped orientation. But when I try to update the settings more than once, if doesn't seem to work.
I have a camera thread which gets updated with the new values:
def set_vflip(self, value):
if self.camera is not None:
print("updated to " + value)
self.camera.vflip = value
So my output is:
updated to True
(image is also actually flipped as excepted)
updated to False
(command doesn't seem to work anymore)
According to http://picamera.readthedocs.io/en/release-1.10/api_camera.html#picamera.camera.PiCamera.hflip I should be able to call this method while the image capture is running. But I cannot disable it from True
to False
. This problem is on hflip
and vflip
property of the PiCamera
object.
When I run the code manually in a python interpreter shell it seems to works:
from picamera import PiCamera
cam = PiCamera()
cam.vflip
False
cam.vflip = True
cam.vlip
True
cam.vflip = False
cam.vflip
False
but running the same code inside a thread with some helper functions doesn't seem to have the same effect. I call set_vflip
function from above first with True, and after some time with False, but it doesn't flip back.
Is this option not working properly with multithreaded environments? Or what could possibly cause this behaviour?
I also modified my code and added a queue for changing the vflip values, so that only the thread changes this setting which also created the PiCamera instance. But this doesn't seem to have any effect either.
Any input on how to fix this behaviour highly appreciated.