& lt; code & gt; for (x = 0; x & lt; width; x ++) {offset = x * nchannels; for (y2 = 35; y2 & lt; 46; y2 ++) {uchar * data = (uchar *) (hsv- & gt; imageData + y2 * step); r = data [offset + 2]; g = data [offset + 1]; b = data [offset]; h [y2-35] = b; s [y2-35] = g; v [y2-35] = r; } H [10] = (h [0] + h [1] + h [2] + h [3] + h [4] + h [5] + h [6] + h [7] + h [8 ] + h [9]) / 10; s [10] = (s [0] + s [1] + s [2] + s [3] + s [4] + s [5] + s [6] + s [7] + s [8] + s [9]) / 10; v [10] = (v [0] + v [1] + v [2] + v [3] + v [4] + v [5] + v [6] + v [7] + v [8] + v [9]) / 10; if ((h [10] & lt; h1 & amp; & amp; h [10] & gt; h2) & amp; & amp; (v [10] & gt; ss) & amp; & amp; (s [10] & gt; vv)) {st [x] = 1;} else {st [x] = 0;} & lt; / code & gt; pre>
2. Determination of the left and right boundaries of the zone of intersection.
According to the input array are filled two arrays of the same dimension. Call them st1 and st2. Filling algorithm implemented arrays cycle in which some variable increases linearly if the element of the input array is 1, and exponentially decreases when the element under consideration is equal to 0, and is recorded in the next array element st1. To form the array st2, the input array is viewed from the end. As a result, st1 and st2 arrays can be graphically represented as follows (Fig. 5)
Figure 5 - Graphical representation of arrays st1 and st2.
Useful signal is the most extensive area of color definition. Noise is small false positives, which can be observed on the record figure 7. The coordinates x maximum element red graph (st1), is the right side of a line across the zone of interest. The x coordinate of the maximal element of blue graphics (st2), is the left side of the line across the zone of interest.
Listing
& lt; code & gt; double sum = 1; double sum2 = 1; for (x = 0; x & lt; width; x ++) {if (st [x] == 1) {sum = sum + 1; st1 [x] = sum;} else {sum = sum / 1.05; st1 [x] = sum;} if (st [width-x] == 1) {sum2 = sum2 + 1; st2 [width-x] = sum2;} else {sum2 = sum2 / 1.005; st2 [width-x] = sum2} } & lt; / code & gt; pre>
After the formation of arrays st1 and st2, are the maximal elements of the array, and the calculated center of the intersection zone. By applying the described steps to the second crossing zone, at the outlet, we have coordinates of points through which the shedding.
Applying common way define the zone of confidence in the next frame, as in the previous facility was not used, since such a method and showed acceptable results of noise in the output parameters. Also the use of this method would not decrease CPU usage, since we are dealing only with multiple enumeration of two arrays with a width of 176 pixels, the resolution of all of the image is 176x144 pixels.
1 OFF - hard left. OFF 2 - to the left. OFF 3 - center. OFF 4 - right. OFF 5 - strongly to the right. | 1 Stand - hard left. Stand 2 - left. Stand 3 - center. Stand 4 - right. Stand 5 - hard to the right. | LEV 1 - very weak. LEV 2 - weakly. LEV 3 - medium. LION 4 - strongly LION 5 - very much. | RIGHTS 1 - very weak. Rule 2 - weakly. RIGHTS 3 - medium. RIGHTS 4 - strongly Rule 5 - very Accordingly, these names, considering that the mini-blimp controlled raznotyagom engines establish communication term. block rules:
|