## 2 Materials and Methods
### Bee Motion Counting and Image Data  
#### 2.2.1 Bee Motion Counting  
In this investigation, we focused on training and evaluating three types of classifiers--automatically and manually designed ConvNets, RFs, and linear SVMs--to classify motion regions. The curation of the image datasets, described in detail in the next two sections, is best construed in the context of the BeePi bee motion counting algorithm shown in Figure 4 and illustrated in the performance videos in the Supplementary Materials. Once mounted on top of a Langstroth beehive (see Figure 1), a BeePi monitor captures a 30-s video every 15 min from 8:00 to 21:00 at a resolution of 360 \(\times\) 240 or 1920 \(\times\) 1080 pixels. All frames from each captured video are processed for motion detection. We experimented with three motion detection algorithms available in OpenCV 3.0.0: KNN [38], MOG [39], and MOG2 [40]. Although all three algorithms performed on par, we experimentally found that MOG2 worked slightly better than either KNN or MOG, because it was less sensitive to shadows [51, 53]. Figure 4: Video processing in BeePi. More details are available in the performance videos in the supplementary materials. Figure 3: A closer look at the camera looking down on the landing pad. More hardware details are available at [42, 43]. When the monitor is placed on the third super, as shown in the picture, the monitor’s camera is \(\approx\)85 cm above the landing pad and the camera’s field of view in this picture is \(\approx\)200 cm high and \(\approx\)320 cm wide. The output of the motion detection module is a set of image regions centered around detected motion points. We call these image regions _motion regions_. In Figure 4, the image with the subtitle \"Motion Regions\" shows detected motion regions as yellow squares. The yellow squares depict the cropped region boundaries around each detected motion point. The size of each square is a height-dependent parameter of the algorithm. To understand how we chose the values of the height parameter, it is helpful to understand the basic beekeeping cycle in a Langstroth live. Initially, after a beekeeper hives a fresh bee package in a Langstroth beehive, the hive consists of a single deep super (a rectangular wooden box 50.48 cm long, 41.28 cm wide and 24.45 cm high) with ten empty frames where the newly hived colony starts to develop. In a hive with a single deep super, a BeePi monitor is placed on top of that super. As the bees fill the frames in the first deep super with comb, pollen, and brood, the beekeeper places a second deep super with another ten frames on top of the first deep super to give the bee colony more space to expand and grow. After the second super is placed on top of the first one, the BeePi monitor is placed on top of the second super. While Langstoth hives with healthy colonies can potentially grow to be four or even five supers high, we confined the scope of this investigation to hives with one or two supers. We refer to the data captured from BeePi monitors on first supers as _1-super data_ and to the data captured from BeePi monitors on second supers as _2-super data_. When the monitor is placed on a single super, the monitor's camera is \(\approx\)35 cm above the hive's landing pad and the camera's field of view is \(\approx\)50 cm high and \(\approx\)80 cm wide. When the monitor is placed on the second super, the monitor's camera is \(\approx\)60 cm above the landing pad and the camera's field of view is \(\approx\)100 cm high and \(\approx\)160 cm wide. When the BeePi monitor is placed on the first super (i.e., the camera is \(\approx\)35 cm above the landing pad), the size of each motion region is set to 150 \(\times\) 150 pixels (see yellow squares in Figure 5). We experimentally found this size to be optimal in that, when cropped, 150 \(\times\) 150 motion regions had a higher probability of containing at least one full-size bee than the other motion region sizes we tested.