WO2018032630A1 - Teaching toy kit and method for identifying programming module by using color and counter - Google Patents
Teaching toy kit and method for identifying programming module by using color and counter Download PDFInfo
- Publication number
- WO2018032630A1 WO2018032630A1 PCT/CN2016/105740 CN2016105740W WO2018032630A1 WO 2018032630 A1 WO2018032630 A1 WO 2018032630A1 CN 2016105740 W CN2016105740 W CN 2016105740W WO 2018032630 A1 WO2018032630 A1 WO 2018032630A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- image
- module
- programming module
- color
- value
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
-
- G—PHYSICS
- G09—EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
- G09B—EDUCATIONAL OR DEMONSTRATION APPLIANCES; APPLIANCES FOR TEACHING, OR COMMUNICATING WITH, THE BLIND, DEAF OR MUTE; MODELS; PLANETARIA; GLOBES; MAPS; DIAGRAMS
- G09B19/00—Teaching not covered by other main groups of this subclass
- G09B19/22—Games, e.g. card games
Definitions
- the present invention relates to the field of computer vision detection processing technology, and in particular to an educational toy kit and a method for recognizing a programming module using color and contour.
- an educational toy kit has been successfully developed in the field of computer vision and image processing technology, including: a bracket, a helmet detector and a bottom plate, and a game program is installed in the tablet, and is collected on a flat surface by a tablet computer. The image of the bottom plate.
- the educational toy kit mentioned above solves the problem of lack of interaction of games in the tablet computer, the form is still single, and there is no game module corresponding to the game software, the game module cannot be identified, and the upper layer software cannot be provided for subsequent processing and Analysis, it is impossible to cultivate children's understanding and interest in programming from an early age.
- the programming game module is placed on a plane, a game program is installed in the tablet computer, and the camera is captured by a tablet computer camera.
- Data using the color and contour information of the icon on the programming module, identify the programming module in the camera data, and provide the upper layer software for subsequent judgment processing; enhance the fun of the game, children's hands-on ability and interactivity, and cultivate the child well. Programming knowledge and interest.
- the present invention provides an educational toy kit and a method for recognizing a programming module by using a color and a contour.
- the technical solution is as follows:
- An educational toy kit comprising: a bracket, a helmet detector and a programming module, and the helmet detector is mounted on the bracket, the programming module is placed on a plane; the bottom of the bracket has a protrusion, and the top has a first groove and a second groove The first groove is used for placing a tablet computer, and the tablet computer collects programming module information; the helmet detector is installed in the second groove;
- the helmet detector further includes a body, a third groove, two segments and a convex mirror, and the third groove is located in the body for holding different types of tablets, and holding the tablet screen in the third groove
- the end of the convex mirror is provided with a convex mirror
- the other end of the convex mirror is mounted on the edge of the helmet detector
- the convex mirror is at an acute angle with the horizontal plane
- the third groove holds the end of the tablet screen higher than the camera position of the tablet
- the segments are located on the two edges of the convex mirror to hold the convex mirror and hold the tablet.
- each type of programming module has a different color.
- the programming module comprises: a monster module, a jump module, a condition 1 module, a condition 2 module, a small q module, a forward module, a left turn module and a right turn module.
- a method for programming module identification using color and contour information in an educational toy kit comprising the following steps:
- Step one installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
- Step 2 After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
- Step 3 Detect the type of the programming module from the color image of step 2.
- G xy represents the color value of the image pixel in the green channel
- B xy represents the color value of the image pixel in the blue channel.
- the specific steps of detecting the type of the programming module in step three are:
- the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color.
- the space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation.
- the specific conversion formula is:
- V max ⁇ C(R'), C(G'), C(B') ⁇ ;
- H is the tone value
- S is the saturation value
- V is the brightness value
- max ⁇ C(R'), C(G'), C(B') ⁇ means that one pixel is in red and green in the original image.
- the maximum pixel value of the three channels of blue, min ⁇ C(R'), C(G'), C(B') ⁇ indicates that the pixel of one pixel in the original image is the smallest in the three channels of red, green and blue.
- Value, and the value range of H is between 0-360;
- the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space.
- the specific formula is as follows:
- B(x, y) represents the binary pixel value of the image pixel point (x, y)
- H(x, y) S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space
- B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, and V regions, if yes, the value is 1, otherwise the value is 0
- H min and H max respectively represent the hue of the red monster programming module and the skip programming module in the HSV color space.
- S min and S max respectively represent the a priori minimum and maximum values of the saturation of the red monster programming module and the jump programming module in the HSV color space
- V min and V max respectively represent the red monster programming The a priori minimum and maximum values of the brightness of the module and the skip programming module within the HSV color space
- step 5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
- the binarized image can be regarded as a grayscale image with only two values.
- the edge of the image refers to the part of the grayscale image where the grayscale changes are more severe.
- the degree of change of the grayscale value is quantified by the gradient change between adjacent pixels.
- the gradient is a two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value at the (x, y) point of the image
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
- the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module;
- the principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour.
- step 2) Convert the image of the region of interest in step 2) to a grayscale image:
- Gray(x,y) 0.2989 ⁇ R xy +0.5870 ⁇ G xy +0.1140 ⁇ B xy
- Gray(x, y) represents a grayscale image
- the edge of the image refers to the part of the gray image where the gray level changes sharply.
- the degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels.
- the gradient is the two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value of the image at the (x, y) point
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- the edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
- step 9 Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined which programming module belongs to the type other than the monster module and the skip module:
- the binarized image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
- the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour.
- the effective recognition area placed by the programming module in step 2) corresponds to only one identification module.
- step 10 if it is determined that the programming module is a conditional module, the centroid of the edge contour of the programming module is taken and judged. The color of the centroid is compared with the prior knowledge, and the programming module is the condition 1 module or the condition 2 module.
- step 10 if it is determined that the programming module is a turning module, the turning point of the edge contour of the programming module is taken The midpoint of the diagonal point connection is judged by the color of the midpoint, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module.
- the invention intelligently combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed and accurate positioning.
- the hardware and software technology are well unified, the game interaction design is ingenious; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
- the detection algorithm of the invention is more scientific and mature, and the combination of image perspective transformation, color space conversion, contour detection, morphological processing, denoising and the like can quickly determine the type of the programming module.
- the calculation speed of the invention is fast; each positioning detection takes about 100ms, which provides a smooth experience for the player.
- the performance of the invention is stable. In the case of different illumination and different tablet computers installed in the educational toy kit, the collection and test of 3,000 pictures are performed, and the false recognition rate and the missed detection rate are below 0.2%.
- Figure 1 is a schematic view showing the structure of an educational toy kit of the present invention.
- FIG. 2 is a schematic view showing the structure of a helmet detector in an educational toy kit of the present invention.
- FIG. 3 is a flow chart of a method for programming module identification using color and contour information in an educational toy kit of the present invention.
- Bracket 1 first groove 102, second groove 103, helmet detector 2, body 201, third groove 202, sector block 203, mirror 204, programming module 3.
- a method for programming module identification using color and contour information in an educational toy kit includes the following steps:
- Step one installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
- Step 2 After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
- Step 3 detecting the type of the programming module from the color image in step two, the specific steps are:
- the image of the region of interest is extracted in the positive view image, that is, the programming module specifies the placement area given by the upper layer software; the effective recognition region placed by the programming module corresponds to only one identification module;
- the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color.
- the space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation.
- the specific conversion formula is:
- V max ⁇ C(R'), C(G'), C(B') ⁇ ;
- H is the tone value
- S is the saturation value
- V is the brightness value
- max ⁇ C(R'), C(G'), C(B') ⁇ means that one pixel is in red and green in the original image.
- the maximum pixel value of the three channels of blue, min ⁇ C(R'), C(G'), C(B') ⁇ indicates that the pixel of one pixel in the original image is the smallest in the three channels of red, green and blue.
- Value, and the value range of H is between 0-360;
- the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space.
- the specific formula is as follows:
- B(x, y) represents the binary pixel value of the image pixel point (x, y)
- H(x, y) S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space
- B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, V area, if yes, the value is 1, otherwise, the value is 0
- H min , H max respectively represent the red system programming module (monster programming module and jump programming module) in HSV color
- S min and S max respectively represent the minimum and maximum values of the prior saturation of the red monster programming module and the jump programming module in the HSV color space
- V min and V max respectively represent The a priori minimum and maximum values of the brightness of the red monster programming module and the jump programming module within
- step 5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
- the binarized image can be regarded as only two grayscale images.
- the edge of the image refers to the part of the grayscale image where the grayscale changes are more intense.
- the degree of change of the grayscale value is quantified by the gradient change between adjacent pixels.
- the gradient is a two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value at the (x, y) point of the image
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
- the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module;
- the principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour.
- step 2) Convert the image of the region of interest in step 2) to a grayscale image:
- Gray(x,y) 0.2989 ⁇ R xy +0.5870 ⁇ G xy +0.1140 ⁇ B xy
- Gray(x, y) represents a grayscale image
- the edge of the image refers to the part of the gray image where the gray level changes sharply.
- the degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels.
- the gradient is the two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value of the image at the (x, y) point
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- edge detection method can be used to extract the edge represented on the programming module.
- Contour edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
- step 9 Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined that the programming module belongs to any type other than the monster module and the jump module;
- the image of the binary image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
- the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour.
- the programming module is a conditional module
- the centroid of the edge contour of the programming module is taken, the color of the centroid is judged, and then compared with the prior knowledge, and the programming module is a conditional 1 module or a conditional 2 module.
- the turning point of the edge contour of the programming module is taken from the midpoint of the line connecting the diagonal point thereof, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module. .
- the invention skillfully combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed, accurate positioning, and hardware It is well integrated with the software technology, the game interaction design is clever; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
- Figure 1 is a schematic view showing the structure of an educational toy kit of the present invention.
- FIG. 2 is a schematic view showing the structure of a helmet detector in an educational toy kit of the present invention.
- a marine mold recognition method for an educational toy kit includes a bracket 1, a helmet detector 2, and a programming module 3, and the helmet detector 2 is mounted on the bracket 1; the programming module 3 is placed on a plane
- the top of the bracket 1 has a first recess 102 for placing a tablet computer, the tablet computer collects programming module information, and the helmet detector 2 is mounted in the second recess 103
- the helmet detector 2 further includes: a body 201, a third groove 202, two sector blocks 203 and a convex mirror 204, and the third groove 202 is located in the body 201 for clamping different types of tablets, in the The end of the three-groove 202 holding the tablet screen is provided with a convex mirror 204.
- the other end of the convex mirror 204 is mounted on the edge of the helmet detector 2.
- the convex mirror 204 is at an acute angle with the horizontal plane, and the third recess 202 is clamped.
- the end of the tablet screen is higher than the camera position of the tablet, and two sectors 203 are located on the two edges of the convex mirror 204 for fixing the convex mirror 204 and holding the tablet.
- FIG. 3 is a flow chart of a method for programming module identification using color and contour information in an educational toy kit of the present invention.
- a method for programming module identification using color and contour information in an educational toy kit includes the following steps:
- Step one installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
- Step 2 After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
- Step 3 detecting the type of the programming module from the color image in step two, the specific steps are:
- the image of the region of interest is extracted in the positive view image, that is, the programming module specifies the placement area given by the upper layer software; the effective recognition region placed by the programming module corresponds to only one identification module;
- the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color.
- the space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation.
- the specific conversion formula is:
- V max ⁇ C(R'), C(G'), C(B') ⁇ ;
- H is the tone value
- S is the saturation value
- V is the brightness value
- max ⁇ C(R'), C(G'), C(B') ⁇ means that one pixel is in red and green in the original image.
- blue three channel image The prime value, min ⁇ C(R'), C(G'), C(B') ⁇ represents the pixel minimum of one pixel in the original image in red, green and blue, and the H is taken The value range is between 0-360;
- the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space.
- the specific formula is as follows:
- B(x, y) represents the binary pixel value of the image pixel point (x, y)
- H(x, y) S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space
- B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, V area, if yes, the value is 1, otherwise, the value is 0
- H min , H max respectively represent the red system programming module (monster programming module and jump programming module) in HSV color
- S min and S max respectively represent the minimum and maximum values of the prior saturation of the red monster programming module and the jump programming module in the HSV color space
- V min and V max respectively represent The a priori minimum and maximum values of the brightness of the red monster programming module and the jump programming module within
- step 5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
- the binarized image can be regarded as only two grayscale images.
- the edge of the image refers to the part of the grayscale image where the grayscale changes are more intense.
- the degree of change of the grayscale value is quantified by the gradient change between adjacent pixels.
- the gradient is a two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value at the (x, y) point of the image
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
- the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module;
- the principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour.
- step 2) Convert the image of the region of interest in step 2) to a grayscale image:
- Gray(x,y) 0.2989 ⁇ R xy +0.5870 ⁇ G xy +0.1140 ⁇ B xy
- Gray(x, y) represents a grayscale image
- the edge of the image refers to the part of the gray image where the gray level changes sharply.
- the degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels.
- the gradient is the two-dimensional equivalent of the first-order two-dimensional derivative.
- G x represents the difference of adjacent pixels in the x direction
- G y represents the difference of adjacent pixels in the y direction
- f[i, j+1] represents the pixel value of the image in the i th row and j+1th column.
- f[i,j] represents the pixel value of the image in the i-th row and the j-th column
- f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column
- G(x, y) represents the gradient value of the image at the (x, y) point
- the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
- edge detection method can be used to extract the edge represented on the programming module.
- Contour edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
- step 9 Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined that the programming module belongs to any type other than the monster module and the jump module;
- the image of the binary image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
- the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour.
- the programming module is a conditional module
- the centroid of the edge contour of the programming module is taken, the color of the centroid is judged, and then compared with the prior knowledge, and the programming module is a conditional 1 module or a conditional 2 module.
- the turning point of the edge contour of the programming module is taken from the midpoint of the line connecting the diagonal point thereof, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module. .
- the invention skillfully combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed, accurate positioning, and hardware It is well integrated with the software technology, the game interaction design is clever; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
- the detection algorithm of the invention is more scientific and mature, and combines the perspective transformation of the image, the color space conversion, the contour detection, the morphological processing, the denoising and the like, and can quickly determine the type of the programming module.
- the calculation speed of the invention is fast; each positioning detection takes about 100ms, which provides a smooth experience for the player.
- the performance of the invention is stable, and in the case of different illumination and different tablet computers installed in the educational toy kit, the collection and test are performed on 3,000 pictures, and the false recognition rate and the missed detection rate are below 0.2%.
Landscapes
- Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Multimedia (AREA)
- Entrepreneurship & Innovation (AREA)
- Physics & Mathematics (AREA)
- Educational Administration (AREA)
- Educational Technology (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
Description
本发明涉及计算机视觉检测处理技术领域,特别涉及一种教育玩具套件及利用颜色和轮廓识别编程模块的方法。The present invention relates to the field of computer vision detection processing technology, and in particular to an educational toy kit and a method for recognizing a programming module using color and contour.
现在平板电脑上有许多有趣的幼教游戏应用程序或者儿童游戏,但往往只是让小朋友在屏幕上指指画画,互动性欠缺,长时间看着屏幕容易对眼睛造成伤害;而当下一些互动性强的传统性游戏玩具已经脱离了时代的发展,形式上无法满足孩子学习、玩耍的需求,也不便于孩子和家长的互动沟通。There are many interesting preschool game apps or children's games on the tablet, but often just let the children point finger on the screen, the interaction is lacking, and watching the screen for a long time is easy to cause damage to the eyes; and now some interactive Traditional game toys have been separated from the development of the times, and the form cannot meet the needs of children to learn and play, and it is not convenient for children and parents to interact.
为了解决上述问题,计算机视觉与图像处理技术领域成功地开发了一种教育玩具套件,包括:支架、头盔探测器和底板,在平板电脑内安装游戏程序,通过平板电脑的摄像头采集放置于平面上的底板的图像。In order to solve the above problems, an educational toy kit has been successfully developed in the field of computer vision and image processing technology, including: a bracket, a helmet detector and a bottom plate, and a game program is installed in the tablet, and is collected on a flat surface by a tablet computer. The image of the bottom plate.
上述的教育玩具套件虽然解决了平板电脑中游戏的互动性欠缺的问题,但是形式仍然单一,没有游戏软件相对应的游戏模块,无法对游戏模块进行识别,亦无法提供给上层软件进行后续处理和分析,无法做到从小培养小朋友对编程的认识和兴趣。Although the educational toy kit mentioned above solves the problem of lack of interaction of games in the tablet computer, the form is still single, and there is no game module corresponding to the game software, the game module cannot be identified, and the upper layer software cannot be provided for subsequent processing and Analysis, it is impossible to cultivate children's understanding and interest in programming from an early age.
因此,计算机视觉检测处理技术领域急需一种教育玩具套件及利用颜色和轮廓识别编程模块的方法,是将编程游戏模块放置于平面上,在平板电脑内安装游戏程序,通过平板电脑的摄像头采集摄像头数据,利用编程模块上图标的颜色和轮廓信息,在摄像头数据中识别编程模块,并提供给上层软件做后续判断处理;增强游戏的趣味性、儿童动手能力以及互动性,良好的培养了孩子对于编程的认识和兴趣。Therefore, there is an urgent need in the field of computer vision detection processing technology for an educational toy kit and a method for recognizing a programming module by using a color and contour. The programming game module is placed on a plane, a game program is installed in the tablet computer, and the camera is captured by a tablet computer camera. Data, using the color and contour information of the icon on the programming module, identify the programming module in the camera data, and provide the upper layer software for subsequent judgment processing; enhance the fun of the game, children's hands-on ability and interactivity, and cultivate the child well. Programming knowledge and interest.
本发明为了解决上述问题,提供了一种教育玩具套件及利用颜色和轮廓识别编程模块的方法,技术方案如下:In order to solve the above problems, the present invention provides an educational toy kit and a method for recognizing a programming module by using a color and a contour. The technical solution is as follows:
一种教育玩具套件,包括:支架、头盔探测器和编程模块,并且头盔探测器安装于支架上,编程模块放置于平面上;支架底部具有凸起,顶部具有第一凹槽和第二凹槽,第一凹槽用于放置平板电脑,平板电脑采集编程模块信息;头盔探测器安装于第二凹槽内; An educational toy kit comprising: a bracket, a helmet detector and a programming module, and the helmet detector is mounted on the bracket, the programming module is placed on a plane; the bottom of the bracket has a protrusion, and the top has a first groove and a second groove The first groove is used for placing a tablet computer, and the tablet computer collects programming module information; the helmet detector is installed in the second groove;
头盔探测器,还包括本体、第三凹槽、2个扇形块和凸面镜,并且第三凹槽位于本体内,用于夹持不同型号的平板电脑,在第三凹槽夹持平板电脑屏幕的端点处设置有凸面镜,凸面镜的另一端安装于头盔探测器边缘上,凸面镜与水平面夹角成锐角,第三凹槽夹持平板电脑屏幕的端点高于平板电脑的摄像头位置,2个扇形块位于凸面镜的2个边缘上,用于固定凸面镜和夹持平板电脑。The helmet detector further includes a body, a third groove, two segments and a convex mirror, and the third groove is located in the body for holding different types of tablets, and holding the tablet screen in the third groove The end of the convex mirror is provided with a convex mirror, the other end of the convex mirror is mounted on the edge of the helmet detector, the convex mirror is at an acute angle with the horizontal plane, and the third groove holds the end of the tablet screen higher than the camera position of the tablet, 2 The segments are located on the two edges of the convex mirror to hold the convex mirror and hold the tablet.
优选的,在上述的一种教育玩具套件中,编程模块的类型为8种,每种类型的编程模块颜色不同。Preferably, in one of the educational toy kits described above, there are eight types of programming modules, and each type of programming module has a different color.
优选的,在上述的一种教育玩具套件中,编程模块包括:怪兽模块、跳跃模块、条件1模块、条件2模块、小q模块、向前模块、左转模块和右转模块。Preferably, in the above educational toy kit, the programming module comprises: a monster module, a jump module, a
一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法,包括如下步骤:A method for programming module identification using color and contour information in an educational toy kit, comprising the following steps:
步骤一,在平板电脑中安装游戏程序,编程模块放置于平面上,平板电脑的底端安装于第一凹槽内,通过第二凹槽将头盔探测器安装于平板电脑的顶端;Step one, installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
步骤二,固定安装好后,通过平板电脑的前置摄像头实时采集彩色图像;Step 2: After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
步骤三,从步骤二的彩色图像中检测编程模块的类型。Step 3: Detect the type of the programming module from the color image of
优选的,在上述的一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法中,步骤二中前置摄像头采集的彩色图像为Ixy,Ixy=f(x,y)=(Rxy,Gxy,Bxy),其中,(x,y)表示彩色图像像素点的位置坐标,f(x,y)表示图像在像素点坐标位置处的像素值,Rxy表示图像像素点在红色通道的色彩值,Gxy表示图像像素点在绿色通道的色彩值,Bxy表示图像像素点在蓝色通道的色彩值。Preferably, in the above method for educational module identification using color and contour information in an educational toy kit, the color image acquired by the front camera in
优选的,在上述的一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法中,步骤三中检测编程模块类型的具体步骤为:Preferably, in the above method for educational module identification using color and contour information in an educational toy kit, the specific steps of detecting the type of the programming module in step three are:
1)采用透视变换原理,将彩色图像Ixy转换成由上而下俯视的正视角图像;1) using a perspective transformation principle, converting the color image I xy into a front view image viewed from top to bottom;
2)根据先验知识,在正视角图像中提取出感兴趣区域图像,即上层软件给出的编程模块指定放置区域;2) extracting the image of the region of interest in the positive view image according to the prior knowledge, that is, the designated placement area of the programming module given by the upper layer software;
3)因为怪兽和跳跃模块在颜色上均属于红色系,与其他模块的色系区分度较大,因此,先用颜色将这两个模块与其他模块区分开;但是编程模块的颜色在RGB颜色空间内不利于分割开来,对光照变化也比较敏感,所以,将提取出来的感兴趣区域图像由RGB颜色空间转换到侧重于色彩表示的HSV颜色空间,具体转换公式为:3) Because the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color. The space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation. The specific conversion formula is:
V=max{C(R′)、C(G′)、C(B′)}; V=max{C(R'), C(G'), C(B')};
其中,H表示色调值,S表示饱和度值,V表示亮度值,max{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像素最大值,min{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像素最小值,并且H的取值范围位于0-360之间;Where H is the tone value, S is the saturation value, V is the brightness value, and max{C(R'), C(G'), C(B')} means that one pixel is in red and green in the original image. The maximum pixel value of the three channels of blue, min{C(R'), C(G'), C(B')} indicates that the pixel of one pixel in the original image is the smallest in the three channels of red, green and blue. Value, and the value range of H is between 0-360;
4)在HSV颜色空间内,根据红色系的怪兽模块和跳跃模块在HSV空间内的先验阈值,将彩色图像进行二值化处理,具体公式如下:4) In the HSV color space, the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space. The specific formula is as follows:
通过公式B(x,y)=B_H(x,y)&B_S(x,y)&B_V(x,y)可获得对应的二进制图像。A corresponding binary image can be obtained by the formula B(x, y) = B_H(x, y) & B_S(x, y) & B_V(x, y).
其中,B(x,y)表示图像像素点(x,y)的二进制像素值,H(x,y)、S(x,y)、V(x,y)分别表示图像像素点(x,y)在HSV颜色空间内的色调值、饱和度值、亮度值;B_H(x,y)、B_S(x,y)、B_V(x,y)分别表示图像像素点(x,y)是否分别在指定的H、S、V区域内,如果是,则取值为1,否则取值为0;Hmin、Hmax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的色调的先验最小和最大值;Smin、Smax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的饱和度的先验最小和最大值;Vmin、Vmax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的亮度的先验最小和最大值; Where B(x, y) represents the binary pixel value of the image pixel point (x, y), and H(x, y), S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space; B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, and V regions, if yes, the value is 1, otherwise the value is 0; H min and H max respectively represent the hue of the red monster programming module and the skip programming module in the HSV color space. The a priori minimum and maximum values; S min and S max respectively represent the a priori minimum and maximum values of the saturation of the red monster programming module and the jump programming module in the HSV color space; V min and V max respectively represent the red monster programming The a priori minimum and maximum values of the brightness of the module and the skip programming module within the HSV color space;
5)采用先腐蚀后膨胀的方法去除步骤4)中二值化图像的噪音干扰,并且平滑物体边界;5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
6)扫描二值化图像,找出所有边缘轮廓;6) Scan the binarized image to find all edge contours;
二值化图像可以看作是只有两个值的灰度图像,图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The binarized image can be regarded as a grayscale image with only two values. The edge of the image refers to the part of the grayscale image where the grayscale changes are more severe. The degree of change of the grayscale value is quantified by the gradient change between adjacent pixels. The gradient is a two-dimensional equivalent of the first-order two-dimensional derivative. The specific calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j]G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示表示图像的在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value at the (x, y) point of the image, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
进一步地,根据怪兽模快、跳跃模块边缘轮廓的大小和离心率的先验知识,滤掉不合理的边缘轮廓,再对剩余的轮廓进行判定,进而得出该编程模块是否为怪兽模快或者跳跃模块,如果是则完成编程模块判定,如果不是则继续执行步骤7);Further, according to the prior knowledge of the monster mode, the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
其中,怪兽模快的判定原则为:利用边缘轮廓的形状、大小、离心率和怪兽模块独有的3个小三角形的位置及大小关系的先验知识,来判定编程模块是否为怪兽模块;跳跃模块的判定原则为:将边缘轮廓的最小外包矩形分割成四等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块是否为跳跃模块; Among them, the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module; The principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour. a priori knowledge of the scale and a priori knowledge of the size and eccentricity of the entire edge contour to determine if the programming module is a jump module;
7)将步骤2)中的感兴趣区域图像转换为灰度图像:7) Convert the image of the region of interest in step 2) to a grayscale image:
Gray(x,y)=0.2989×Rxy+0.5870×Gxy+0.1140×Bxy Gray(x,y)=0.2989×R xy +0.5870×G xy +0.1140×B xy
其中,Gray(x,y)表示灰度图像;Where Gray(x, y) represents a grayscale image;
8)采用边缘检测算法检测图像中的强边缘;8) using edge detection algorithm to detect strong edges in the image;
图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The edge of the image refers to the part of the gray image where the gray level changes sharply. The degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels. The gradient is the two-dimensional equivalent of the first-order two-dimensional derivative. The calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j]G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示图像在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value of the image at the (x, y) point, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
由于待检测的编程模块目标,在转换为灰度图后,编程模块上的标识与编程模块上的白色区域存在较大的反差,因此可以利用边缘检测的方法提取出编程模块上标识的边缘轮廓;边缘提取算法包括Sobel算子、Roberts算子、Prewitt算子和Canny算子等,具体公式为:Due to the programming module target to be detected, after conversion to the grayscale image, there is a large contrast between the identification on the programming module and the white area on the programming module, so the edge detection can be used to extract the edge contour identified on the programming module. The edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
其中,|G(x,y)|表示边缘点的梯度幅值;Where |G(x,y)| represents the gradient magnitude of the edge point;
9)对步骤8)中得出的编程模块边缘轮廓进行膨胀处理; 9) expanding the edge contour of the programming module obtained in step 8);
10)扫描步骤9)中的二值化图像,由于当前编程模块属于非红色系的,因此,判断编程模块属于除了怪兽模块、跳跃模块之外的哪种类型:10) Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined which programming module belongs to the type other than the monster module and the skip module:
首先,对步骤9)中得到的二值化图像进行扫描,得到相应的边缘轮廓,通过边缘轮廓的大小和离心率的先验知识,滤掉不合理的轮廓;First, the binarized image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
进一步地,将过滤后剩余的边缘轮廓的最小外接矩形分割成4等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块的类型。Further, the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour The a priori knowledge of the ratio and the prior knowledge of the size and eccentricity of the entire edge profile to determine the type of programming module.
优选的,在上述的一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法中,步骤2)中编程模块放置的有效识别区域只对应一个识别模块。Preferably, in the method for programming module identification using color and contour information in an educational toy kit as described above, the effective recognition area placed by the programming module in step 2) corresponds to only one identification module.
优选的,在上述的一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法中,步骤10)中,如果判断出编程模块为条件模块,则取该编程模块边缘轮廓的质心,判断质心的颜色,再与先验知识进行比对,得出编程模块为条件1模块或者条件2模块。Preferably, in the method for using the color and contour information to perform programming module identification in the above educational toy kit, in step 10), if it is determined that the programming module is a conditional module, the centroid of the edge contour of the programming module is taken and judged. The color of the centroid is compared with the prior knowledge, and the programming module is the
优选的,在上述的一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法中,步骤10)中,如果判断出编程模块为转弯模块,则取该编程模块边缘轮廓的转弯点与其对角点连线的中点,判断该中点的颜色,再与先验知识进行比对,得出编程模块为左转模块或者右转模块。Preferably, in the method for identifying the programming module by using color and contour information in the above educational toy kit, in step 10), if it is determined that the programming module is a turning module, the turning point of the edge contour of the programming module is taken The midpoint of the diagonal point connection is judged by the color of the midpoint, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module.
1、本发明巧妙的将应用计算机视觉图形识别技术与HSV颜色空间、二值化处理、灰度图像、图像切割技术相结合使用,能够判断出编程模块的类型,具有运算速度快,定位准确,将硬件与软件技术很好地统一起来,游戏交互设计巧妙;美观简单,判断更加快速,同时增强了趣味性和直观性。1. The invention intelligently combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed and accurate positioning. The hardware and software technology are well unified, the game interaction design is ingenious; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
2、本发明检测算法更加科学、成熟,将图像的透视变换、色彩空间转换、轮廓检测、形态学处理、去噪等算法相结合使用,能够快速的判断出编程模块的类型。2. The detection algorithm of the invention is more scientific and mature, and the combination of image perspective transformation, color space conversion, contour detection, morphological processing, denoising and the like can quickly determine the type of the programming module.
3、本发明计算速度快;每次定位检测耗时在100ms左右,为玩家提供流畅的使用体验。3. The calculation speed of the invention is fast; each positioning detection takes about 100ms, which provides a smooth experience for the player.
4、本发明性能稳定,在不同光照、对不同平板电脑安装于教育玩具套件内的情况下,针对3千幅图片进行了采集测试,误识别率和漏检率在0.2%以下。4. The performance of the invention is stable. In the case of different illumination and different tablet computers installed in the educational toy kit, the collection and test of 3,000 pictures are performed, and the false recognition rate and the missed detection rate are below 0.2%.
下面结合附图和具体实施方式来详细说明本发明:The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
图1是本发明一种教育玩具套件的结构示意图。BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a schematic view showing the structure of an educational toy kit of the present invention.
图2是本发明一种教育玩具套件中头盔探测器的结构示意图。2 is a schematic view showing the structure of a helmet detector in an educational toy kit of the present invention.
图3是本发明一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法的流程图。3 is a flow chart of a method for programming module identification using color and contour information in an educational toy kit of the present invention.
其中,图1-3中的附图标记与部件名称之间的对应关系为:The correspondence between the reference numerals in Figure 1-3 and the part names is:
支架1,第一凹槽102,第二凹槽103,头盔探测器2,本体201,第三凹槽202,扇形块203,反光镜204,,编程模块3。
如图3所示,一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法,包括如下步骤:As shown in FIG. 3, a method for programming module identification using color and contour information in an educational toy kit includes the following steps:
步骤一,在平板电脑中安装游戏程序,编程模块放置于平面上,平板电脑的底端安装于第一凹槽内,通过第二凹槽将头盔探测器安装于平板电脑的顶端;Step one, installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
步骤二,固定安装好后,通过平板电脑的前置摄像头实时采集彩色图像;Step 2: After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
前置摄像头采集的彩色图像为Ixy,Ixy=f(x,y)=(Rxy,Gxy,Bxy),其中,(x,y)表示彩色图像像素点的位置坐标,f(x,y)表示图像在像素点坐标位置处的像素值,Rxy表示图像像素点在红色通道的色彩值,Gxy表示图像像素点在绿色通道的色彩值,Bxy表示图像像素点在蓝色通道的色彩值。The color image acquired by the front camera is I xy , I xy =f(x,y)=(R xy , G xy , B xy ), where (x, y) represents the position coordinate of the pixel of the color image, f( x, y) represents the pixel value of the image at the pixel point coordinate position, R xy represents the color value of the image pixel point in the red channel, G xy represents the color value of the image pixel point in the green channel, and B xy represents the image pixel point in the blue The color value of the color channel.
步骤三,从步骤二的彩色图像中检测编程模块的类型,具体步骤为:Step 3: detecting the type of the programming module from the color image in step two, the specific steps are:
1)采用透视变换原理,将彩色图像Ixy转换成由上而下俯视的正视角图像;1) using a perspective transformation principle, converting the color image I xy into a front view image viewed from top to bottom;
2)根据先验知识,在正视角图像中提取出感兴趣区域图像,即上层软件给出的编程模块指定放置区域;编程模块放置的有效识别区域只对应一个识别模块;2) According to the prior knowledge, the image of the region of interest is extracted in the positive view image, that is, the programming module specifies the placement area given by the upper layer software; the effective recognition region placed by the programming module corresponds to only one identification module;
3)因为怪兽和跳跃模块在颜色上均属于红色系,与其他模块的色系区分度较大,因此,先用颜色将这两个模块与其他模块区分开;但是编程模块的颜色在RGB颜色空间内不利于分割开来,对光照变化也比较敏感,所以,将提取出来的感兴趣区域图像由RGB颜色空间转换到侧重于色彩表示的HSV颜色空间,具体转换公式为:3) Because the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color. The space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation. The specific conversion formula is:
V=max{C(R′)、C(G′)、C(B′)};V=max{C(R'), C(G'), C(B')};
其中,H表示色调值,S表示饱和度值,V表示亮度值,max{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像素最大值,min{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像素最小值,并且H的取值范围位于0-360之间;Where H is the tone value, S is the saturation value, V is the brightness value, and max{C(R'), C(G'), C(B')} means that one pixel is in red and green in the original image. The maximum pixel value of the three channels of blue, min{C(R'), C(G'), C(B')} indicates that the pixel of one pixel in the original image is the smallest in the three channels of red, green and blue. Value, and the value range of H is between 0-360;
4)在HSV颜色空间内,根据红色系的怪兽模块和跳跃模块在HSV空间内的先验阈值,将彩色图像进行二值化处理,具体公式如下:4) In the HSV color space, the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space. The specific formula is as follows:
通过公式B(x,y)=B_H(x,y)&B_S(x,y)&B_V(x,y)获得对应的二进制图像;Obtaining a corresponding binary image by the formula B(x, y)=B_H(x,y)&B_S(x,y)&B_V(x,y);
其中,B(x,y)表示图像像素点(x,y)的二进制像素值,H(x,y)、S(x,y)、V(x,y)分别表示图像像素点(x,y)在HSV颜色空间内的色调值、饱和度值、亮度值;B_H(x,y)、B_S(x,y)、B_V(x,y)分别表示图像像素点(x,y)是否分别在指定的H、S、V区域内,如果是,则取值为1,否则,取值为0;Hmin、Hmax分别表示红色系编程模块(怪兽编程模块和跳跃编程模块)在HSV颜色空间内的色调的先验最小和最大值;Smin、Smax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的先验饱和度最小和最大值;Vmin、Vmax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的亮度的先验最小和最大值;Where B(x, y) represents the binary pixel value of the image pixel point (x, y), and H(x, y), S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space; B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, V area, if yes, the value is 1, otherwise, the value is 0; H min , H max respectively represent the red system programming module (monster programming module and jump programming module) in HSV color The a priori minimum and maximum values of the hue in the space; S min and S max respectively represent the minimum and maximum values of the prior saturation of the red monster programming module and the jump programming module in the HSV color space; V min and V max respectively represent The a priori minimum and maximum values of the brightness of the red monster programming module and the jump programming module within the HSV color space;
5)采用先腐蚀后膨胀的方法去除步骤4)中二值化图像的噪音干扰,并且平滑物体边界;5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
6)扫描二值化图像,找出所有边缘轮廓; 6) Scan the binarized image to find all edge contours;
二值化图像可以看作是只有两个值得灰度图像,图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The binarized image can be regarded as only two grayscale images. The edge of the image refers to the part of the grayscale image where the grayscale changes are more intense. The degree of change of the grayscale value is quantified by the gradient change between adjacent pixels. The gradient is a two-dimensional equivalent of the first-order two-dimensional derivative. The specific calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j]G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示表示图像的在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value at the (x, y) point of the image, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
进一步地,根据怪兽模快、跳跃模块边缘轮廓的大小和离心率的先验知识,滤掉不合理的边缘轮廓,再对剩余的轮廓进行判定,进而得出该编程模块是否为怪兽模快或者跳跃模块,如果是则完成编程模块判定,如果不是则继续执行步骤7);Further, according to the prior knowledge of the monster mode, the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
其中,怪兽模快的判定原则为:利用边缘轮廓的形状、大小、离心率和怪兽模块独有的3个小三角形的位置及大小关系的先验知识,来判定编程模块是否为怪兽模块;跳跃模块的判定原则为:将边缘轮廓的最小外包矩形分割成四等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块是否为跳跃模块;Among them, the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module; The principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour. a priori knowledge of the scale and a priori knowledge of the size and eccentricity of the entire edge contour to determine if the programming module is a jump module;
7)将步骤2)中的感兴趣区域图像转换为灰度图像:7) Convert the image of the region of interest in step 2) to a grayscale image:
Gray(x,y)=0.2989×Rxy+0.5870×Gxy+0.1140×Bxy Gray(x,y)=0.2989×R xy +0.5870×G xy +0.1140×B xy
其中,Gray(x,y)表示灰度图像;Where Gray(x, y) represents a grayscale image;
8)采用边缘检测算法检测图像中的强边缘; 8) using edge detection algorithm to detect strong edges in the image;
图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The edge of the image refers to the part of the gray image where the gray level changes sharply. The degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels. The gradient is the two-dimensional equivalent of the first-order two-dimensional derivative. The calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j]G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示图像在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value of the image at the (x, y) point, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
由于待检测的编程模块目标,在转换为灰度图后,编程模块上的标识与编程模块上的白色区域存在较大的反差,因此,可以利用边缘检测的方法提取出编程模块上表示的边缘轮廓;边缘提取算法包括Sobel算子、Roberts算子、Prewitt算子和Canny算子等,具体公式为:Due to the programming module target to be detected, after conversion to the grayscale image, there is a large contrast between the identification on the programming module and the white area on the programming module. Therefore, the edge detection method can be used to extract the edge represented on the programming module. Contour; edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
其中,|G(x,y)|表示边缘点的梯度幅值;Where |G(x,y)| represents the gradient magnitude of the edge point;
9)对步骤8)中得出的编程模块边缘轮廓进行膨胀处理;9) expanding the edge contour of the programming module obtained in step 8);
10)扫描步骤9)中的二值化图像,由于当前编程模块属于非红色系的,因此,判断编程模块属于除了怪兽模块、跳跃模块之外的哪种类型;10) Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined that the programming module belongs to any type other than the monster module and the jump module;
首先,对步骤9)中得到的二化值图像进行扫描,得到相应的边缘轮廓,通过边缘轮廓的大小和离心率的先验知识,滤掉不合理的轮廓; First, the image of the binary image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
进一步地,将过滤后剩余的边缘轮廓的最小外接矩形分割成4等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块的类型。Further, the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour The a priori knowledge of the ratio and the prior knowledge of the size and eccentricity of the entire edge profile to determine the type of programming module.
如果判断出编程模块为条件模块,则取该编程模块边缘轮廓的质心,判断质心的颜色,再与先验知识进行比对,得出编程模块为条件1模块或者条件2模块。If it is determined that the programming module is a conditional module, the centroid of the edge contour of the programming module is taken, the color of the centroid is judged, and then compared with the prior knowledge, and the programming module is a conditional 1 module or a conditional 2 module.
如果判断出编程模块为转弯模块,则取该编程模块边缘轮廓的转弯点与其对角点连线的中点,再与先验知识进行比对,得出编程模块为左转模块或者右转模块。If it is determined that the programming module is a turning module, the turning point of the edge contour of the programming module is taken from the midpoint of the line connecting the diagonal point thereof, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module. .
本发明巧妙的将应用计算机视觉图形识别技术与HSV颜色空间、二值化处理、灰度图像、图像切割技术相结合使用,能够判断出编程模块的类型,具有运算速度快,定位准确,将硬件与软件技术很好地统一起来,游戏交互设计巧妙;美观简单,判断更加快速,同时增强了趣味性和直观性。The invention skillfully combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed, accurate positioning, and hardware It is well integrated with the software technology, the game interaction design is clever; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
为了使本发明技术实现的措施、创作特征、达成目的与功效易于明白了解,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. The described embodiments are only a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
实施例1:Example 1:
图1是本发明一种教育玩具套件的结构示意图。BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 is a schematic view showing the structure of an educational toy kit of the present invention.
图2是本发明一种教育玩具套件中头盔探测器的结构示意图。2 is a schematic view showing the structure of a helmet detector in an educational toy kit of the present invention.
如图1-2所示,一种教育玩具套件的海洋模具识别方法,包括支架1、头盔探测器2、和编程模块3,并且头盔探测器2安装于支架1上;编程模块3放置于平面上;支架1,顶部具有第一凹槽102和第二凹槽103,第一凹槽102用于放置平板电脑,平板电脑采集编程模块信息;头盔探测器2,安装于第二凹槽103内;头盔探测器2还包括:本体201、第三凹槽202、2个扇形块203和凸面镜204,并且第三凹槽202位于本体201内,用于夹持不同型号的平板电脑,在第三凹槽202夹持平板电脑屏幕的端点处设置有凸面镜204,凸面镜204的另一端安装于头盔探测器2边缘上,凸面镜204与水平面夹角成锐角,第三凹槽202夹持平板电脑屏幕的端点高于平板电脑的摄像头位置,2个扇形块203位于凸面镜204的2个边缘上,用于固定凸面镜204和夹持平板电脑。
As shown in FIG. 1-2, a marine mold recognition method for an educational toy kit includes a
图3是本发明一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法的流程图。3 is a flow chart of a method for programming module identification using color and contour information in an educational toy kit of the present invention.
如图3所示,一种教育玩具套件中利用颜色和轮廓信息进行编程模块识别的方法,包括如下步骤:As shown in FIG. 3, a method for programming module identification using color and contour information in an educational toy kit includes the following steps:
步骤一,在平板电脑中安装游戏程序,编程模块放置于平面上,平板电脑的底端安装于第一凹槽内,通过第二凹槽将头盔探测器安装于平板电脑的顶端;Step one, installing a game program in the tablet, the programming module is placed on the plane, the bottom end of the tablet is installed in the first groove, and the helmet detector is installed on the top of the tablet through the second groove;
步骤二,固定安装好后,通过平板电脑的前置摄像头实时采集彩色图像;Step 2: After the fixed installation, the color image is collected in real time through the front camera of the tablet computer;
前置摄像头采集的彩色图像为Ixy,Ixy=f(x,y)=(Rxy,Gxy,Bxy),其中,(x,y)表示彩色图像像素点的位置坐标,f(x,y)表示图像在像素点坐标位置处的像素值,Rxy表示图像像素点在红色通道的色彩值,Gxy表示图像像素点在绿色通道的色彩值,Bxy表示图像像素点在蓝色通道的色彩值。The color image acquired by the front camera is I xy , I xy =f(x,y)=(R xy , G xy , B xy ), where (x, y) represents the position coordinate of the pixel of the color image, f( x, y) represents the pixel value of the image at the pixel point coordinate position, R xy represents the color value of the image pixel point in the red channel, G xy represents the color value of the image pixel point in the green channel, and B xy represents the image pixel point in the blue The color value of the color channel.
步骤三,从步骤二的彩色图像中检测编程模块的类型,具体步骤为:Step 3: detecting the type of the programming module from the color image in step two, the specific steps are:
1)采用透视变换原理,将彩色图像Ixy转换成由上而下俯视的正视角图像;1) using a perspective transformation principle, converting the color image I xy into a front view image viewed from top to bottom;
2)根据先验知识,在正视角图像中提取出感兴趣区域图像,即上层软件给出的编程模块指定放置区域;编程模块放置的有效识别区域只对应一个识别模块;2) According to the prior knowledge, the image of the region of interest is extracted in the positive view image, that is, the programming module specifies the placement area given by the upper layer software; the effective recognition region placed by the programming module corresponds to only one identification module;
3)因为怪兽和跳跃模块在颜色上均属于红色系,与其他模块的色系区分度较大,因此,先用颜色将这两个模块与其他模块区分开;但是编程模块的颜色在RGB颜色空间内不利于分割开来,对光照变化也比较敏感,所以,将提取出来的感兴趣区域图像由RGB颜色空间转换到侧重于色彩表示的HSV颜色空间,具体转换公式为:3) Because the monster and the jump module are red in color, they are more distinguishable from the colors of other modules. Therefore, the two modules are first distinguished from other modules by color; however, the color of the programming module is in RGB color. The space is not conducive to segmentation, and is sensitive to illumination changes. Therefore, the extracted region of interest image is converted from the RGB color space to the HSV color space that focuses on the color representation. The specific conversion formula is:
V=max{C(R′)、C(G′)、C(B′)};V=max{C(R'), C(G'), C(B')};
其中,H表示色调值,S表示饱和度值,V表示亮度值,max{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像 素最大值,min{C(R′)、C(G′)、C(B′)}表示在原始图像中一个像素点在红、绿、蓝三个通道的像素最小值,并且H的取值范围位于0-360之间;Where H is the tone value, S is the saturation value, V is the brightness value, and max{C(R'), C(G'), C(B')} means that one pixel is in red and green in the original image. , blue three channel image The prime value, min{C(R'), C(G'), C(B')} represents the pixel minimum of one pixel in the original image in red, green and blue, and the H is taken The value range is between 0-360;
4)在HSV颜色空间内,根据红色系的怪兽模块和跳跃模块在HSV空间内的先验阈值,将彩色图像进行二值化处理,具体公式如下:4) In the HSV color space, the color image is binarized according to the a priori threshold of the red monster module and the jump module in the HSV space. The specific formula is as follows:
通过公式B(x,y)=B_H(x,y)&B_S(x,y)&B_V(x,y)获得对应的二进制图像;Obtaining a corresponding binary image by the formula B(x, y)=B_H(x,y)&B_S(x,y)&B_V(x,y);
其中,B(x,y)表示图像像素点(x,y)的二进制像素值,H(x,y)、S(x,y)、V(x,y)分别表示图像像素点(x,y)在HSV颜色空间内的色调值、饱和度值、亮度值;B_H(x,y)、B_S(x,y)、B_V(x,y)分别表示图像像素点(x,y)是否分别在指定的H、S、V区域内,如果是,则取值为1,否则,取值为0;Hmin、Hmax分别表示红色系编程模块(怪兽编程模块和跳跃编程模块)在HSV颜色空间内的色调的先验最小和最大值;Smin、Smax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的先验饱和度最小和最大值;Vmin、Vmax分别表示红色系怪兽编程模块和跳跃编程模块在HSV颜色空间内的亮度的先验最小和最大值;Where B(x, y) represents the binary pixel value of the image pixel point (x, y), and H(x, y), S(x, y), V(x, y) respectively represent the image pixel point (x, y) the hue value, saturation value, and brightness value in the HSV color space; B_H(x, y), B_S(x, y), B_V(x, y) respectively indicate whether the image pixel points (x, y) are respectively In the specified H, S, V area, if yes, the value is 1, otherwise, the value is 0; H min , H max respectively represent the red system programming module (monster programming module and jump programming module) in HSV color The a priori minimum and maximum values of the hue in the space; S min and S max respectively represent the minimum and maximum values of the prior saturation of the red monster programming module and the jump programming module in the HSV color space; V min and V max respectively represent The a priori minimum and maximum values of the brightness of the red monster programming module and the jump programming module within the HSV color space;
5)采用先腐蚀后膨胀的方法去除步骤4)中二值化图像的噪音干扰,并且平滑物体边界;5) removing the noise interference of the binarized image in step 4) by using the method of first etching and then expanding, and smoothing the boundary of the object;
6)扫描二值化图像,找出所有边缘轮廓;6) Scan the binarized image to find all edge contours;
二值化图像可以看作是只有两个值得灰度图像,图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The binarized image can be regarded as only two grayscale images. The edge of the image refers to the part of the grayscale image where the grayscale changes are more intense. The degree of change of the grayscale value is quantified by the gradient change between adjacent pixels. The gradient is a two-dimensional equivalent of the first-order two-dimensional derivative. The specific calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j]G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j] G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示表示图像的在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value at the (x, y) point of the image, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
进一步地,根据怪兽模快、跳跃模块边缘轮廓的大小和离心率的先验知识,滤掉不合理的边缘轮廓,再对剩余的轮廓进行判定,进而得出该编程模块是否为怪兽模快或者跳跃模块,如果是则完成编程模块判定,如果不是则继续执行步骤7);Further, according to the prior knowledge of the monster mode, the size of the edge contour of the jump module and the eccentricity, the unreasonable edge contour is filtered out, and then the remaining contour is determined, thereby determining whether the programming module is a monster model or Jump module, if yes, complete the programming module decision, if not, continue to step 7);
其中,怪兽模快的判定原则为:利用边缘轮廓的形状、大小、离心率和怪兽模块独有的3个小三角形的位置及大小关系的先验知识,来判定编程模块是否为怪兽模块;跳跃模块的判定原则为:将边缘轮廓的最小外包矩形分割成四等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块是否为跳跃模块;Among them, the rule of the monster model is: using the shape, size, eccentricity of the edge contour and the prior knowledge of the position and size relationship of the three small triangles unique to the monster module to determine whether the programming module is a monster module; The principle of the module is to divide the smallest outer envelope of the edge contour into four equal parts, using the shape between the upper left, upper right, lower left and lower right contours, the size ratio of the four contours, and the four contours occupying the entire edge contour. a priori knowledge of the scale and a priori knowledge of the size and eccentricity of the entire edge contour to determine if the programming module is a jump module;
7)将步骤2)中的感兴趣区域图像转换为灰度图像:7) Convert the image of the region of interest in step 2) to a grayscale image:
Gray(x,y)=0.2989×Rxy+0.5870×Gxy+0.1140×Bxy Gray(x,y)=0.2989×R xy +0.5870×G xy +0.1140×B xy
其中,Gray(x,y)表示灰度图像;Where Gray(x, y) represents a grayscale image;
8)采用边缘检测算法检测图像中的强边缘;8) using edge detection algorithm to detect strong edges in the image;
图像的边缘是指灰度图像中灰度变化比较剧烈的部分,灰度值的变化程度采用相邻像素间的梯度变化来定量表示,梯度是一阶二维导数的二维等效式,具体计算过程为:The edge of the image refers to the part of the gray image where the gray level changes sharply. The degree of change of the gray value is quantitatively represented by the gradient change between adjacent pixels. The gradient is the two-dimensional equivalent of the first-order two-dimensional derivative. The calculation process is:
首先,计算相邻像素的差分,具体公式为:First, calculate the difference between adjacent pixels. The specific formula is:
Gx=f[i,j+1]-f[i,j] G x =f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]G y =f[i,j]-f[i+1,j]
其中,Gx表示相邻像素在x方向上的差分,Gy表示相邻像素在y方向上的差分,f[i,j+1]表示图像在第i行第j+1列的像素值,f[i,j]表示图像在第i行第j列的像素值;f[i+1,j]表示图像在第i+1行第j列的像素值,Where G x represents the difference of adjacent pixels in the x direction, G y represents the difference of adjacent pixels in the y direction, and f[i, j+1] represents the pixel value of the image in the i th row and j+1th column. , f[i,j] represents the pixel value of the image in the i-th row and the j-th column; f[i+1,j] represents the pixel value of the image in the i-th row and the j-th column,
进一步地,计算相邻像素间的梯度,具体公式为:Further, the gradient between adjacent pixels is calculated, and the specific formula is:
其中,G(x,y)表示图像在(x,y)点上梯度值,表示像素值在x方向上求导,表示像素值在y方向上求导;Where G(x, y) represents the gradient value of the image at the (x, y) point, Indicates that the pixel value is derived in the x direction. Indicates that the pixel value is derived in the y direction;
进一步地,计算边缘点的梯度幅值,所有边缘点的梯度幅值集合即为提取的边缘轮廓;Further, the gradient magnitude of the edge point is calculated, and the gradient magnitude set of all the edge points is the extracted edge contour;
由于待检测的编程模块目标,在转换为灰度图后,编程模块上的标识与编程模块上的白色区域存在较大的反差,因此,可以利用边缘检测的方法提取出编程模块上表示的边缘轮廓;边缘提取算法包括Sobel算子、Roberts算子、Prewitt算子和Canny算子等,具体公式为:Due to the programming module target to be detected, after conversion to the grayscale image, there is a large contrast between the identification on the programming module and the white area on the programming module. Therefore, the edge detection method can be used to extract the edge represented on the programming module. Contour; edge extraction algorithm includes Sobel operator, Roberts operator, Prewitt operator and Canny operator. The specific formula is:
其中,|G(x,y)|表示边缘点的梯度幅值;Where |G(x,y)| represents the gradient magnitude of the edge point;
9)对步骤8)中得出的编程模块边缘轮廓进行膨胀处理;9) expanding the edge contour of the programming module obtained in step 8);
10)扫描步骤9)中的二值化图像,由于当前编程模块属于非红色系的,因此,判断编程模块属于除了怪兽模块、跳跃模块之外的哪种类型;10) Scanning the binarized image in step 9), since the current programming module belongs to a non-red system, it is determined that the programming module belongs to any type other than the monster module and the jump module;
首先,对步骤9)中得到的二化值图像进行扫描,得到相应的边缘轮廓,通过边缘轮廓的大小和离心率的先验知识,滤掉不合理的轮廓;First, the image of the binary image obtained in step 9) is scanned to obtain a corresponding edge contour, and the unreasonable contour is filtered out by the prior knowledge of the size of the edge contour and the eccentricity;
进一步地,将过滤后剩余的边缘轮廓的最小外接矩形分割成4等份,利用左上、右上、左下和右下的轮廓间的形状、4个轮廓的大小比例关系、4个轮廓占整个边缘轮廓的比例的先验知识以及整个边缘轮廓的大小和离心率的先验知识,来判定编程模块的类型。Further, the minimum circumscribed rectangle of the edge contour remaining after filtering is divided into 4 equal parts, and the shape between the upper left, upper right, lower left, and lower right contours, the size ratio relationship of the four contours, and the four contours occupy the entire edge contour The a priori knowledge of the ratio and the prior knowledge of the size and eccentricity of the entire edge profile to determine the type of programming module.
如果判断出编程模块为条件模块,则取该编程模块边缘轮廓的质心,判断质心的颜色,再与先验知识进行比对,得出编程模块为条件1模块或者条件2模块。 If it is determined that the programming module is a conditional module, the centroid of the edge contour of the programming module is taken, the color of the centroid is judged, and then compared with the prior knowledge, and the programming module is a conditional 1 module or a conditional 2 module.
如果判断出编程模块为转弯模块,则取该编程模块边缘轮廓的转弯点与其对角点连线的中点,再与先验知识进行比对,得出编程模块为左转模块或者右转模块。If it is determined that the programming module is a turning module, the turning point of the edge contour of the programming module is taken from the midpoint of the line connecting the diagonal point thereof, and then compared with the prior knowledge, and the programming module is a left turn module or a right turn module. .
本发明巧妙的将应用计算机视觉图形识别技术与HSV颜色空间、二值化处理、灰度图像、图像切割技术相结合使用,能够判断出编程模块的类型,具有运算速度快,定位准确,将硬件与软件技术很好地统一起来,游戏交互设计巧妙;美观简单,判断更加快速,同时增强了趣味性和直观性。The invention skillfully combines the application of computer vision graphic recognition technology with HSV color space, binarization processing, grayscale image and image cutting technology, can determine the type of programming module, has fast computing speed, accurate positioning, and hardware It is well integrated with the software technology, the game interaction design is clever; the appearance is simple, the judgment is faster, and the fun and the intuitiveness are enhanced.
本发明检测算法更加科学、成熟,将图像的透视变换、色彩空间转换、轮廓检测、形态学处理、去噪等算法相结合使用,能够快速的判断出编程模块的类型。The detection algorithm of the invention is more scientific and mature, and combines the perspective transformation of the image, the color space conversion, the contour detection, the morphological processing, the denoising and the like, and can quickly determine the type of the programming module.
本发明计算速度快;每次定位检测耗时在100ms左右,为玩家提供流畅的使用体验。The calculation speed of the invention is fast; each positioning detection takes about 100ms, which provides a smooth experience for the player.
本发明性能稳定,在不同光照、对不同平板电脑安装于教育玩具套件内的情况下,针对3千幅图片进行了采集测试,误识别率和漏检率在0.2%以下。The performance of the invention is stable, and in the case of different illumination and different tablet computers installed in the educational toy kit, the collection and test are performed on 3,000 pictures, and the false recognition rate and the missed detection rate are below 0.2%.
以上显示和描述了本发明的基本原理、主要特征和本发明的优点。本行业的技术人员应该了解,本发明不受上述实施例的限制,上述实施例和说明书中描述的只是说明本发明的原理,在不脱离本发明精神和范围的前提下本发明还会有各种变化和改进,这些变化和改进都落入要求保护的本发明范围内。本发明要求保护范围由所附的权利要求书及其等同物界定。The basic principles, main features, and advantages of the present invention are shown and described above. It should be understood by those skilled in the art that the present invention is not limited by the foregoing embodiments, and that the present invention is described in the foregoing description and the description of the present invention. Such changes and modifications are intended to fall within the scope of the invention as claimed. The scope of the invention is defined by the appended claims and their equivalents.
所属领域技术人员根据上文的记载容易得知,本发明技术方案适合在工业中制造并在生产、生活中使用,因此本发明具备工业实用性。 It is easily known to those skilled in the art from the above description that the technical solution of the present invention is suitable for industrial production and is used in production and life, and therefore the present invention has industrial applicability.
Claims (9)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201610697871.2A CN106297492B (en) | 2016-08-19 | 2016-08-19 | A kind of Educational toy external member and the method using color and outline identification programming module |
| CN201610697871.2 | 2016-08-19 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018032630A1 true WO2018032630A1 (en) | 2018-02-22 |
Family
ID=57661921
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2016/105740 Ceased WO2018032630A1 (en) | 2016-08-19 | 2016-11-14 | Teaching toy kit and method for identifying programming module by using color and counter |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN106297492B (en) |
| WO (1) | WO2018032630A1 (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109448093A (en) * | 2018-10-25 | 2019-03-08 | 广东智媒云图科技股份有限公司 | A kind of style image generation method and device |
| US20190244392A1 (en) * | 2018-02-08 | 2019-08-08 | Hasbro, Inc. | Color-based toy identification system |
| CN115761485A (en) * | 2022-11-07 | 2023-03-07 | 埃夫特智能装备股份有限公司 | Method for identifying U-shaped groove on side edge of door handle plate applied to spraying system |
Families Citing this family (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106327956B (en) * | 2016-08-19 | 2019-06-21 | 上海葡萄纬度科技有限公司 | A kind of Educational toy external member and its card identification method of tinting |
| CN107154058B (en) * | 2017-05-08 | 2020-09-01 | 上海葡萄纬度科技有限公司 | Method for guiding user to restore magic cube |
| CN110223541A (en) * | 2018-03-03 | 2019-09-10 | 哈尔滨越泰科技发展有限公司 | A kind of educational suite based on mirror surface refraction image recognition methods |
| CN109410702B (en) * | 2018-12-28 | 2021-10-01 | 于珂 | System suitable for parent-child interaction learning programming and device for realizing system |
| CN110378248B (en) * | 2019-06-25 | 2023-07-21 | 平安科技(深圳)有限公司 | Pie chart identification method, device, equipment and computer readable storage medium |
Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9158389B1 (en) * | 2012-10-15 | 2015-10-13 | Tangible Play, Inc. | Virtualization of tangible interface objects |
| CN105194884A (en) * | 2015-10-27 | 2015-12-30 | 上海葡萄纬度科技有限公司 | Educational toy suite |
| CN205164140U (en) * | 2015-10-27 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Education toy external member |
| CN105498200A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy set and tangram color recognition method thereof |
| CN105498253A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy set and positioning hole detecting and positioning method thereof |
| CN105513086A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy suite and magic cube detecting and positioning method thereof on basis of shape matching |
| CN105719307A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy set and method for detecting placing shape and position of tangram |
| CN105719318A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy set and HSV based color identification method for Rubik's cube |
| CN105709434A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy suite and reflector position detecting method thereof |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101146231A (en) * | 2007-07-03 | 2008-03-19 | 浙江大学 | Method for generating panoramic video based on multi-view video stream |
| CN105590486A (en) * | 2014-10-21 | 2016-05-18 | 黄小曼 | Machine vision-based pedestal-type finger reader, related system device and related method |
-
2016
- 2016-08-19 CN CN201610697871.2A patent/CN106297492B/en active Active
- 2016-11-14 WO PCT/CN2016/105740 patent/WO2018032630A1/en not_active Ceased
Patent Citations (9)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9158389B1 (en) * | 2012-10-15 | 2015-10-13 | Tangible Play, Inc. | Virtualization of tangible interface objects |
| CN105194884A (en) * | 2015-10-27 | 2015-12-30 | 上海葡萄纬度科技有限公司 | Educational toy suite |
| CN205164140U (en) * | 2015-10-27 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Education toy external member |
| CN105498200A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy set and tangram color recognition method thereof |
| CN105498253A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy set and positioning hole detecting and positioning method thereof |
| CN105513086A (en) * | 2016-01-26 | 2016-04-20 | 上海葡萄纬度科技有限公司 | Educational toy suite and magic cube detecting and positioning method thereof on basis of shape matching |
| CN105719307A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy set and method for detecting placing shape and position of tangram |
| CN105719318A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy set and HSV based color identification method for Rubik's cube |
| CN105709434A (en) * | 2016-01-26 | 2016-06-29 | 上海葡萄纬度科技有限公司 | Educational toy suite and reflector position detecting method thereof |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20190244392A1 (en) * | 2018-02-08 | 2019-08-08 | Hasbro, Inc. | Color-based toy identification system |
| US10950007B2 (en) * | 2018-02-08 | 2021-03-16 | Hasbro, Inc. | Color-based toy identification system |
| CN109448093A (en) * | 2018-10-25 | 2019-03-08 | 广东智媒云图科技股份有限公司 | A kind of style image generation method and device |
| CN115761485A (en) * | 2022-11-07 | 2023-03-07 | 埃夫特智能装备股份有限公司 | Method for identifying U-shaped groove on side edge of door handle plate applied to spraying system |
Also Published As
| Publication number | Publication date |
|---|---|
| CN106297492B (en) | 2019-06-25 |
| CN106297492A (en) | 2017-01-04 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018032630A1 (en) | Teaching toy kit and method for identifying programming module by using color and counter | |
| CN105719318B (en) | Magic square color identification method based on HSV in a kind of Educational toy external member | |
| CN111243032B (en) | Full-automatic detection method for checkerboard corner points | |
| CN106355592B (en) | An educational toy kit and method for identifying its circuit components and wires | |
| WO2018032626A1 (en) | Teaching toy kit and number identification method thereof | |
| WO2017128606A1 (en) | Educational toy kit and tangram color recognition method therefor | |
| CN105893949B (en) | A kind of method for detecting lane lines under complex road condition scene | |
| CN110478892B (en) | A three-dimensional interactive method and system | |
| CN103218605B (en) | A kind of fast human-eye positioning method based on integral projection and rim detection | |
| WO2017128604A1 (en) | Educational toy kit and shape matching-based magic cube location detection method therefor | |
| CN110032932B (en) | Human body posture identification method based on video processing and decision tree set threshold | |
| CN105279787A (en) | Method for generating three-dimensional (3D) building model based on photographed house type image identification | |
| CN105709434B (en) | A kind of Educational toy external member and its mirror position detection method | |
| CN111695373B (en) | Zebra stripes positioning method, system, medium and equipment | |
| CN107154058B (en) | Method for guiding user to restore magic cube | |
| CN105498253B (en) | A kind of Educational toy external member and its positioning hole detection localization method | |
| CN105488492A (en) | Color image preprocessing method, road identification method and related device | |
| WO2017128607A1 (en) | Educational toy kit and method for detecting placement shape and position of tangram | |
| CN102930279A (en) | Image identification method for detecting product quantity | |
| CN108830198A (en) | Recognition methods, device, equipment and the storage medium of video format | |
| WO2018032627A1 (en) | Teaching toy kit and marine mold identification method thereof | |
| CN108564020B (en) | Micro-gesture recognition method based on panoramic 3D images | |
| CN112200230B (en) | Training board identification method and device and robot | |
| CN104459101B (en) | Enzyme-linked immunospot assay device and method | |
| WO2018032628A1 (en) | Teaching toy kit and colored card identification method thereof |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16913385 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 16913385 Country of ref document: EP Kind code of ref document: A1 |