Disclosure of Invention
Based on the technical problem, the invention provides a method for determining the position of a surface pointer, which is characterized in that the current position of the pointer is identified and positioned from a data image by means of video shooting of a mobile phone, the current position and the angle to be adjusted are sent to a watch through Bluetooth, and the watch is adjusted to the correct position according to an instruction. The accuracy rate is extremely high according to the test at present. The user experience is improved due to the great convenience of the user.
The specific technical scheme of the invention is as follows:
a method of determining the position of a surface pointer, the method comprising the steps of:
the method comprises the following steps that firstly, a camera of a shooting device is used for shooting the surface of a watch in real time to obtain a video;
secondly, the shooting device identifies the video shot by the camera, and the identification is carried out by extracting the image of the video;
thirdly, the shooting device positions the image to enable the image to be positioned in a dial area;
fourthly, the shooting device carries out positioning processing on the pointer in the dial area to obtain a pointer;
and fifthly, the shooting device determines the angle of the pointer deviating from the preset point.
Further, the camera is a mobile phone including a processor and a video camera, and preferably may be a mobile phone with an IOS system.
Further, in the second step, the processor extracts the image of the video according to a rule, specifically: and numbering the image currently being processed as 0, and extracting each frame of image of the video, or extracting the image with odd number or even number, or extracting the image with the number being multiple of 3, or extracting the image with the number being multiple of 4.
Further, in the second step, the extraction is performed according to the processing speed of the processor, and if the current image is not processed, the sent image is skipped over and is not extracted for recognition until the current image is processed and then the first frame image is sent to the processor after the extraction processing is finished.
Further, in the third step, the positioning includes positioning preprocessing, and the positioning preprocessing includes graying the image so that a 1-channel grayscale image is generated from the 4-channel image. When the calculation speed required by the processor is evaluated for multiple times, factors such as light, color and the like are found to have great obstacles to the subsequent extraction of the pointer, so that the conventional 4-channel image is creatively and directly reduced to the 1-channel gray image for processing, the processing speed is high, and the requirement on the performance of the mobile phone is reduced.
Further, Gaussian filtering processing is carried out on the gray level image to obtain a smooth gray level image.
Further, in the third step, after the preprocessing, the hough transform image processing is adopted, the dial is positioned in the grayscale image according to the shape of the dial, so as to obtain a positioning matrix, the positioning matrix is used for cutting the image extracted in the second step, and the area outside the positioning matrix in the image is removed, including the image in the positioning matrix range of the image extracted in the second step, so as to be called as a positioning image.
Further, in the fourth step, the positioning image is subjected to image marginalization processing, so that only lines are left in the positioning image. Since all the hands are straight, only the line needs to be reserved for pertinence.
Further, in the fourth step, a hough transform is adopted to find a straight line, and invalid line segments are filtered.
Further, the method for filtering invalid line segments is as follows: judging the shortest distance H from the central point of the dial to the line segment and the length L of the line segment, wherein the processor stores a first threshold value and a second threshold value:
if the H is smaller than the first threshold value and the L is larger than the second threshold value, the line is judged to be a pointer, and the line segments which are not pointers are filtered.
Further, the second threshold includes a second first threshold and a second threshold:
if the H is smaller than the first threshold value, and the L is larger than the second first threshold value and smaller than the second threshold value, judging that the line is an hour hand pointer;
if the H is smaller than the first threshold value and the L is larger than the second threshold value, judging that the line is a minute hand pointer;
the processor filters out segments that are not pointers.
Further, the second threshold includes a second first threshold, a second threshold, and a second third threshold:
if the H is smaller than the first threshold value, and the L is larger than the second first threshold value and smaller than the second threshold value, judging that the line is an hour hand pointer;
if the H is smaller than the first threshold value, and the L is larger than the second threshold value and smaller than the second third threshold value, judging that the line is a minute hand pointer;
if the H is smaller than the first threshold value and the L is larger than the second third threshold value, judging that the line is a second hand pointer;
the processor filters out segments that are not pointers.
Further, in the fifth step, a color point is preset in the dial, the processor performs color recognition on the positioning image to determine the color point, and calculates an angle between a connecting line of the color point and a center point of the dial and the pointer.
Further, the preset color point is a color point of the 12 o' clock position of the dial.
Further, repeating the second step to the fifth step, processing the subsequent frame images with the third threshold number, calculating the angles of the pointer deviating from the color point to obtain the angles with the third threshold number, and taking the angle with the maximum occurrence probability as the angle of the pointer deviating from the color point.
Further, the third threshold is not less than 10.
Through the technical scheme, firstly, the position of the pointer of the watch on the surface can be accurately calculated in real time, secondly, the requirement on the processor of the mobile phone is not high, asynchronous processing is adopted for identification, the APP of the mobile phone cannot be changed, and moreover, the image frame mode is selectively ignored, so that the low-end mobile phone can express very smoothly even if the image cannot be quickly processed.
Detailed Description
The technical solution of the present invention is explained in detail below.
The invention only needs to solve the algorithm problems of image recognition, noise coming and time calibration and the optimization problem of different requirements of the mobile phone processor.
The extraction of the surface pointer has the image extraction, however, due to the problems of light and color in the image extraction, a single picture is difficult to accurately determine the position of the pointer, and the pointer has a very high possibility to move due to the problem of time intervals in the shooting of multiple pictures.
The invention adopts a mode of extracting pictures from the video, the video has continuity, and a plurality of frames of pictures can be extracted from the video within 1 second, and the position of the pointer is basically unchanged when a plurality of frames are processed.
The specific implementation mode is as follows:
first, the watch surface is photographed in real time using a photographing device, such as a mobile phone, and more preferably, a mobile phone with an IOS system, to obtain a video, and then the video is processed.
When processing a video, the number of frames taken by the video is large, and the processing capability of the processor is limited, and the most ideal state is that the processor performs processing calculation on each frame of image, but actually, when processing an image, the processor is likely to not process the current image when the next frame of image is sent, and at this time, the processor can ignore the sent next frame of image until the processor finishes processing the current image.
Of course, it is also possible to perform forced processing, for example, by numbering the currently processed image as the image No. 0 regularly, numbering the subsequent images by natural numbers, and processing the frame images by taking multiples of 2, 3, or 4. If the current image is not processed, the current processing can be forcibly stopped, and the image sent according to the rule is processed.
After the image is extracted, in order to better position the dial plate and reduce the interference of other factors (such as light and color), the image is grayed, and the original 4-channel image is used for generating a 1-channel grayscale image, so that the requirement on the performance of the mobile phone can be reduced. And performing Gaussian filtering processing on the gray level image to smooth the gray level image.
Due to the fact that the dial plate has particularity and specific geometric figures, the dial plate can be located through Hough transform image processing, for example, when the dial plate is square, a location matrix can be located, and the range in the location matrix is the range of the dial plate. Or, when the dial is circular, a matrix can be located, the range within the matrix being the range of the dial. Even when a square matrix is positioned when the dial is circular, the space between the circles and squares can be filled with all black or all white.
And (3) utilizing the positioning matrix or the edge of the positioning matrix to cut out the extracted image (the image is not the gray image, and is the image with the color extracted from the video), so that the image with the color only has the area of the dial. The cropped image may be defined as the positioning image.
And then, performing marginalization processing on the positioning image to enable the image to only have lines, and searching straight lines by utilizing Hough line transformation, wherein the number of the searched straight lines is very large, and invalid line segments need to be filtered. The filtering method of the invalid line segment is as follows:
the filtering invalidation adopts a method that the shortest distance from the central point of the dial to the line segment is judged to be less than a specific threshold value (adjusted according to the actual condition), and the length of the line segment is more than or equal to a certain threshold value (determined according to the distance length of the dial pointer), so that the filtering invalidation is considered to be effective. Otherwise, the task bar is invalid.
Of course, in the actual operation process, there may be two hands coinciding or substantially coinciding (the two hands deviate by an angle not exceeding 2 degrees or less), and the mobile phone sends a signal to the watch to allow any one of the two hands of the watch to rotate by a certain angle.
During shooting, most of the time, the mobile phone can be used for shooting watches not just opposite to each other, in order to adapt to the condition that the watches are not always in a correct scanning mode, a reference point, such as a reference point in the 12 o 'clock direction, needs to be found for the pointer, and a color point with color, such as red, can be set in the 12 o' clock direction.
The processor judges the position of a color point (red point) by adopting a color identification mode, and confirms that the red point algorithm is that R minus G is more than or equal to 80 and R minus B is more than or equal to 80 according to the RGB values (0-255) of the image pixels, so that the red point is considered as the red point.
The minute hand and the hour hand are distinguished according to the length and the angle of the line segment, the second hand can be distinguished when the second hand exists, and finally the angle of each hand deviating from 12 o' clock is calculated by combining the central point.
The extracted images are calculated once, and after one calculation is finished, the frame images transmitted subsequently are calculated again, for example, 10 times are calculated, and the angle with the highest occurrence probability in the 10 times is taken as the angle of the pointer deviating from the color point. For example, if 14 degrees, 4 degrees and 16 degrees occur 3 times in 10 times, then 15 degrees is taken as the angle of the pointer from the color point.
Through the technical scheme, firstly, the position of the pointer of the watch on the surface can be accurately calculated in real time, secondly, the requirement on the processor of the mobile phone is not high, asynchronous processing is adopted for identification, the APP of the mobile phone cannot be changed, and moreover, the image frame mode is selectively ignored, so that the low-end mobile phone can express very smoothly even if the image cannot be quickly processed.