ai-thermometer icon indicating copy to clipboard operation
ai-thermometer copied to clipboard

Capture of pixel temperature with Lepton 3.5 camera

Open GillesBra opened this issue 4 years ago • 1 comments

Hi Tomasz, Thank you very much for your answer concerning the script you have developped for temperature capture with Lepton 3.5.

Not being experienced in software development, I send you below a few questions:

  • How is captured the 16 bits flow of the Lepton camera ? Does the Python script command the camera (in line 47 to 67 or 218) ? Or do we have to send separate commands through the CCI channel ?

  • Which data contains the libuvc and how is it fed ?

  • Which command stops the flow ?

  • Have you an example of the temperature array (both link in your mail points to the script)

  • Which configuration is needed to run the script ? Is Lepton 3.5 with PureThermal2 connected via USB to a PC with windows 10 acceptable ?

  • Which software do we have to load (Python, openCV...) ?

Sorry to take your time by basic questions, but this could help the project a lot.

GillesBra avatar Sep 07 '21 16:09 GillesBra

Hi @GillesBra !

Glad you answer your questions:

  1. The Lepton Camera with Purethermal board act together as a USB UVC device. So going line-by-line:
  • start_pt2() in Line 47 is responsible for finding and opening the device,
  • uvc_get_stream_ctrl_format_size() in line 67 sets capture parameters such as frame dimensions, format, frame interval, etc. So the Y16/ 16-bit grayscale format is set here.
  • py_frame_callback() in line 78 is the function that is called every time a new frame arrives, and puts the frames in a Queue. The Queue is there mostly to avoid waiting in the consumer thread (could be up to 1/(8.7Hz)=115ms
  • Line 218 is where we pop the ready frames from a Queue, and convert them to Celsius via ktoc()
while True:
    data = q.get(True, 500)
    print(ktoc(data))
  1. Here it is (an aarch64 binary): https://github.com/tomek-l/ai-thermometer/blob/master/ir/libuvc_wrapper/libuvc.so

Here are instructions to build your own:

git clone https://github.com/groupgets/libuvc
cd libuvc
mkdir build
cd build
cmake ..
make
cp libuvc.so ~/ai-thermometer/ir/libuvc_wrapper
  1. self._exit_handler() does the cleanup here
libuvc.uvc_stop_streaming(self._devh)
libuvc.uvc_unref_device(self._dev)
libuvc.uvc_exit(self._ctx)
  1. I don't have an output of a full array. The closest thing would be in this notebook
array([[32.56, 32.32, 32.36, ..., 31.93, 31.47, 31.77],
       [32.52, 32.06, 32.  , ..., 31.77, 31.47, 31.81],
       [32.38, 32.36, 32.24, ..., 31.57, 31.53, 31.77],
       ...,
       [31.77, 31.75, 32.32, ..., 31.11, 31.15, 30.81],
       [31.75, 31.57, 32.12, ..., 31.03, 30.71, 30.89],
       [31.77, 31.59, 31.77, ..., 31.11, 30.71, 30.73]])
  1. Please read README.md. This is the list of supported parts:
# Part link Price (USD)
1 Jetson Nano Dev Kit link 99
3 FLIR Lepton 3.5 IR Camera link 199
4 GroupGets Purethermal2 Module link 99
2 Raspberry Pi Camera Module V2.1 link 25
5 Noctua cooling fan link 14
6 3D printed enclosure 3D model -
total 436
  1. The project depends on:
  • numpy (pip3 install numpy)
  • opencv (build instructions in README.md)
  • pytorch (build instructions in README.md)

That being said, I should add a proper requirements.txt to this project.

tomasz-lewicki avatar Sep 08 '21 04:09 tomasz-lewicki