Saving frames when the animal (fish) is in the camera view

Lab pictures

Zebrafish larvae swim intermittently, with a pause between bouts. Calcium signals can be obtained when fish are not moving (See Muto et al., 2017).

Now I wanted to record for longer time. The challenge is that fish comes in the camera view only occasionally. Most of the frames have no fish in it, which I don’t want to save just to fill up my disk space with background images. How can I save frames only when fish is in camera view?

Hamamatsu ORCA Flah4.0 camera can be controlled in LabVIEW (National Instruments).Here is what I did in LabVIEW programming. By drawing a histogram of pixel values, I could see noise and fish that can be segregated in the histogram.

 

The fish part in the histogram can be use as a “template”, which will be multiplied with the counterpart of each frame (histogram). When the dot product (i.e., vector-vector multiplication) gives values exceeding a set value, fish was found in the camera view. Nice thing about this is that even when only a part of the whole body, like the head, is there, fish can be detected (depending on the set threshold value).

Use small number of bins (e.g. 10) to minimize the time to make a histogram. In this way, 20 fps can be achieved (25ms exposure time, 25ms for the calculation and saving of the image) at 1024×1024 spatial resolution (i.e., 2×2 binning with this camera).

タイトルとURLをコピーしました