Educational toy set, circuit element thereof and wire identification method
Technical Field
The invention relates to the technical field of computer vision detection processing, in particular to an educational toy set and a circuit element and wire identification method thereof.
Background
At present, a plurality of interesting preschool education game application programs or children games exist on a tablet personal computer, but the interaction is lacked, so that children can only point to draw pictures on a screen, the eyes are easily injured when the children look at the screen for a long time, physical knowledge education is lacked, and logical thinking culture is lacked; moreover, some traditional game toys with strong interactivity break away from the development of the times, so that the requirements of children on learning and playing cannot be met formally, and the interactive communication between the children and parents is not convenient.
In order to solve the above problems, the computer vision and image processing technology field has successfully developed an educational toy set comprising: the system comprises a support, a helmet detector and a bottom plate, wherein a game program is installed in a tablet personal computer, and images of the bottom plate placed on a plane are collected through a camera of the tablet personal computer. Although the education toy set solves the problem of lacking interactivity of games in the tablet personal computer, the education toy set is still single in form, only interacts simply, is not embedded with physical knowledge, cannot cultivate electrical knowledge for children from childhood, and cannot cultivate the knowledge and interest of children on electricity from childhood.
Therefore, an educational toy set, a circuit element and an electric wire identification method thereof are urgently needed in the technical field of computer vision detection processing, the circuit element and the electric wire are placed on a game bottom plate, a game program is installed in a tablet personal computer, the circuit element and the electric wire image placed on the bottom plate are collected through a camera of the tablet personal computer, the circuit element and the electric wire are identified based on predefined color, outline information and color coding information, and a child connects the circuit element and the electric wire to judge whether the connected circuit is correct or not, so that the imagination of the child is enhanced, the game interest is increased, the child can learn basic circuit knowledge and the interest of the child is developed.
Disclosure of Invention
In order to solve the above problems, the present invention provides an educational toy set, a circuit element thereof, and a method for identifying an electric wire, the technical scheme is as follows:
an educational toy set comprising: the tablet personal computer, the bottom plate, the circuit components and the wire bottom plate are placed on the plane, and the circuit components and the wire are placed on the bottom plate; and the corners of the bottom plate are provided with calibration angles.
Preferably, in the above-mentioned educational toy set, the base plate has a rectangular shape with rounded corners; the calibration angle is a red circular arc.
A method of identifying circuit elements and wires in an educational toy set, comprising the steps of:
step one, installing a game program in a tablet personal computer, and then placing a bottom plate on a plane to ensure that one surface of a calibration angle faces upwards
Step two, completing the connection of circuit components and wires on a bottom plate, collecting a color image in real time through a rear camera of a tablet computer, and moving the tablet computer to ensure that the color image collected by the rear camera at least contains 3 calibration angles;
step three, extracting an effective identification area from the color image in the step two;
detecting circuit components in the effective identification area of the color image;
step five, detecting the electric wire positioned in the effective identification area of the color image;
and step six, judging whether the connection between the circuit component and the electric wire is accurate.
Preferably, in the above method for identifying circuit components and wires in an educational toy set, the color image collected by the rear camera in the second step is Ixy,Ixy=f(x,y)=(Rxy,Gxy,Bxy) Wherein (x, y) represents the position coordinates of the pixel points of the color image, f (x, y) represents the pixel values of the image at the coordinate positions of the pixel points, RxyRepresenting the color value, G, of a pixel of an image in the red channelxyRepresenting the color value of a pixel of an image in the green channel, BxyAnd the color value of the pixel point of the image in the blue channel is represented.
Preferably, in the above method for identifying circuit elements and wires in an educational toy set, the specific steps of extracting the effective identification area from the color image in the third step are:
A) according to the priori knowledge, 4 calibration angle regions are segmented from the color image in the second step, and according to the priori threshold value in the HSV space, binarization processing is carried out on the 4 calibration angle region images to obtain 4 calibration angle binary images;
B) scanning the 4 calibration angle binary images obtained in the step A) to obtain corresponding edge contour images, and filtering unreasonable contours according to the prior knowledge of the eccentricity and the size of the edge contours;
C) calculating circumscribed rectangles of 4 calibration angles according to the residual edge profile obtained in the step B), wherein in the identification process, when at least three corner marks have qualified calibration angles, the circumscribed rectangles are the calculated effective identification areas.
Preferably, in the above method for identifying circuit components and wires in an educational toy set, the step of detecting circuit components located in the color image identification area in the fourth step comprises the steps of:
1, dividing each circuit component according to the color difference because the color of the shell of each circuit component is different, and extracting the inner contour of the shell of each circuit component;
2, calculating the position and deflection angle of each circuit component according to the inner contour of the shell of the circuit component extracted in the step 1;
and 3, rotating the circuit component according to the deflection angle calculated in the step 2, then dividing the circuit component, and identifying the type of the circuit component through color coding.
Preferably, in the above method for identifying circuit components and wires in an educational toy set, the specific steps of extracting the inner contour of each circuit component housing in step 1 are as follows:
a) because the colors of the circuit components are not beneficial to being divided in the RGB color space and are sensitive to illumination change, the extracted effective identification area image is converted into HSV color space which is emphasized on color representation from the RGB color space, and the specific conversion formula is as follows:
V=max{C(R′)、C(G′)、C(B′)};
h represents a hue value, S represents a saturation value, V represents a brightness value, max { C (R '), C (G'), C (B ') } represents the maximum value of a pixel point in three channels of red, green and blue in an original image, min { C (R'), C (G ') and C (B') } represent the minimum value of a pixel point in three channels of red, green and blue in the original image, and the value range of H is between 0 and 360;
b) in an HSV color space, carrying out binarization processing on the color image according to a prior threshold value of the color related to the circuit component in the HSV color space, wherein a specific formula is as follows:
when B (x, y) ═ B _ H (x, y) & B _ S (x, y) & B _ V (x, y) in the binary image, the binary image is generated;
b (x, y) represents a binary pixel value of an image pixel (x, y), and H (x, y), S (x, y) and V (x, y) respectively represent a hue value, a saturation value and a brightness value of the image pixel (x, y) in an HSV color space; b _ H (x, y), B _ S (x, y) and B _ V (x, y) respectively represent whether the image pixel points (x, y) are respectively in the designated H, S, V areas, if yes, the value is 1, otherwise, the value is 0; hmin、HmaxRespectively representing prior minimum and maximum values of hues of the color of a certain component shell in an HSV color space; smin、SmaxRespectively representing prior minimum and maximum values of the saturation of the color of a certain component shell in an HSV color space; vmin、VmaxRespectively representing the prior minimum and maximum values of the brightness of the color of a certain component shell in the HSV color space.
c) Scanning the binary image to find out all edge contours;
the binary image can be regarded as a gray image with only two values, the edge of the image refers to a part with severe gray change in the gray image, the change degree of the gray value is quantitatively expressed by the gradient change between adjacent pixels, the gradient is a two-dimensional equivalent formula of a first-order two-dimensional derivative, and the specific calculation process is as follows:
firstly, calculating the difference of adjacent pixels, wherein the specific formula is as follows:
Gx=f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]
wherein G isxRepresenting the difference of adjacent pixels in the x-direction, GyDenotes the difference in y direction between adjacent pixels, f [ i, j +1]Representing the pixel value of the image in the ith row, column j +1, f i, j]The pixel value of the image in the ith row and the jth column is represented; f [ i +1, j ]]The pixel value of the j th column in the i +1 th row of the image is represented;
further, the gradient between adjacent pixels is calculated by the following specific formula:
wherein G (x, y) represents a gradient value at an (x, y) point representing an image,
indicating that the pixel values are differentiated in the x-direction,
indicating that the pixel values are derived in the y-direction;
further, calculating the gradient amplitudes of the edge points, wherein the gradient amplitude set of all the edge points is the extracted edge profile;
furthermore, the method for calculating the ears of the non-stationary electric fan and other circuit components filters unreasonable outlines according to the priori knowledge of the shapes, sizes and eccentricities of the ear outlines of the circuit components, so that the positions of 2 ears of the circuit components are obtained;
because the ears of the stationary fan are possibly covered by the fan blades, the color image in the step b) needs to be segmented into a blue binary image and a green binary image;
further, scanning the blue binary image, judging whether the fan blades exist or not through the prior knowledge of the contour shape, eccentricity and size of the fan blades, and if so, judging that the circuit component is a fan; otherwise, directly jumping to the step 2;
further, after the circuit component is judged to be a fan, the calculation method for the ear of the stationary fan is as follows: clustering the green binary image in the step 1, clustering the green points with close distance into one class, filtering the point set clustered into one class through the number of the point sets of the same class, the size of the minimum outsourcing rectangle of the point sets, the eccentricity and the priori knowledge of the positions of the point sets, if only two classes of point sets are left after filtering, considering that the current fan blade position covers the ears of the electric component with high probability, and calculating the position of the center point of each ear of the electric component through the position of the center point between the two classes of point sets, namely the position of the center point of the electric component and the contour information of the component.
Preferably, in the above method for identifying circuit components and wires in an educational toy set, the step 2 of calculating the position and deflection angle of each circuit component comprises the following specific steps:
and calculating the rotation angle of the circuit component according to the calculated position of the central point of the circuit component and the position of the central point of each ear by taking the ear of the circuit component in the horizontal direction as a standard.
Preferably, in the above method for identifying circuit components and wires in an educational toy set, the specific step of identifying the type of the circuit component in step 3 is:
firstly, a coding rule needs to be set for all circuit components in advance, so that each circuit component has a unique code; because the number of the circuit components to be identified is limited, four easily-distinguished colors of red, yellow, blue and green are selected as the coding characteristic colors; the private printing of the circuit components is mainly concentrated in three areas, namely, an upper area, a middle area and a lower area, and when a certain color pixel of the three areas exceeds a color pixel threshold value, the color is considered as the color of the area;
according to the shell color of the circuit components, the private printing colors of the upper middle part, the middle part and the lower middle part, red is marked as 1, yellow is marked as 2, blue is marked as 3, green is marked as 4, no marking is marked as 0, the current color is also marked as 0 after neglecting, 11 circuit components can be coded, and the type of the current detection circuit component can be uniquely determined according to the coding of the circuit components;
and filtering circuit components which do not accord with the codes, and transmitting the types of the remaining circuit components, the central points of the circuit components and the rotation angles to upper-layer software together.
Preferably, in the above-mentioned method of recognizing circuit elements and electric wires in an educational toy set, the color pixel threshold is 30% of the area of each of the nine cells.
Preferably, in the above method for identifying circuit elements and wires in an educational toy set, the step five of detecting the wires located in the effective identification area of the color image comprises the specific steps of:
step 1), segmenting wires and extracting bones through color difference;
and 2) calculating the end point and the bifurcation point of the electric wire through the extracted bones.
Preferably, in the above method for identifying circuit elements and wires in an educational toy set, the specific steps of segmenting the wires by color difference and extracting bones in step 1) are:
firstly, in an effective identification area HSV space in the third step, carrying out binarization processing on an image according to a prior threshold value of the color of the wire in the HSV space to obtain a wire binarization image;
further, scanning the wire binary image, filtering out contours which do not accord with the characteristics of the wire through the priori knowledge of the shape and the size of the contour of the wire, and filling the remaining contours to obtain a new wire-only binary image;
further, the skeleton of the wire is obtained by thinning the binary image of the wire only.
Preferably, in the above method for identifying circuit elements and wires in an educational toy set, the specific steps of calculating the end points and branch points of the wires through the extracted skeleton in step 2) are: finding the end points and the branch points in the wire skeleton through the wire skeleton obtained in the step 1) and the prior knowledge of the end points and the branch point characteristics of the wire, if the branch points exist, separating the wire skeleton from the branch points to be divided into a plurality of line segments, if the branch points do not exist, the original wire skeleton is a line segment, and providing all the line segments and the types of the end points of the line segments in the skeleton to upper-layer software.
Preferably, in the above method for identifying a circuit component and an electric wire in an educational toy set, the step six of determining whether the connection between the circuit component and the electric wire is accurate includes the specific steps of: and the upper software connects the circuit component identified in the step four with the electric wire identified in the step five, and then compares the electric wire with a circuit diagram stored by the upper software, and if the electric wire is consistent with the circuit diagram, the circuit connection is considered to be accurate.
The invention has the beneficial effects that:
1. the invention skillfully combines the applied computer vision figure recognition technology with HSV color space, binarization processing and image cutting technology for use, can judge the types and electric wires of circuit components and can judge whether the circuit connection is accurate, has the advantages of high operation speed and accurate positioning, well unifies hardware and software technologies, and has ingenious game interaction design; beautiful and simple, the judgment is quicker, the imagination of the children is enhanced, the interesting of the game is increased, the children can learn the basic circuit knowledge, and the interest of the children is cultivated.
2. The detection algorithm is more scientific and mature, and the algorithms such as color conversion of images, image convolution, image cutting, skeleton thinning and the like are combined for use, so that the types of circuit components and wires can be quickly judged.
3. The invention has high calculation speed; each positioning detection takes about 200ms, and a smooth use experience is provided for the player.
4. The invention has stable performance, and the error recognition rate and the omission factor are below 0.2 percent when 3 thousand pictures are acquired and tested under the conditions of different illumination and installation of different tablet computers in the educational toy suite.
Drawings
The invention is described in detail below with reference to the following figures and detailed description:
fig. 1 is a schematic view showing the construction of an educational toy set of the present invention.
Fig. 2 is a flowchart of a method of identifying circuit elements and wires in an educational toy set according to the present invention.
Fig. 3 is a table diagram of specific circuit component codes of step 3 in step four of the educational toy set of the present invention.
Wherein, the corresponding relationship between the reference numbers and the part names in fig. 1-3 is:
bottom plate 1, circuit component 2, electric wire 3.
Detailed Description
In order to make the measures, features, objectives and functions of the present invention easy to be understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a toy set and a method for identifying circuit components and electric wires thereof, a base plate 1, a circuit component 2 and an electric wire 3, wherein the base plate 1 is placed on a plane, and the circuit component 2 and the electric wire 3 are placed on the base plate 3.
In this embodiment, the bottom plate is a rectangle with rounded corners, and 4 corners of the rectangle are provided with calibration corners; preferably, the alignment angle is a red circular arc.
The circuit components comprise a static electric fan, a non-static electric fan and other circuit components, and each circuit component is provided with 2 symmetrical ears.
As shown in fig. 2, a method for identifying circuit elements and wires in an educational toy set, comprising the steps of:
step one, installing a game program in a tablet personal computer, and then placing a bottom plate on a plane to ensure that one surface of a calibration angle faces upwards;
step two, accomplish the connection of circuit components and parts and electric wire on the bottom plate, gather the color image through the rear camera of panel computer in real time, remove the panel computer, guarantee that the color image that the rear camera was gathered contains 3 calibration angles at least, concrete step is:
the color image collected by the rear camera is Ixy,Ixy=f(x,y)=(Rxy,Gxy,Bxy) Wherein (x, y) represents the position coordinates of the pixel points of the color image, f (x, y) represents the pixel values of the image at the coordinate positions of the pixel points, RxyRepresenting the color value, G, of a pixel of an image in the red channelxyRepresenting the color value of a pixel of an image in the green channel, BxyRepresenting the color value of the image pixel point in a blue channel;
step three, extracting an effective identification area from the color image in the step two, and specifically comprising the following steps:
A) according to the priori knowledge, 4 calibration angle regions are segmented from the color image in the second step, and according to the priori threshold value in the HSV space, binarization processing is carried out on the 4 calibration angle region images to obtain 4 calibration angle binary images;
B) scanning the 4 calibration angle binary images obtained in the step A) to obtain corresponding edge contour images, and filtering unreasonable contours according to the prior knowledge of the eccentricity and the size of the edge contours;
C) calculating circumscribed rectangles of 4 calibration angles according to the residual edge profile obtained in the step B), wherein in the identification process, when at least three corner marks have qualified calibration angles, the circumscribed rectangles are calculated effective identification areas;
detecting circuit components in the effective identification area of the color image, and specifically comprising the following steps:
1, because the colour of every circuit components and parts shell is different, consequently through the colour difference, divide out each circuit components and parts to extract the interior profile of every circuit components and parts shell, concrete step is:
a) because the colors of the circuit components are not beneficial to being divided in the RGB color space and are sensitive to illumination change, the extracted effective identification area image is converted into HSV color space which is emphasized on color representation from the RGB color space, and the specific conversion formula is as follows:
V=max{C(R′)、C(G′)、C(B′)};
h represents a hue value, S represents a saturation value, V represents a brightness value, max { C (R '), C (G'), C (B ') } represents the maximum value of a pixel point in three channels of red, green and blue in an original image, min { C (R'), C (G ') and C (B') } represent the minimum value of a pixel point in three channels of red, green and blue in the original image, and the value range of H is between 0 and 360;
b) in an HSV color space, carrying out binarization processing on the color image according to a prior threshold value of a color related to a shell of a circuit component in the HSV color space, wherein a specific formula is as follows:
when B (x, y) ═ B _ H (x, y) & B _ S (x, y) & B-V (x, y) in the binary image, the binary image is generated;
b (x, y) represents a binary pixel value of an image pixel (x, y), and H (x, y), S (x, y) and V (x, y) respectively represent a hue value, a saturation value and a brightness value of the image pixel (x, y) in an HSV color space; b _ H (x, y), B _ S (x, y) and B _ V (x, y) respectively represent whether the image pixel points (x, y) are respectively in the designated H, S, V areas, if yes, the value is 1, otherwise, the value is 0; hmin、HmaxRespectively representing prior minimum and maximum values of hues of the color of a certain component shell in an HSV color space; smin、SmaxRespectively representing prior minimum and maximum values of the saturation of the color of a certain component shell in an HSV color space; vmin、VmaxRespectively representing prior minimum and maximum values of brightness of the color of a certain component shell in an HSV color space;
c) scanning the binary image to find out all edge contours;
the binary image can be regarded as a gray image with only two values, the edge of the image refers to a part with severe gray change in the gray image, the change degree of the gray value is quantitatively expressed by the gradient change between adjacent pixels, the gradient is a two-dimensional equivalent formula of a first-order two-dimensional derivative, and the specific calculation process is as follows:
firstly, calculating the difference of adjacent pixels, wherein the specific formula is as follows:
Gx=f[i,j+1]-f[i,j]
Gy=f[i,j]-f[i+1,j]
wherein G isxRepresenting the difference of adjacent pixels in the x-direction, GyDenotes the difference in y direction between adjacent pixels, f [ i, j +1]Representing the pixel value of the image in the ith row, column j +1, f i, j]The pixel value of the image in the ith row and the jth column is represented; f [ i +1, j ]]Representing the pixel value of the image at row i +1 and column j,
further, the gradient between adjacent pixels is calculated by the following specific formula:
wherein G (x, y) represents a gradient value at an (x, y) point representing an image,
indicating that the pixel values are differentiated in the x-direction,
indicating that the pixel value is at yDerivation in direction;
further, calculating the gradient amplitudes of the edge points, wherein the gradient amplitude set of all the edge points is the extracted edge profile;
furthermore, the method for calculating the ears of the non-stationary electric fan and other circuit components filters unreasonable outlines according to the priori knowledge of the shapes, sizes and eccentricities of the ear outlines of the circuit components, so that the positions of 2 ears of the circuit components are obtained;
because the ears of the stationary fan are possibly covered by the fan blades partially or completely, the color segmentation is carried out on the step b) to segment a blue binary image and a green binary image;
further, scanning the blue binary image, judging whether the fan blades exist or not through the prior knowledge of the contour shape, eccentricity and size of the fan blades, and if so, judging that the circuit component is a fan; otherwise, directly jumping to the step 2;
further, after the circuit component is judged to be a fan, the calculation method for the ear of the stationary fan is as follows: clustering the green binary image in the step 1, clustering the green points with close distance into one class, filtering the clustered point sets through the number of the point sets of the same class, the size of the minimum outsourcing rectangle of the point sets, the eccentricity and the priori knowledge of the positions of the point sets, if only two classes of point sets are left after filtering, considering that the current fan blade position covers the ears of the electric component with high probability, and calculating the position of the center point of each ear of the electric component through the position of the center point between the two classes of point sets, namely the position of the center point of the electric component and the contour information of the electric component;
2, calculating the position and deflection angle of each circuit component according to the contour of the circuit component extracted in the step 1, and the specific steps are as follows:
and calculating the rotation angle of the circuit component according to the calculated position of the central point of the circuit component and the position of the central point of each ear by taking the ear of the circuit component in the horizontal direction as a standard.
Rotating the circuit component according to the deflection angle calculated in the step 2, then dividing the circuit component, and identifying the category of the circuit component through color coding, wherein the method specifically comprises the following steps:
firstly, a coding rule needs to be set for all circuit components in advance, so that each circuit component has a unique code; because the number of the circuit components to be identified is limited, four easily-distinguished colors of red, yellow, blue and green are selected as the coding characteristic colors; the private printing of the circuit components is mainly concentrated in three areas, namely, an upper area, a middle area, a lower area and a middle area, and when the pixel value of a certain color of the three areas exceeds a prior threshold value, the color is considered as the color of the area;
according to the shell color of the circuit components, the private printing colors of the upper middle part, the middle part and the lower middle part, red is marked as 1, yellow is marked as 2, blue is marked as 3, green is marked as 4, no marking is marked as 0, the current color is also marked as 0 after neglecting, 11 circuit components can be coded, and the type of the current detection circuit component can be uniquely determined according to the coding of the circuit components;
filtering out circuit components which do not accord with codes, and transmitting the types of the remaining circuit components, the central points of the circuit components and the rotation angles to upper-layer software together, wherein the specific codes of the circuit components are shown in figure 3;
step five, detecting the electric wire positioned in the effective identification area of the color image, and the specific steps are as follows:
step 1), segmenting wires and extracting bones through color difference, and the method comprises the following specific steps:
firstly, in an effective identification area HSV space in the third step, carrying out binarization processing on an image according to a prior threshold value of the color of the wire in the HSV space to obtain a wire binarization image;
further, scanning the wire binary image, filtering out contours which do not accord with the characteristics of the wire through the priori knowledge of the shape and the size of the contour of the wire, and filling the remaining contours to obtain a new wire-only binary image;
further, thinning the bones of the binary image only with the electric wires to obtain bones of the electric wires;
step 2), calculating the end point and the bifurcation point of the electric wire through the extracted bones, and the specific steps are as follows: finding out the end points and branch points in the wire skeleton through the wire skeleton obtained in the step 1) and the prior knowledge of the end points and branch point characteristics of the wire, if the branch points exist, separating the wire skeleton from the branch points to form a plurality of line segments, if the branch points do not exist, the original wire skeleton is a line segment, and providing all the line segments and the types of the end points of the line segments in the skeleton to upper-layer software;
and step six, judging whether the connection between the circuit component and the electric wire is accurate or not, and specifically comprising the following steps:
and the upper software connects the circuit component identified in the step four with the electric wire identified in the step five, and then compares the electric wire with a circuit diagram stored by the upper software, and if the electric wire is consistent with the circuit diagram, the circuit connection is considered to be accurate.
In this embodiment, the color pixel threshold is 30% of the area of each of the nine-square squares.
The invention skillfully combines the applied computer vision figure recognition technology with HSV color space, binarization processing and image cutting technology for use, can judge the types and electric wires of circuit components and can judge whether the circuit connection is accurate, has the advantages of high operation speed and accurate positioning, well unifies hardware and software technologies, and has ingenious game interaction design; beautiful and simple, the judgment is quicker, the imagination of the children is enhanced, the interesting of the game is increased, the children can learn the basic circuit knowledge, and the interest of the children is cultivated.
The detection algorithm is more scientific and mature, and the algorithms such as color conversion of images, image convolution, image cutting, skeleton thinning and the like are combined for use, so that the types of circuit components and wires can be quickly judged.
The invention has high calculation speed; each positioning detection takes about 200ms, and a smooth use experience is provided for the player.
The invention has stable performance, and the error recognition rate and the omission factor are below 0.2 percent when 3 thousand pictures are acquired and tested under the conditions of different illumination and installation of different tablet computers in the educational toy suite.
The foregoing shows and describes the general principles, essential features, and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, which are given by way of illustration of the principles of the present invention, and that various changes and modifications may be made without departing from the spirit and scope of the invention as defined by the appended claims. The scope of the invention is defined by the appended claims and equivalents thereof.