Last weekend I went to a meetup which was a bit like a hackathon. The title was ‘Multispectral Imaging with Raspberry Pi’. In a lot of ways I am not a fan of the Raspberry Pi – I feel that it was hyped as a great way to get kids into programming, but in reality most kids have access to full Windows PCs which they will be more familiar with and also have much more user friendly programming IDEs, tutorials etc. What interested me was the multispectral imaging, so I went along not sure what to expect.
They introduced the concept of the Normalised Difference Vegetation Index (NDVI). This is a value indicates the health of plant life and calculate by measuring the light reflected by a plant. It is defined as:
Where NIR is the Near Infrared light reflected by the plant and Red is the red light reflected by the plant.
In order to capture these two values, we used two raspberry pi cameras connected to two raspberry pis. In one of our cameras there was an infrared filter fitted which stops IR from reaching the sensor, however in the other this had been removed and a blue filter put in front. This meant that the red channel of the first camera captured only red light, while the red channel of the second camera captured only IR. Using the two pis and two cameras we could capture both images simultaneously.
The device operated from a normal usb power bank and connected to the wifi. This meant that we could open a secure shell to each of the raspberry pis from my laptop. In order to synchronise the two photos a wire was connector from the GPIO of one pi (the master) to the GPIO of the other pi (the slave). Therefore, we could connect to the master via SSH and tell it to take a photo. The master would then send a pulse on the GPIO to the slave which was waiting. Both devices would then take a photo simultaneously. We could then copy both photos back to my laptop via SCP.
The final step was to take the two photos and, for each pixel, calculate the NDVI. This value could then be used to create a greyscale image output.
You can see that the plant stands out as a very white object. Interestingly you can also see other, non-plant objects that stand out. Therefore this cannot be indiscriminately used to find healthy plants, but merely used to distinguish healthy plants from unhealthy plants once the property of ‘being a plant’ has been ensured.
Admittedly, I never tested it on an unhealthy plant simply because none were present and it seems inhumane (inplante?) to purposely make a plant ill.
The pictures are clearly not perfectly aligned and this is because the two images are taken from adjacent cameras. This could be improved by using a single sensor and making the filter removable, however the photos would then not be perfectly aligned.