## 2 Materials and Methods
### Bee Motion Counting and Image Data
#### 2.2.1 Bee Motion Counting
Specifically, to discover this size, we took samples of \(n\)\(\times\)\(n\) motion regions from 1-super videos, where \(n\) ranged from 50 to 250 in increments of 10, and manually counted the percentage of samples containing at least one full-size bee for each sample size. The size of 150 \(\times\) 150 had the highest percentage of regions with at least one full-size bee. When the monitor is placed on the second super (i.e., the camera is \(\approx\)60 cm above the landing pad), the size of each motion region is set to 90 \(\times\) 90 pixels. This size was also experimentally found to be optimal in the same fashion as in the case of the single super in that 90 \(\times\) 90 motion regions from 2-super videos contained the highest number of regions with at least one full-size bee. Each detected motion region is classified by a trained classifier (e.g., a ConvNet, an RF, or an SVM) into two classes--BEE or NO-BEE. When a detected motion region is classified by a ConvNet,  
Figure 5: Three sample frames of the landing pad of a Langstroth beehive captured from a BeePi monitor’s camera mounted on top of the first deep super. The yellow squares mark 150 \(\times\) 150 regions with detected motion. The performance videos in the Supplementary Materials show how our system detects bee motions in real time. it is resized to fit the dimensions of the input layer of a particular ConvNet (i.e., 32 \(\times\) 32 pixels or 64 \(\times\) 64 pixels). In the case of an RF or an SVM, the size of each detected motion region is left unchanged. In Figure 4, two motion regions are shown under the title \"Motion Region\". The upper region contains a bee while the bottom one does not. Similarly, in Figure 5, some motion regions contain bees or parts thereof while others do not. For each video, the BeePi video processing algorithm returns the number of omnidirectional bee motions within the camera's field of view over a 30-s period. We call these numbers _bee motion counts_ and use them as estimates of omnidirectional bee traffic levels. Algorithm 1 outlines the pseudocode of our bee motion counting method described above. On Line 2, the video is segmented into frames. In each frame, all motions are detected on Line 3. On Lines 4-13, each motion point is boxed to become a motion region, resized when necessary, classified by a classifier, and the total bee motion count is increased if a bee is detected in the motion region. On Line 15, the count of detected bee motions is returned. ```
1: BeeMotionCount = 0;
2:For each frame \(F\) in \(V\)Do
3: MotionPoints = Use \(MD\) to detect motions in \(F\);
4:For each motion point \(P\) in MotionPoints Do
5: MotionRegion = crop \(H\) x \(W\) box around \(P\);
6:If\(CL\) is a ConvNet Then
7: MotionRegion = Resize MotionRegion to the size of \(CL\)'s input layer
8:End If
9:CLR = Use \(CL\) to classify Box;
10:IfCLR == BEE Then
11:BeMotionCount = BeeMotionCount + 1;
12:End If
13:End For
14:End For
15:Return BeeMotionCount;
```  
**Algorithm 1**_CountBeeMotion_(Video \(V\), MotionDetector \(MD\), Classifier \(CL\), int \(H\), and int \(W\)).