# FLIR Thermal Camera Person Detection

**URL:** <https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258>\
**Category:** OpenMV Boards\
**Created:** [May 17, 2019, 6:18am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258 "2019-05-17T06:18:15Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [May 17, 2019, 6:18am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/1 "2019-05-17T06:18:15Z")

</div>

Ibrahim made this example script showing off person detection using the FLIR Thermal camera. Works with any FLIR Lepton.

```python
import sensor, image, time, os, nn

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565
sensor.set_framesize(sensor.QQVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((32, 64)) # Set 128x128 window.
sensor.skip_frames(time=1000)

net = nn.load('/person.network')

clock = time.clock() # Create a clock object to track the FPS.
while(True):
    clock.tick() # Update the FPS clock.
    img = sensor.snapshot() # Take a picture and return the image.
    out = net.forward(img, softmax=True)
    if out.index(max(out)) == 0:
        print("person detected")

```

Save the person.network to your SD card.  
[person.zip](https://forums.openmv.io/uploads/short-url/xcM0RlpS1ELa8k3xUsD36VTsEe.zip) (64.1 KB)

---

<div class="post-metadata">

**Author:** ![RECOVA](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/recova/32/1561_2.png) [@RECOVA](https://forums.openmv.io/u/RECOVA)\
**Post date:** [August 18, 2020, 3:44am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/2 "2020-08-18T03:44:57Z")

</div>

HELLO  
I loaded the code to my openmv cam h7 with a lepton 2.5 sensor and at the time of execution I got the error: OsERROR: this function is unavaible on your open MV cam could you help me please

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [August 18, 2020, 5:08am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/3 "2020-08-18T05:08:37Z")

</div>

We removed the NN module.

Ibrahim, do you have the dataset this model was trained on? It could be quickly moved to TensorFlow with the dataset.

---

<div class="post-metadata">

**Author:** ![iabdalkader](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/iabdalkader/32/1169_2.png) [@iabdalkader](https://forums.openmv.io/u/iabdalkader)\
**Post date:** [August 18, 2020, 12:00pm UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/4 "2020-08-18T12:00:33Z")

</div>

Yes, I think it was this dataset:

[http://portal.uc3m.es/portal/page/portal/dpto\_ing\_sistemas\_automatica/investigacion/IntelligentSystemsLab/research/InfraredDataset](http://portal.uc3m.es/portal/page/portal/dpto_ing_sistemas_automatica/investigacion/IntelligentSystemsLab/research/InfraredDataset)

[https://e-archivo.uc3m.es/handle/10016/17370](https://e-archivo.uc3m.es/handle/10016/17370)

Note, you need to downsample the 14 bit images to 8 bit before training and testing, and use FLIR module in GS mode.

---

<div class="post-metadata">

**Author:** ![NoBearSnack](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NoBearSnack](https://forums.openmv.io/u/NoBearSnack)\
**Post date:** [December 20, 2020, 7:03am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/5 "2020-12-20T07:03:38Z")

</div>

Will this work with the Lepton PureThermal2 USB camera plugged into a Rpi? If so, this would be a godsend. I’m trying to create a FLIR sensor that detects bears and blows an airhorn for our yurt off grid in Alaska. Brown bear tore our place to pieces while we were gone and we’re hoping to keep that from happening again. I’m going to get to researching this in the morning but many thanks for any help!

---

<div class="post-metadata">

**Author:** ![NoBearSnack](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NoBearSnack](https://forums.openmv.io/u/NoBearSnack)\
**Post date:** [December 20, 2020, 7:10am UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/6 "2020-12-20T07:10:26Z")

</div>

Just saw this video and I can’t tell you how excited I am if this will prove a solution. I’ll need to train it over time to recognize bears by capturing my own video I imagine (I doubt there is a bear FLIR training set out there, but who knows) and I suppose I can do that by just having it blow the horn anytime it detects something from 80-105F just to be safe. Maybe it will be a moose, but I’ll collect the images and train it over time.

Super excited about this!

[![](https://canada1.discourse-cdn.com/flex029/uploads/openmv1/original/2X/3/3007e1e96a93f825233b935bde18b5a09fa36a9e.jpeg "OpenMV Cam Pure Thermal Auto Focus") ](https://www.youtube.com/watch?v=MZ2u_0UB6NI)

---

<div class="post-metadata">

**Author:** ![NoBearSnack](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NoBearSnack](https://forums.openmv.io/u/NoBearSnack)\
**Post date:** [December 20, 2020, 6:25pm UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/7 "2020-12-20T18:25:25Z")

</div>

I have the PureThermal2 and I think I can pop the lepton camera off of it, could I then pop that into this adapter?

> **[FLIR® Lepton® Adapter Module](https://openmv.io/collections/cams/products/flir-lepton-adapter-module)**
>
> The FLIR® Lepton® Adapter Module allows your OpenMV Cam to interface with the FLIR® Lepton® 1/2/3 Thermal Imaging sensors for Thermal Vision applications.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [December 20, 2020, 6:47pm UTC](https://forums.openmv.io/t/flir-thermal-camera-person-detection/1258/8 "2020-12-20T18:47:19Z")

</div>

Yep, that’s fine.
