stawel / ht301_hacklib

ht-301 thermal camera opencv lib
GNU General Public License v3.0
56 stars 31 forks source link

Exporting (uncompressed) video file? #9

Open zeirix opened 1 year ago

zeirix commented 1 year ago

Very cool project!

Is it possible to output the Data as a 25 fps lossless video file (grayscale or Iron colors) or maybe as a bunch of PNGs, that could be merged to a video? I tried to get out a Video out of my HT-301 with VLC, but it looks noisier, than the output of your opencv.py script.

Thanks a lot!

stawel commented 1 year ago

unfortunately, I don't have much time to deal with this project so I can only give you some hints, you could:

  1. save frame after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L15 at this line frame should be 16bit raw sensor ADC data (numpy 2D array of type numpy.uint16)
  2. add lut_frame = lut[frame] to line 16 and save it, lut_frame will be a 2D array of temperatures in Celsius (of type numpy.float32)
  3. save frame after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L23 here frame is a numpy.uint8 scaled gayscale of raw sensors ADC data
  4. save frame after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L24 here frame is an RGB (or BGR I'm not sure) image, probably this should do at line 25:
    cv2.imwrite('image.png', frame)
    1. save frame after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L32 (see point 4.)

to save the output as one video file you probably can use: https://www.geeksforgeeks.org/saving-a-video-using-opencv/

zeirix commented 1 year ago

Hi Pawel,

Thank you for sharing these hints. I'll try to edit the script.

lorenzo-gi commented 1 month ago

@zeirix I was also thinking about saving the video. Have implemented already? Any hint?

lorenzo-gi commented 1 month ago

unfortunately, I don't have much time to deal with this project so I can only give you some hints, you could:

1. save `frame` after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L15
   at this line `frame` should be 16bit raw sensor ADC data (numpy 2D array of type numpy.uint16)

2. add `lut_frame = lut[frame]` to line 16 and save it, `lut_frame` will be a 2D array of temperatures in Celsius (of type numpy.float32)

3. save `frame` after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L23
   here `frame` is a numpy.uint8 scaled gayscale of raw sensors ADC data

4. save `frame` after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L24
   here `frame` is an RGB (or BGR I'm not sure)  image, probably this should do at line 25:
cv2.imwrite('image.png', frame)
5. save `frame` after line https://github.com/stawel/ht301_hacklib/blob/master/opencv.py#L32
   (see point 4.)

to save the output as one video file you probably can use: https://www.geeksforgeeks.org/saving-a-video-using-opencv/

Just wanted to add that those links are now referring to an old commit. I assume the correct commit was this one: https://github.com/stawel/ht301_hacklib/blob/81f14d0fc81b4d9d7d0067aa877b213f1ff0c220/opencv.py