Sunday, February 23, 2020

Recognition module

Determination the position of hand:

In this part, the requirement is using a rectangle to locate the position of hand. This step is also basic requirement of subsequent recognition because the scaling and application functions both require the position and size of hand.

Algorithm of finding the position of hand is weird but effective. The core of this algorithm is the x, y coordinates and the corresponding value of each pixel. To determine a rectangle area of hand, the minimum and maximum coordinates of x and y axis should be found, hence, there are x_min, x_max, y_min and y_max variables. VGA display module has lcd_x, lcd_y and image_bit to represent the x, y coordinates and RGB data of this pixel. Firstly, at the begining of each frame, x_min will be assigned as the maximum value of horizontal coordinate, x_max is the minimum of horizontal coordinate and same for the y_min and y_max. Then, x and y coordinates of each pixel will be compared with these 4 above position variables if the value of this pixel is 8 b' 1111 1111, furthermore, corresponding x and y coordinates will be assigned to these 4 position variables, for example, if x coordinate is smaller than x_min, then this x coordinate will be assigned to x_min. The purpose of this algorithm is that lcd_x and lcd_y are both increase from 1 and ensure the minimum and maximum variables are assigned as the true minimum and maximum coordinates of this frame. The implementation of this algorithm can be seen in following figure.
Figure 1. Implementation of finding position of hand

Finally, the maximum values and minimum values will be stored firstly and output to VGA display at the end of each frame because the final value can only be determined at the end of each frame, otherwise, the rectangle will move from top to end of the screen. Actual operation of data has been shown in Figure 2.
Figure 2. Operation of final position variables

No comments:

Post a Comment