openUC2 / UC2-Software-GIT

This repository hosts all necessary software for the UC2 project.
https://useetoo.org
Other
12 stars 6 forks source link

Snap to take a photo then Crash #22

Closed BackMountainDevil closed 2 years ago

BackMountainDevil commented 3 years ago

My schoolmates and I have printed and assembled a Incubator_Microscope. And I have installed the raspberry pi 4 GUI app(using script in /3Dimaging/UC2-Software-GIT/GUI/RASPBERRY_PI/RASPIapp_py3). Now it can fully conrol the motor and the LED matrix via the GUI.

motor Z

Click "z" to choose that motor, then change its value by "+ ++ - --". Click the "<<" or ">>" will make it move as you want.

LED matrix

Click "FULL" to trun on all leds. Click "PRE" to trun on the leds you want. Clike "OPT" to set the color of led and else.

puzzle

When I tell them I can control motor and led, I suddenly find out that I have no idea on how to take a photo and how to record. I try all buttons one by one... It seems no one work. Some buttons will break down the app.

beniroquai commented 2 years ago

Hey @BackMountainDevil, congrats on building the microscope! I'm a bit curious, do you have pictures from your setup? :-)

Regarding the software, @renerichter is the expert here; However, I can try to help out. There should be a button "SNAP" that takes a snapshot of the current scene. The data is stored in the folder DATA in the same folder where you find the program file main.py. Videos are not yet enabled, but you could enable that in the Kivy code - needs some programming though. Timelapse imaging series can be created by first setting up the time and then start the acquisition. Does this make sense?

BackMountainDevil commented 2 years ago

It is very nice of you to reply so carefully. I can use "show preview" to show the image. Now from your reply, I know "SNAP" means taking photos. It seems that it will break down. I will make it work.

Thanks for your reply.

beniroquai commented 2 years ago

Can you please make a screenshot of your error message? Or perhaps even copy-paste your terminal output?

BackMountainDevil commented 2 years ago

It is very nice of you guys to reply. And I feel sorry to take a long time to make a log of error message. Cause our school has two campus. Today I went to another campus to have a try.

Error output log

v1

Last line: picamera.exc.PiCameraValueError: Invalid resolution requested: PiResolution(width=3280, height=2464)

