This camera setup is designed to go into small spaces where my other setups would not fit
Its basically the same setup I use in my birdboxes, with a Raspberry Pi + Raspberry Pi v2 IR camera module + IR cut + some IR LEDs, with the addition of an adaptor which allows you to turn an HDMI cable into a camera cable extension. I used a 3 meter HDMI cable (Amazon basics) as I wanted to get the camera into an otherwise inaccessible bit of the shed where a Treecreeper had been building a nest.
The HDMI cable adapter with the camera attached has a couple of spare cables in it, so I was also able to power four IR leds and switch an IR cut via the one HDMI cable. The IR cut is the round black thing on top of the Raspberry Pi camera board that switches it from visible to IR light sensitive modes.
If I was to do this again I would add a few white LEDs that would switch on when the IR leds were off (it's possible do the IR on/vis off and vice versa by using the same GPIO pin with NPN and PNP transistor combined). As-is, having the IR cut is a bit superfluous since without the IR light it's pretty dark in there, and a 'day mode' doesn't see much without any visible light illumination - one for a future post (when I've modified it!).
You can get the HDMI adaptor direct from it's French maker via Tindie, or via UK all-round supplier of shiny must-haves Pimoroni (hint it's a bit cheaper to go direct to Tindie).
Here is a screen capture of the Treecreeper nest
The camera cable is poked through a gap in the shed structure into a void space created by the corner cladding on the outside.
Here is the bird bringing nesting material in...
This gives some idea of the length of the cable
I sort of threw together the perfboard sitting on top, so don't look too hard... I've also used a longer than normal camera ribbon cable so that it comfortably reaches the HDMI adaptor.
I've enlarged it below to give show how the Pi end of the HDMI adaptor works.
Unfortunately our Treecreeper didn't get as far as egg laying, I can only assume that she found a preferable site elsewhere. I do wonder if the bench saw in the shed put her off.... But it does mean that I've now got a mini camera for tricky places for next year...
Showing posts with label IRcut. Show all posts
Showing posts with label IRcut. Show all posts
Monday, 4 November 2019
Saturday, 7 July 2018
BirdBox infra-red camera IR filter upgrade
Now that the bird nesting season is over, it's upgrade time! The infrared (IR) cameras in this year's boxes are getting IR filters...
This year's two new bird boxes have an infrared (IR) camera with visible and IR LEDs (Robin box Birch log tit box). There is 'night mode' with IR light that the birds cant see, and day mode with optional visible light illumination. All non IR-light sensitive cameras have an IR filter built into the camera, whereas IR-sensitive cameras don't.
Without an IR filter, IR camera images have a pinkish cast to them in visible light, giving a permanent 'Hipstamatic' look:
An IR filter (called an IR-cut) converts an IR-sensitive camera into a conventional one that can't see IR light. This gizmo has a bit of glass in it that blocks IR light, and can move backwards and forwards over the camera lens by changing the voltage polarity applied across it.
These bird boxes use the 8MP Raspberry Pi IR camera board. This has a similar shape and design to those found found in many commercial CCTV cameras, so IR filters designed for CCTV camera modules can be fitted to them. Sort of...
I wanted something easy to add to this year's boxes, and found an IR cut filter without a lens mount which fits nicely over the existing screw holes in the Raspberry Pi camera module (22mm separation).
This come from AliExpress (China, so take a couple of weeks to get to the UK), and costs $3.50 so wont break the bank. It comes with a separate lens mount holder which I haven't used. There's the option of 20mm or 22mm screw hole separation at order - you need the 22mm one as to fit the Raspberry Pi camera board.
This shows the underside of the camera unit that is slotted in to the top of the birdbox, pre and post IR-cut upgrade. The ir-cut is attached over the camera by M2 nylon screws and nuts, and the screws just go through the 4mm ply and pass through the camera board.
I had previously designed this year's Raspberry pi zero W add-on board with an IR-cut in mind. The voltage polarity reversal to switch the IR-cut is done with a L293DNE (£2.70). I did a more detailed writeup of this here which also has some example code. The design for the wiring of this my customised add-on board is detailed here.
No birds in this, but you get the idea what switching the IR-cut in natural daylight does...
...so there are alternatives to this, eg here which has integrated IR LED, camera and IR cut - does not have stellar reviews on amazon though.
![]() |
| and some to spare... |
This year's two new bird boxes have an infrared (IR) camera with visible and IR LEDs (Robin box Birch log tit box). There is 'night mode' with IR light that the birds cant see, and day mode with optional visible light illumination. All non IR-light sensitive cameras have an IR filter built into the camera, whereas IR-sensitive cameras don't.
Without an IR filter, IR camera images have a pinkish cast to them in visible light, giving a permanent 'Hipstamatic' look:
![]() |
| Un-filtered IR camera pink colour is obvious here |
An IR filter (called an IR-cut) converts an IR-sensitive camera into a conventional one that can't see IR light. This gizmo has a bit of glass in it that blocks IR light, and can move backwards and forwards over the camera lens by changing the voltage polarity applied across it.
These bird boxes use the 8MP Raspberry Pi IR camera board. This has a similar shape and design to those found found in many commercial CCTV cameras, so IR filters designed for CCTV camera modules can be fitted to them. Sort of...
My first attempt to do this was the top-down camera in last years's double camera bird box. Unfortunately, I sourced an IR-cut that had an ?M12 lens mount on it, basically a dirty great chunk of plastic poking out the font that needed to be cut off before I could use it = fiddly. You can see my v1 test for this here from a separate project:
I wanted something easy to add to this year's boxes, and found an IR cut filter without a lens mount which fits nicely over the existing screw holes in the Raspberry Pi camera module (22mm separation).
This come from AliExpress (China, so take a couple of weeks to get to the UK), and costs $3.50 so wont break the bank. It comes with a separate lens mount holder which I haven't used. There's the option of 20mm or 22mm screw hole separation at order - you need the 22mm one as to fit the Raspberry Pi camera board.
This shows the underside of the camera unit that is slotted in to the top of the birdbox, pre and post IR-cut upgrade. The ir-cut is attached over the camera by M2 nylon screws and nuts, and the screws just go through the 4mm ply and pass through the camera board.
![]() |
| IR-cut sitting flush against the 'underside' of the bird box camera insert |
I had previously designed this year's Raspberry pi zero W add-on board with an IR-cut in mind. The voltage polarity reversal to switch the IR-cut is done with a L293DNE (£2.70). I did a more detailed writeup of this here which also has some example code. The design for the wiring of this my customised add-on board is detailed here.
No birds in this, but you get the idea what switching the IR-cut in natural daylight does...
...so there are alternatives to this, eg here which has integrated IR LED, camera and IR cut - does not have stellar reviews on amazon though.
Saturday, 24 February 2018
Coding for day or night events
This post was promoted by a post on the GarysShed blog after a discussion on triggering events based on whether it's day or night time.
To be fair, the whole post is an excuse to include following video from the BBC's 'Walk on the Wildside' series
I needed to modify the behaviour of the illumination LEDs in one of my Raspberry Pi-based birdboxes based on whether it is light or dark. This box has IR (Infra-Red) as well as visible light LEDs, I wanted the IR to operate all the time, and the standard LEDs to come on (and IR LED go off) only in the event of a daytime motion 'event', which could be triggered by any of: Entrance hole IR beam being broken, PIR insider the box triggered or motion detected on camera.
An IR-cut filter over the camera can then be switched on or off depending based on this too - IR LED off when visible LEDs are on. (An IR-cut filter turns an IR-sensitive camera into a daylight-only sensitive camera).
The idea was that I didn't want visible LEDs coming on during the night, mainly to disturb any occupants, I also didn't want this happening as it looks a bit odd from the outside:
Possible solutions:
1) Analyse camera image for brightness
2) Use a light-dependent resistor (LDR) to sense ambient light and modify LED behaviour based on this.
3) Implement a software-method to predict day vs night based on longitude and latitude
1) Analyse camera image for brightness. Borrowed code from here and here and here
If run in the terminal, will output something like: 81.857%,38.706%,17.7462% where these figures are the HSB (hue, saturation, brightness) values from a 1x1 pixel converted version of the original image (test.png in this example)
2) Use LDR to monitor light. There's loads of examples out there how to do this, a randomly selected recent one here
At one time I did a merge of method 1 & 2 to which I've uploaded to a github repository Ambient-Light-Monitoring, the script is called ambient_lightMonitor.py. This reads actual light level via an LDR, and also takes image with a Raspberry Pi Camera and measures image brightness. All these variables are then written to a filefor playing with which could be applied with in a variety of contexts..
3) Software method
I've tried two approaches, both rely on feeding the application the current location via longitude and latitude.
3.1) SunWait. A stand-alone program, an example use is described in a blog post here. Essentially you run a crontab job every ?minute that writes to a file to indicate the current light/dark state. You can then read that file into your application and base the outcome on whether its day (..light) or night (...dark). I could not get it to work..
3.2) Python module: pyephem, website here
This is a python module, so is used within a python script. You need to install python-dev first or the install of this module will fail. The module can then be installed with the pip python module installer
Note, the sudo bit is important otherwise if you attempt to run a python script from rc.local containing this module (to run it at boot) the root user wont be able to find the module since without 'sudo...' it will install ephem under the user 'pi'
This approach worked for me. Longitude and Latitude can be generated on various websites, eg here, pyephem also uses height above sea level which I think I got off google earth. This would be aprticularly relevant if you're using it at the top of a mountain....
Refer to the example script light_dark.py in the above mentioned githib repository
3.3) ?Pikrellcam motion capture application
I use the awesome motion capture application PiKrellCam in my birdboxes. In its .config file is the facility to define location by longitude and latitude. I spotted a recent forum post querying if it was possible to switch an IR-cut filter on or off by using the day/night status within Pikrellcam to trigger a command to the GPOI pin(s) controlling the IR cut. See my IR-cut post on how to wire such a thing up.
To be fair, the whole post is an excuse to include following video from the BBC's 'Walk on the Wildside' series
I needed to modify the behaviour of the illumination LEDs in one of my Raspberry Pi-based birdboxes based on whether it is light or dark. This box has IR (Infra-Red) as well as visible light LEDs, I wanted the IR to operate all the time, and the standard LEDs to come on (and IR LED go off) only in the event of a daytime motion 'event', which could be triggered by any of: Entrance hole IR beam being broken, PIR insider the box triggered or motion detected on camera.
An IR-cut filter over the camera can then be switched on or off depending based on this too - IR LED off when visible LEDs are on. (An IR-cut filter turns an IR-sensitive camera into a daylight-only sensitive camera).
The idea was that I didn't want visible LEDs coming on during the night, mainly to disturb any occupants, I also didn't want this happening as it looks a bit odd from the outside:
Possible solutions:
1) Analyse camera image for brightness
2) Use a light-dependent resistor (LDR) to sense ambient light and modify LED behaviour based on this.
3) Implement a software-method to predict day vs night based on longitude and latitude
1) Analyse camera image for brightness. Borrowed code from here and here and here
convert test.png -colorspace hsb -resize 1x1 txt:- | sed -n 2p | sed 's/.*(//; s/).*//'
If run in the terminal, will output something like: 81.857%,38.706%,17.7462% where these figures are the HSB (hue, saturation, brightness) values from a 1x1 pixel converted version of the original image (test.png in this example)
2) Use LDR to monitor light. There's loads of examples out there how to do this, a randomly selected recent one here
At one time I did a merge of method 1 & 2 to which I've uploaded to a github repository Ambient-Light-Monitoring, the script is called ambient_lightMonitor.py. This reads actual light level via an LDR, and also takes image with a Raspberry Pi Camera and measures image brightness. All these variables are then written to a file
3) Software method
3.1) SunWait. A stand-alone program, an example use is described in a blog post here. Essentially you run a crontab job every ?minute that writes to a file to indicate the current light/dark state. You can then read that file into your application and base the outcome on whether its day (..light) or night (...dark). I could not get it to work..
3.2) Python module: pyephem, website here
This is a python module, so is used within a python script. You need to install python-dev first or the install of this module will fail. The module can then be installed with the pip python module installer
sudo apt-get install python-dev sudo apt-get install python-pip #if pip not available, e.g. on Raspbian Lite
sudo pip install ephem
This approach worked for me. Longitude and Latitude can be generated on various websites, eg here, pyephem also uses height above sea level which I think I got off google earth. This would be aprticularly relevant if you're using it at the top of a mountain....
Refer to the example script light_dark.py in the above mentioned githib repository
3.3) ?Pikrellcam motion capture application
I use the awesome motion capture application PiKrellCam in my birdboxes. In its .config file is the facility to define location by longitude and latitude. I spotted a recent forum post querying if it was possible to switch an IR-cut filter on or off by using the day/night status within Pikrellcam to trigger a command to the GPOI pin(s) controlling the IR cut. See my IR-cut post on how to wire such a thing up.
Monday, 5 June 2017
ZeroView IR-Cut hack
This is hopefully the beginning of something beautiful... This a ZeroView, which is a neat way to attach a Raspberry Pi zero-W + camera module to a window:
I've modified modified the ZeroView (+IR camera module) to squeeze in an infra-red cut filter (IR-cut) between the ZeroView and the PiZero, making a wifi enabled 8MP camera that can see in the dark (+IR illumination)...
This is still very much a work in progress as I need to add an IR illumination source too. Some incarnation of this will find its way into a nest box or a trail camera. As-is it does stay stuck to a window, but the addition of the perfboard does make it a bit top-heavy. I'm sure it can be refined a bit...
Here is a video showing filter on and off. This was captured using PikrellCam:
Filter is switched using a L293DNE, connected in the above example as follows:
Sample python script:
I've modified modified the ZeroView (+IR camera module) to squeeze in an infra-red cut filter (IR-cut) between the ZeroView and the PiZero, making a wifi enabled 8MP camera that can see in the dark (+IR illumination)...
This is still very much a work in progress as I need to add an IR illumination source too. Some incarnation of this will find its way into a nest box or a trail camera. As-is it does stay stuck to a window, but the addition of the perfboard does make it a bit top-heavy. I'm sure it can be refined a bit...
![]() |
| IRcut OFF (top) & ON (bottom) |
Here is a video showing filter on and off. This was captured using PikrellCam:
Filter is switched using a L293DNE, connected in the above example as follows:
import RPi.GPIO as GPIO import time import datetime as dt import os GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.cleanup IRcutEnable=13 IRcut1A=6 IRcut2A=9 IRcutPins=[13,6,9] for IRcutPin in IRcutPins: GPIO.setup(IRcutPin,GPIO.OUT) #Default states: global IR_cutState IR_cutState="not_set" def separator(): print "---------------------------" def IRcut_DayTime(): print "IR cut DAY" print "=============" GPIO.output(IRcutEnable,GPIO.HIGH) GPIO.output(IRcut1A,GPIO.LOW) GPIO.output(IRcut2A,GPIO.HIGH) print "IRcutEnable ("+str(IRcutEnable)+") = HIGH" print "IRcut1A ("+str(IRcut1A)+") = LOW" print "IRcut2A ("+str(IRcut2A)+") = HIGH" print "" global IR_cutState IR_cutState="IRcut_DAY" time.sleep(0.5) def IRcut_NightTime(): print "IR cut NIGHT" print "=============" GPIO.output(IRcutEnable,GPIO.HIGH) #was LOW GPIO.output(IRcut1A,GPIO.HIGH) GPIO.output(IRcut2A,GPIO.LOW) #was HIGH print "IRcutEnable ("+str(IRcutEnable)+") = LOW" print "IRcut1A ("+str(IRcut1A)+") = HIGH" print "IRcut2A ("+str(IRcut2A)+") = L" print "" global IR_cutState IR_cutState="IRcut_NIGHT" time.sleep(0.5) def IRcut_STOP(): print "STOP" GPIO.output(IRcut2A, GPIO.LOW) time.sleep(2) while True: IRcut_NightTime() time.sleep(2) IRcut_DayTime() time.sleep(2)
Subscribe to:
Posts (Atom)

