Error output v1 ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210917_170331.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit Time on receive=1631869413.6607409----------------------------------scopeInit Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631869413.6607409 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1 Time on receive=1631869413.6724238----------------------------------scopeInit Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631869413.6724238 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1 [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.toolbox ] Got here. [ DEBUG ] [ UC2.toolbox ] Got here. [ DEBUG ] [ UC2.toolbox ] False [ DEBUG ] [ UC2.toolbox ] Preview started [ DEBUG ] [ UC2.toolbox ] Got here. [ DEBUG ] [ UC2.toolbox ] Got here. [ DEBUG ] [ UC2.toolbox ] Preview stopped! [ DEBUG ] [ UC2.io ] Folder: /home/pi/UC2/UC2-GUI/data/20210917/expt_014 created successfully [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeAutofocus.py", line 214, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: fg.camera.resolution = fg.config[camdict]['resolution'] [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/camera.py", line 2271, in _set_resolution [ WARNING ] [ kivy ] stderr: "Invalid resolution requested: %r" % (value,)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Invalid resolution requested: PiResolution(width=3280, height=2464) ```

v2

According to the output(v0), I change the resolution in /config/camera*.yaml to 2592x1944(come from a photo captured by pi with raspistill -o tmp.jpg -t 10)

Error output v2: Very similar to v1 Difference between v1 and v2 is the last line about resolution. `picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 2592x1944` ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210917_172354.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit Time on receive=1631870637.106871----------------------------------scopeInit Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631870637.106871 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1 Time on receive=1631870637.1205437----------------------------------scopeInit Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631870637.1205437 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1 [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: /home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 2592x1944 to 2592x1952 [ WARNING ] [ kivy ] stderr: width, height, fwidth, fheight))) [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/camera.py", line 1423, in capture [ WARNING ] [ kivy ] stderr: 'Timed out waiting for capture to end') [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: During handling of the above exception, another exception occurred: [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeAutofocus.py", line 229, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: toolbox.take_image_atom(rawCapture=rawCapture,rawFormat='rgb',camdict=camdict) [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 786, in take_image_atom [ WARNING ] [ kivy ] stderr: fg.camera.capture(rawCapture, format=rawFormat, use_video_port=use_video_port, bayer=use_bayer) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/camera.py", line 1425, in capture [ WARNING ] [ kivy ] stderr: encoder.close() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 431, in close [ WARNING ] [ kivy ] stderr: self.stop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 419, in stop [ WARNING ] [ kivy ] stderr: self._close_output() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 349, in _close_output [ WARNING ] [ kivy ] stderr: mo.close_stream(output, opened) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/mmalobj.py", line 371, in close_stream [ WARNING ] [ kivy ] stderr: stream.flush() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/array.py", line 238, in flush [ WARNING ] [ kivy ] stderr: self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/array.py", line 127, in bytes_to_rgb [ WARNING ] [ kivy ] stderr: 'Incorrect buffer length for resolution %dx%d' % (width, height)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 2592x1944 ```

v3

Now I change resolution to 640x480( in low-cost camera). Output is the basic the same as v1,v2. Difference is the number of resolution.

Error output v3: Basiclly same ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210917_173202.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit Time on receive=1631871124.767929----------------------------------scopeInit Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631871124.767929 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/LAR01/STAT QOS=0 Retain Flag=1 Time on receive=1631871124.783165----------------------------------scopeInit Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1----------------------------------scopeInit [ INFO ] [ UC2.init ] Time on receive=1631871124.783165 [ INFO ] [ UC2.init ] Received=0 Topic=/S001/MOT01/STAT QOS=0 Retain Flag=1 [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/camera.py", line 1423, in capture [ WARNING ] [ kivy ] stderr: 'Timed out waiting for capture to end') [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: During handling of the above exception, another exception occurred: [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeAutofocus.py", line 229, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: toolbox.take_image_atom(rawCapture=rawCapture,rawFormat='rgb',camdict=camdict) [ WARNING ] [ kivy ] stderr: File "/home/pi/UC2/UC2-GUI/fluidiscopeToolbox.py", line 786, in take_image_atom [ WARNING ] [ kivy ] stderr: fg.camera.capture(rawCapture, format=rawFormat, use_video_port=use_video_port, bayer=use_bayer) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/camera.py", line 1425, in capture [ WARNING ] [ kivy ] stderr: encoder.close() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 431, in close [ WARNING ] [ kivy ] stderr: self.stop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 419, in stop [ WARNING ] [ kivy ] stderr: self._close_output() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/encoders.py", line 349, in _close_output [ WARNING ] [ kivy ] stderr: mo.close_stream(output, opened) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/mmalobj.py", line 371, in close_stream [ WARNING ] [ kivy ] stderr: stream.flush() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/array.py", line 238, in flush [ WARNING ] [ kivy ] stderr: self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2envBERRYCONDA_VERSION=3/lib/python3.6/site-packages/picamera/array.py", line 127, in bytes_to_rgb [ WARNING ] [ kivy ] stderr: 'Incorrect buffer length for resolution %dx%d' % (width, height)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 640x480 ```
BackMountainDevil commented 2 years ago

For some reson, I have reinstall the raspberry pi OS. So this issus may not be reproduce because prepare the environment takes lots of time. But a good news I write a GUI app that can work with your work. When it test work stable in the following weeks, I will put it on Github. Thank you all the time. This is an amazing idea.

beniroquai commented 2 years ago

This error whoever looks familiar. But I don't remember the solution. Looking forward to see your GUI! :-)

renerichter commented 2 years ago

Dear @BackMountainDevil, one possibility that we typically encounter is that the available RAM Ram for GPU-access (of the Pi) is set too small. In the manual we tried to explain a solution to this issue in this section. Would you please be so kind to increase the GPURAM as explained and try again?

BackMountainDevil commented 2 years ago

To be honest, I have make a backup before reinstall pi OS. So I can try to reproduce again in the near future. Yeah, I have found that section. Today I learn basic concept about mqtt topic. I read the git history and find that you made a commit about "add MQTT command-description; add LED + MOTOR commands explanation; add GUI Desktop shortcut explanation; minor dependency fixes for GUI" on 2020-09-21.

In my opinion, the topic structure(/<SETUP>/<DEVICE>/<GENERALCOMMAND>) start with / will make a useless top topic level. If use this structure(<SETUP>/<DEVICE>/<GENERALCOMMAND>), that will cut down a topic named /.

I try to look for explanation about topic start with /. Most text just show examples about topic like home/floor/tempature which not start with /. I can only find one artical explain the reason written in Chinese

不要用 “/” 作为主题开头
MQTT允许使用“/”作为主题的开头,例如/home/sensor/data。但是这将这么做毫无意义,而且会额外产生一个没有用处的主题级别。所以我们应避免使用/作为主题的开头。

It means do not start with /, that will create a useless topic level.

beniroquai commented 2 years ago

Do you think it's worth thinking about switching to Rest API instead? This makes the broker obsolete.

On Tue, Sep 21, 2021, 12:31 Kearney @.***> wrote:

To be honest, I have make a backup before reinstall pi OS. So I can try to reproduce again in the near future. Yeah, I have found that section. Today I learn basic concept about mqtt topic. I read the git history and find that you made a commit about "add MQTT command-description; add LED + MOTOR commands explanation; add GUI Desktop shortcut explanation; minor dependency fixes for GUI" on 2020-09-21.

In my opinion, the topic structure(///) start with / will make a useless top topic level. If use this structure(

//), that will cut down a topic named /. I try to look for explanation about topic start with /. Most text just show examples about topic like home/floor/tempature which not start with /. I can only find one artical explain the reason written in Chinese 不要用 “/” 作为主题开头 MQTT允许使用“/”作为主题的开头,例如/home/sensor/data。但是这将这么做毫无意义,而且会额外产生一个没有用处的主题级别。所以我们应避免使用/作为主题的开头。 It means do not start with /, that will create a useless topic level. — You are receiving this because you commented. Reply to this email directly, view it on GitHub , or unsubscribe .
renerichter commented 2 years ago

Dear @BackMountainDevil, I agree that the first level "/" is rather useless and has, together with the other structure a more basic semantic meaning. As the system is intended to work with multiple setups hosting multiple devices which themselves have different commands the structure <SETUP>/<DEVICE>/<GENERALCOMMAND> was chosen. I hope this makes sense for you? Still: all the commands chosen and implemented yet (eg the GENERALCOMMANDS on ESP32) can be optimized to be much more light-weight. I hope this was helpful. Any suggestions are welcome.

PS: I reopened the issue as I am looking forward to still solve your error. :) PPS: Would you mind opening a new issue for the MQTT such that we can link it to a fix (pull-request) then?

BackMountainDevil commented 2 years ago

Thanks for your reply. I have look at REST API. Either turn to REST API or change the command structure will take many time and effort. So I just keep the same.

BackMountainDevil commented 2 years ago

I reproduce the origin problem about snap function on the same raspi 4B. This time I got two SD cards(same new system). The reproduce show that change gpu_mem may not be the solution.

I use SD 2 to test pi 4B : camera, mqtt, esp32 all work well.

new GUI screenshot

kivy GUI

Steps:

  1. Run app: python main.py>logx.txt
  2. Test show camera function: Show preview, Stop preview
  3. Test Snap function: Start Exp - Bright - SNAP.
  4. Freeze for a while and breakdown.

log4 - reproduce the breakdown

Keep origin resolution with the repo(3280x2464). As usual, it break down.

log ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210923_085601.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.toolbox ] False [ DEBUG ] [ UC2.toolbox ] Preview started [ DEBUG ] [ UC2.toolbox ] Preview stopped! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeAutofocus.py", line 214, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: fg.camera.resolution = fg.config[camdict]['resolution'] [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 2271, in _set_resolution [ WARNING ] [ kivy ] stderr: "Invalid resolution requested: %r" % (value,)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Invalid resolution requested: PiResolution(width=3280, height=2464) ```

log5 - Change gpu_mem to 256M and solution 2592x1944

log ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210923_090016.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.toolbox ] False [ DEBUG ] [ UC2.toolbox ] Preview started [ DEBUG ] [ UC2.toolbox ] Preview stopped! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: /home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py:544: PiCameraResolutionRounded: frame size rounded up from 2592x1944 to 2592x1952 [ WARNING ] [ kivy ] stderr: width, height, fwidth, fheight))) [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 1423, in capture [ WARNING ] [ kivy ] stderr: 'Timed out waiting for capture to end') [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: During handling of the above exception, another exception occurred: [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeAutofocus.py", line 229, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: toolbox.take_image_atom(rawCapture=rawCapture,rawFormat='rgb',camdict=camdict) [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 786, in take_image_atom [ WARNING ] [ kivy ] stderr: fg.camera.capture(rawCapture, format=rawFormat, use_video_port=use_video_port, bayer=use_bayer) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 1425, in capture [ WARNING ] [ kivy ] stderr: encoder.close() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 431, in close [ WARNING ] [ kivy ] stderr: self.stop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 419, in stop [ WARNING ] [ kivy ] stderr: self._close_output() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 349, in _close_output [ WARNING ] [ kivy ] stderr: mo.close_stream(output, opened) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/mmalobj.py", line 371, in close_stream [ WARNING ] [ kivy ] stderr: stream.flush() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/array.py", line 238, in flush [ WARNING ] [ kivy ] stderr: self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/array.py", line 127, in bytes_to_rgb [ WARNING ] [ kivy ] stderr: 'Incorrect buffer length for resolution %dx%d' % (width, height)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 2592x1944 ```

log6 - gpu_men 256M and resolution 640x480

Breakdown

log ```bash [ DEBUG ] [ UC2 ] Logging successfully initialized to -> uc2-20210923_090231.log Configuration file loaded MQTTClient: connecting to broker ----------------------------------------------------scopeInit [ INFO ] [ UC2.init ] MQTTClient: connecting to broker [ INFO ] [ UC2.init ] MQTTClient: Waiting for established connection. MQTTClient: Waiting for established connection.----------------------------------scopeInit [ INFO ] [ UC2.init ] Connected with result code = 0 Connected with result code = 0 MQTTClient: ok connection.----------------------------------scopeInit S001 | MQTTinit: LAR01 | ['MOT02', 'MOT02', 'MOT01'] ----------------------------------scopeInit [ DEBUG ] [ UC2.init ] Cam is online.---------------- [ DEBUG ] [ UC2.toolbox ] False [ DEBUG ] [ UC2.toolbox ] Preview started [ DEBUG ] [ UC2.toolbox ] Preview stopped! [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_imaging_technique_1. [ DEBUG ] [ UC2.io ] Folder check done! [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=CLEAR. tbs: /S001/LAR01/RECM pl: CLEAR rc: (0, 11) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=FLYBY+1. tbs: /S001/LAR01/RECM pl: FLYBY+1 rc: (0, 12) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2.toolbox ] Selected methods: ['Bright']. [ DEBUG ] [ UC2.toolbox ] this time selected method: btn_snap. [ DEBUG ] [ UC2.toolbox ] Active method = with mode= SNAP [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=NA+3. tbs: /S001/LAR01/RECM pl: NA+3 rc: (0, 13) MQTTDevice send for debug------------------------------------------- [ DEBUG ] [ UC2./S001/LAR01/ ] MQTTDevice_extractCommand -> topic_spec=/S001/LAR01/, cmd=RECT+0+0+8+8+1+120+120+120. tbs: /S001/LAR01/RECM pl: RECT+0+0+8+8+1+120+120+120 rc: (0, 14) MQTTDevice send for debug------------------------------------------- [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 1423, in capture [ WARNING ] [ kivy ] stderr: 'Timed out waiting for capture to end') [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraRuntimeError: Timed out waiting for capture to end [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: During handling of the above exception, another exception occurred: [ WARNING ] [ kivy ] stderr: [ WARNING ] [ kivy ] stderr: Traceback (most recent call last): [ WARNING ] [ kivy ] stderr: File "main.py", line 318, in [ WARNING ] [ kivy ] stderr: FluidiscopeApp().run() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/app.py", line 950, in run [ WARNING ] [ kivy ] stderr: runTouchApp() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 582, in runTouchApp [ WARNING ] [ kivy ] stderr: EventLoop.mainloop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 347, in mainloop [ WARNING ] [ kivy ] stderr: self.idle() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/base.py", line 387, in idle [ WARNING ] [ kivy ] stderr: Clock.tick() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 733, in tick [ WARNING ] [ kivy ] stderr: self.post_idle(ts, self.idle()) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/kivy/clock.py", line 776, in post_idle [ WARNING ] [ kivy ] stderr: self._process_events() [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 616, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 649, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 645, in kivy._clock.CyClockBase._process_events [ WARNING ] [ kivy ] stderr: File "kivy/_clock.pyx", line 218, in kivy._clock.ClockEvent.tick [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper [ WARNING ] [ kivy ] stderr: take_image(self) [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image [ WARNING ] [ kivy ] stderr: camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam') [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeAutofocus.py", line 229, in autofocus_setupCAM [ WARNING ] [ kivy ] stderr: toolbox.take_image_atom(rawCapture=rawCapture,rawFormat='rgb',camdict=camdict) [ WARNING ] [ kivy ] stderr: File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 786, in take_image_atom [ WARNING ] [ kivy ] stderr: fg.camera.capture(rawCapture, format=rawFormat, use_video_port=use_video_port, bayer=use_bayer) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 1425, in capture [ WARNING ] [ kivy ] stderr: encoder.close() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 431, in close [ WARNING ] [ kivy ] stderr: self.stop() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 419, in stop [ WARNING ] [ kivy ] stderr: self._close_output() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/encoders.py", line 349, in _close_output [ WARNING ] [ kivy ] stderr: mo.close_stream(output, opened) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/mmalobj.py", line 371, in close_stream [ WARNING ] [ kivy ] stderr: stream.flush() [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/array.py", line 238, in flush [ WARNING ] [ kivy ] stderr: self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution) [ WARNING ] [ kivy ] stderr: File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/array.py", line 127, in bytes_to_rgb [ WARNING ] [ kivy ] stderr: 'Incorrect buffer length for resolution %dx%d' % (width, height)) [ WARNING ] [ kivy ] stderr: picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 640x480 ```

About sulotion

Use raspistill test solution 2592x1944, 640x480.

$  raspistill  -o test.jpg
$  raspistill  -o test2.jpg -w 640 -h 480
# It is easy to check output file's resolution. It is 2592x1944, 640x480.
# list all video device
$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
    /dev/video10
    /dev/video11
    /dev/video12

bcm2835-isp (platform:bcm2835-isp):
    /dev/video13
    /dev/video14
    /dev/video15
    /dev/video16

mmal service 16.1 (platform:bcm2835-v4l2-0):
    /dev/video0

# list solution of /dev/video0
 $ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
    Type: Video Capture

    [0]: 'YU12' (Planar YUV 4:2:0)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [1]: 'YUYV' (YUYV 4:2:2)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [2]: 'RGB3' (24-bit RGB 8-8-8)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [3]: 'JPEG' (JFIF JPEG, compressed)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [4]: 'H264' (H.264, compressed)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [5]: 'MJPG' (Motion-JPEG, compressed)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [6]: 'YVYU' (YVYU 4:2:2)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [7]: 'VYUY' (VYUY 4:2:2)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [8]: 'UYVY' (UYVY 4:2:2)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [9]: 'NV12' (Y/CbCr 4:2:0)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [10]: 'BGR3' (24-bit BGR 8-8-8)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [11]: 'YV12' (Planar YVU 4:2:0)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [12]: 'NV21' (Y/CrCb 4:2:0)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2
    [13]: 'RX24' (32-bit XBGR 8-8-8-8)
        Size: Stepwise 32x32 - 2592x1944 with step 2/2

Sumary

  1. Change gpu_mem not work this time.
  2. I find gpu_mem could be revise in pi config via GUI

Screenshot_20210923_085407

Screenshot_20210923_085442 I

Thank you for watching.

renerichter commented 2 years ago

Thank you for your thourough error-analysis. Your error-messages point the fingers quite at different potential problems that are interesting for investigation.

  1. Run app: python main.py>logx.txt
  2. Test show camera function: Show preview, Stop preview
  3. Test Snap function: Start Exp - Bright - SNAP.
  4. Freeze for a while and breakdown.

I tested it on our systems and your approach is working fine here. So far so good.

log4 - reproduce the breakdown

Keep origin resolution with the repo(3280x2464). As usual, it break down.

[...]
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper
[ WARNING  ] [ kivy          ] stderr:     take_image(self)
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image
[ WARNING  ] [ kivy          ] stderr:     camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam')
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeAutofocus.py", line 214, in autofocus_setupCAM
[ WARNING  ] [ kivy          ] stderr:     fg.camera.resolution = fg.config[camdict]['resolution']
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/camera.py", line 2271, in _set_resolution
[ WARNING  ] [ kivy          ] stderr:     "Invalid resolution requested: %r" % (value,))
[ WARNING  ] [ kivy          ] stderr: picamera.exc.PiCameraValueError: Invalid resolution requested: PiResolution(width=3280, height=2464)

The last line Invalid resolution requested together with your presented output of v4l2-ctl -d /dev/video0 --list-formats-ext suggests that you did connect a different camera than RPiCam V2. Might this be the case?

log5 - Change gpu_mem to 256M and solution 2592x1944

[...]

[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 879, in take_image_wrapper
[ WARNING  ] [ kivy          ] stderr:     take_image(self)
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 899, in take_image
[ WARNING  ] [ kivy          ] stderr:     camStats, _ = af.autofocus_setupCAM(camStats=None, camdict='cam')
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeAutofocus.py", line 229, in autofocus_setupCAM
[ WARNING  ] [ kivy          ] stderr:     toolbox.take_image_atom(rawCapture=rawCapture,rawFormat='rgb',camdict=camdict)
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/Desktop/UC2-GUI/fluidiscopeToolbox.py", line 786, in take_image_atom
[ WARNING  ] [ kivy          ] stderr:     fg.camera.capture(rawCapture, format=rawFormat, use_video_port=use_video_port, bayer=use_bayer)
[...]
[ WARNING  ] [ kivy          ] stderr:     self.array = bytes_to_rgb(self.getvalue(), self.size or self.camera.resolution)
[ WARNING  ] [ kivy          ] stderr:   File "/home/pi/berryconda3/envs/UC2env/lib/python3.6/site-packages/picamera/array.py", line 127, in bytes_to_rgb
[ WARNING  ] [ kivy          ] stderr:     'Incorrect buffer length for resolution %dx%d' % (width, height))
[ WARNING  ] [ kivy          ] stderr: picamera.exc.PiCameraValueError: Incorrect buffer length for resolution 2592x1944

Suggests that the prepared buffer-shape within our app might not fit to the output-format of the buffer-stream of the camera. This might be due to a difference between the internal conventions in buffering between RPiCam v1 and v2. As we right now do not have a v1 lying around anymore we limit our support to RPICam v2. Hence right now I am sorry to not be able to check for a fix to this issue.

log6 - gpu_men 256M and resolution 640x480

...repeats log5 problem.

BackMountainDevil commented 2 years ago

Thank you for dive so deep into this issue. I see pi official shop and know the camera version is v2.1 now. However I am using v1.3. I think that is the reason.

renerichter commented 2 years ago

Always welcome! Did you by any chance try to change line 17ff of camera properties to eg

resolution:
- 2592
- 1944
sensor_mode: 3
sensor_mode_size:
- - 800
  - 480
- - 1920
  - 1080
- - 2592
  - 1944
- - 2592
  - 1944
- - 1640
  - 1232
- - 1640
  - 922
- - 1280
  - 720
- - 640
  - 480

and ran the code? Make sure that you overwrite these lines in your config/backup/... as well. It's a simple hack, but maybe this does already the trick?

BackMountainDevil commented 2 years ago

Thanks for advise. The device has been sent to lab. It would take a few weeks or months for my schoolmates to obersve and record. At that time, I will get the device and have a try. Should I close this issue now ?

renerichter commented 2 years ago

If the problem (for now) is solved for you and you anyways have to wait then please go ahead to close the issue. Further, as we are looking forward to your results as well, please feel free to reopen the issue at any time and get in touch again.

BackMountainDevil commented 2 years ago

Maybe a little late. I wrote a simple GUI via tkinter here. Not good enough. Only one motor and all LED. Enough for me now.

beniroquai commented 2 years ago

Now I would need understand a bit of chinese I guess :D (CC: @ranranking ) Awesome! Do you have any screenshots available?

Rush2112hale commented 2 years ago

What is a photo manager and do I need one ?

BackMountainDevil commented 2 years ago

sorry to late reply. about this issue, I think I am not going to dive into it. Maybe it is because I use the v1 camera while this project use v2. Issue will be close soon

From An idea

在 2022年8月2日,05:24,Rush2112hale @.***> 写道:

What is a photo manager and do I need one ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

--Apple-Mail-D0CD9620-9A0A-4512-A915-E8005B1681F0--