Disclosure of Invention
In order to solve the technical problems that the projector is occupied with more computing power in the space-to-space distance transformation process in related scenes, and the accuracy of the transformed feature points is low due to noise interference and illumination influence, the disclosure provides a feature point transformation method, a device and equipment in an embedded system.
According to a first aspect of the embodiments of the present disclosure, there is provided a feature point transformation method in an embedded system, the feature point transformation method in the embedded system including:
inputting feature points into a pre-configured rectangle aiming at any adjacent image frame to be processed, and constructing feature pixel points according to the feature points of the image frame to be processed in the rectangle;
subtracting the vertical coordinates of the characteristic pixel points on the corresponding coordinate positions in the adjacent image frames to be processed to obtain standby image frames;
performing Gaussian filtering and binarization on the standby image frame to obtain a black-and-white image frame;
performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle;
determining a target straight line corresponding to the side of the rectangle according to the coordinates of the four corners of the pixel points in the black-and-white image frame based on a least square method;
and determining a target characteristic point in the adjacent image frames to be processed according to the intersection point of the target straight line.
In one embodiment, the step of constructing a feature pixel point according to a feature point of the image frame to be processed in the rectangle includes:
calculating the difference value between the maximum value of each color channel and the parameter value of the color channel corresponding to the characteristic point in the rectangle;
taking the difference value as a reverse color parameter value of a color channel corresponding to the characteristic point to obtain reverse color of the characteristic point;
and constructing corresponding characteristic pixel points according to the reverse color parameter values of the characteristic points of the image frame to be processed in the rectangle.
In one embodiment, the step of performing gaussian filtering and binarization on the spare image frame to obtain a black-and-white image frame includes:
performing Gaussian filtering on the standby image frame through a Gaussian filtering matrix;
determining background pixel points from the Gaussian filtered image according to a preset gray threshold, and calculating the average gray value of the background pixel points to obtain a first average gray value and the average gray values of all the pixel points in the Gaussian filtered image to obtain a second average gray value;
determining a binarization threshold value according to the first average gray value and the second average gray value;
and carrying out gray level binarization on the Gaussian filtered image according to the binarization threshold value to obtain a black-and-white image frame.
In one embodiment, the step of determining a binary threshold according to the first average grayscale value and the second average grayscale value includes:
and calculating the average value of the first average gray value and the second average gray value to obtain a third average gray value, and taking the third average gray value as the binarization threshold value.
In one embodiment, the step of performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle includes:
calculating the variance of all pixel points in the black-and-white image frame and the gradient information of adjacent pixel points;
and according to the sides of the rectangle, the variance and the gradient information, performing edge calculation on the rectangle to obtain coordinates of four corners of the rectangle.
In one embodiment, the step of determining a target straight line corresponding to the side of the rectangle according to the coordinates of the four corners of the pixel points in the black-and-white image frame based on the least square method includes;
screening pixel points in the black-and-white image frame according to the coordinates of the four corners to obtain standby pixel points;
and determining a target straight line corresponding to the side of the rectangle according to the spare pixel point based on a least square method.
In one embodiment, the standby pixel point is obtained through the following formula;
fabs(r)>1;
wherein, r is a correlation function, r = E/F, E = sum [ (Xi-Xmean) ((Yi-Ymean) ], F = sqrt { sum [ (Xi-Xmean) ((Xi-Xmean) ] } sqrt { sum [ (Yi-Ymean) × (Yi-Ymean) ] }, xmean and Ymean are the abscissa and ordinate of any angle of the four corners, and Xi and Yi are the abscissa and ordinate of the i-th pixel point in the black-and-white image frame, respectively.
In one embodiment, the straight line corresponding to the side of the rectangle is determined by the following formula:
y=a*n i +b;
wherein a = (n × C-B × D)/(n × a-B × B), B = (a × D-B × C)/(n × a-B × B), a = sum (Xi × Xi),
B=sum(Xi),C=sum(Xi*Yi),D=sum(Yi),n i the number is the ith spare pixel point, and n is the total number of the spare pixel points.
According to a second aspect of the embodiments of the present disclosure, there is provided a feature point transforming apparatus in an embedded system, the feature point transforming apparatus in the embedded system including:
the image processing device comprises a construction module, a processing module and a display module, wherein the construction module is configured to input feature points into a preset rectangle aiming at any adjacent image frame to be processed, and construct feature pixel points according to the feature points of the image frame to be processed in the rectangle;
the first determining module is configured to subtract the vertical coordinates of the characteristic pixel points at the corresponding coordinate positions in the adjacent image frames to be processed to obtain a standby image frame;
the second determining module is configured to perform Gaussian filtering and binarization on the standby image frame to obtain a black-and-white image frame;
the calculation module is configured to perform edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle;
a third determining module configured to determine a target straight line corresponding to an edge of the rectangle according to coordinates of four corners of pixel points in the black-and-white image frame based on a least square method;
a fourth determining module configured to determine a target feature point in the adjacent image frames to be processed according to an intersection point of the target straight line.
In one embodiment, the building module is configured to:
calculating the difference value between the maximum value of each color channel and the parameter value of the color channel corresponding to the characteristic point in the rectangle;
taking the difference value as a reverse color parameter value of a color channel corresponding to the characteristic point to obtain reverse color of the characteristic point;
and constructing corresponding characteristic pixel points according to the reverse color parameter values of the characteristic points of the image frame to be processed in the rectangle.
In one embodiment, the second determining module is configured to:
performing Gaussian filtering on the standby image frame through a Gaussian filtering matrix;
determining background pixel points from the Gaussian filtered image according to a preset gray threshold, and calculating the average gray value of the background pixel points to obtain a first average gray value and the average gray values of all pixel points in the Gaussian filtered image to obtain a second average gray value;
determining a binarization threshold value according to the first average gray value and the second average gray value;
and carrying out gray level binarization on the Gaussian filtered image according to the binarization threshold value to obtain a black-and-white image frame.
In one embodiment, the second determining module is configured to determine a second threshold value;
and calculating the average value of the first average gray value and the second average gray value to obtain a third average gray value, and taking the third average gray value as the binarization threshold value.
In one embodiment, the calculation module is configured to:
calculating the variance of all pixel points in the black-and-white image frame and the gradient information of adjacent pixel points;
and according to the sides of the rectangle, the variance and the gradient information, performing edge calculation on the rectangle to obtain coordinates of four corners of the rectangle.
In one embodiment, the third determining module is configured to:
screening pixel points in the black-and-white image frame according to the coordinates of the four corners to obtain standby pixel points;
and determining a target straight line corresponding to the side of the rectangle according to the spare pixel point based on a least square method.
In one embodiment, the standby pixel point is obtained through the following formula;
fabs(r)>1;
wherein r is a correlation function, r = E/F, E = sum [ (Xi-Xmean) × (Yi-Ymean) ], F = sqrt { sum [ (Xi-Xmean) ] } sqrt { sum [ (Yi-Ymean) × (Yi-Ymean) ] }, xmean and Ymean are an abscissa and an ordinate of any angle of the four angles, and Xi and Yi are respectively an abscissa and an ordinate of the i-th pixel point in the black-and-white image frame.
In one embodiment, the straight line corresponding to the side of the rectangle is determined by the following formula:
y=a*n i +b;
wherein a = (n × C-B × D)/(n × a-B × B), B = (a × D-B × C)/(n × a-B × B), a = sum (Xi × Xi),
B=sum(Xi),C=sum(Xi*Yi),D=sum(Yi),n i the number is the ith spare pixel point, and n is the total number of the spare pixel points.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the feature point transformation method in the embedded system according to any one of the first aspect.
Through the technical scheme, the following beneficial effects can be at least achieved:
inputting feature points into a preset rectangle by aiming at any adjacent image frame to be processed, and constructing feature pixel points according to the feature points of the image frame to be processed in the rectangle; subtracting the vertical coordinates of the characteristic pixel points on the corresponding coordinate positions in the adjacent image frames to be processed to obtain a standby image frame; performing Gaussian filtering and binarization on the standby image frame to obtain a black-and-white image frame; performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle; determining a target straight line corresponding to the side of the rectangle according to the coordinates of the four corners of the pixel points in the black-and-white image frame based on a least square method; and determining target characteristic points in the adjacent image frames to be processed according to the intersection points of the target straight lines. The accuracy of the transformed feature points is improved, and the resource occupation of the projector is reduced.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, embodiments accompanying figures are described in detail below. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure. This disclosure may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein.
The embodiment of the present disclosure provides a feature point transformation method in an embedded system, and fig. 1 is a flowchart of the feature point transformation method in the embedded system according to one embodiment, where the feature point transformation method in the embedded system includes the following steps:
in step S11, for any adjacent image frame to be processed, inputting feature points into a preset rectangle, and constructing feature pixel points according to the feature points of the image frame to be processed in the rectangle;
in step S12, subtracting the ordinate of the feature pixel point at the corresponding coordinate position in the adjacent image frame to be processed to obtain a standby image frame;
in step S13, gaussian filtering and binarization are performed on the spare image frame to obtain a black-and-white image frame;
in step S14, performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle;
in step S15, based on the least square method, determining a target straight line corresponding to the side of the rectangle according to the coordinates of the four corners of the pixel points in the monochrome image frame;
in step S16, a target feature point is determined in the adjacent image frames to be processed according to the intersection point of the target straight line.
According to the technical scheme, the characteristic points are input into a preset rectangle aiming at any adjacent image frame to be processed, and the characteristic pixel points are constructed according to the characteristic points of the image frame to be processed in the rectangle; subtracting the vertical coordinates of the characteristic pixel points on the corresponding coordinate positions in the adjacent image frames to be processed to obtain standby image frames; performing Gaussian filtering and binaryzation on the standby image frame to obtain a black-and-white image frame; performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle; determining a target straight line corresponding to the side of the rectangle according to the coordinates of the four corners of the pixel points in the black-and-white image frame based on a least square method; and determining target characteristic points in the adjacent image frames to be processed according to the intersection points of the target straight lines. The accuracy of the transformed feature points is improved, and the resource occupation of the projector is reduced.
In one embodiment, referring to fig. 2, in step S11, the step of constructing a feature pixel point according to a feature point of the image frame to be processed in the rectangle includes:
in step S111, calculating a difference between the maximum value of each color channel and a parameter value of the color channel corresponding to the feature point in the rectangle;
it can be understood that the maximum value of each color channel is 255, for any feature point, there are three color channels of red, green and blue, the parameter value of each color channel is subtracted from 255, and the parameter value represents the value of the color channel, so as to obtain the corresponding difference value of the feature point in the three color channels.
In step S112, taking the difference value as an inverse color parameter value of a color channel corresponding to the feature point, so as to invert the color of the feature point;
for example, for any feature point, the values of the three color channels are 122,94 and 106 respectively, and then the three values are subtracted from 255 respectively, so as to obtain the values of the inverse color parameters of the feature point, which are 133,161 and 149.
In step S113, corresponding feature pixel points are constructed according to the inverse color parameter values of the feature points of the image frame to be processed in the rectangle.
In one embodiment, referring to fig. 3, in step S13, the step of performing gaussian filtering and binarization on the spare image frame to obtain a black-and-white image frame includes:
in step S131, gaussian filtering is performed on the spare image frame through a gaussian filter matrix;
in step S132, according to a preset gray threshold, determining a background pixel point from the gaussian-filtered image, and calculating an average gray value of the background pixel point to obtain a first average gray value and average gray values of all pixel points in the gaussian-filtered image, so as to obtain a second average gray value;
exemplarily, the preset gray threshold is 127, the pixel points with the gray value greater than 127 are taken as foreground pixel points, the foreground pixel points are removed from the image after gaussian filtering, and the remaining pixel points with the gray value less than or equal to 127 are taken as background pixel points. And calculating the average value of the gray values of the background pixel points to obtain a first average gray value.
In step S133, a binarization threshold is determined according to the first average grayscale value and the second average grayscale value;
in step S134, performing grayscale binarization on the gaussian-filtered image according to the binarization threshold to obtain a black-and-white image frame.
In one embodiment, in step S133, the step of determining a binary threshold according to the first average grayscale value and the second average grayscale value includes:
and calculating the average value of the first average gray value and the second average gray value to obtain a third average gray value, and taking the third average gray value as the binarization threshold value.
In one embodiment, in step S14, the step of performing edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle includes:
calculating the variance of all pixel points in the black-and-white image frame and the gradient information of adjacent pixel points;
and according to the sides of the rectangle, the variance and the gradient information, performing edge calculation on the rectangle to obtain the coordinates of four corners of the rectangle.
In one embodiment, in step S15, the step of determining a target straight line corresponding to a side of the rectangle according to coordinates of four corners of pixel points in the black-and-white image frame based on a least square method includes;
screening pixel points in the black-and-white image frame according to the coordinates of the four corners to obtain standby pixel points;
and determining a target straight line corresponding to the side of the rectangle according to the spare pixel point based on a least square method.
In one embodiment, the standby pixel point is obtained through the following formula;
fabs(r)>1;
wherein r is a correlation function, r = E/F, E = sum [ (Xi-Xmean) × (Yi-Ymean) ], F = sqrt { sum [ (Xi-Xmean) ] } sqrt { sum [ (Yi-Ymean) × (Yi-Ymean) ] }, xmean and Ymean are an abscissa and an ordinate of any angle of the four angles, and Xi and Yi are respectively an abscissa and an ordinate of the i-th pixel point in the black-and-white image frame.
In one embodiment, the straight line corresponding to the side of the rectangle is determined by the following formula:
y=a*n i +b;
wherein a = (n × C-B × D)/(n × a-B × B), B = (a × D-B × C)/(n × a-B × B), a = sum (Xi × Xi),
B=sum(Xi),C=sum(Xi*Yi),D=sum(Yi),n i the number is the ith spare pixel point, and n is the total number of the spare pixel points.
Based on the same inventive concept, an embodiment of the present disclosure further provides a feature point transforming apparatus in an embedded system, and fig. 4 is a block diagram of the feature point transforming apparatus in the embedded system according to an embodiment of the present disclosure, where the feature point transforming apparatus 400 in the embedded system includes:
the construction module 410 is configured to input feature points into a preset rectangle for any adjacent image frame to be processed, and construct feature pixel points according to the feature points of the image frame to be processed in the rectangle;
the first determining module 420 is configured to subtract the vertical coordinates of the feature pixel points at the corresponding coordinate positions in the adjacent image frames to be processed to obtain a standby image frame;
a second determining module 430, configured to perform gaussian filtering and binarization on the spare image frame to obtain a black-and-white image frame;
the calculation module 440 is configured to perform edge calculation according to the rectangle and the pixel points in the black-and-white image frame to obtain coordinates of four corners of the rectangle;
a third determining module 450, configured to determine a target straight line corresponding to an edge of the rectangle according to coordinates of four corners of pixel points in the black-and-white image frame based on a least square method;
a fourth determining module 460 configured to determine a target feature point in the adjacent image frames to be processed according to the intersection point of the target straight line.
In one embodiment, the building module 410 is configured to:
calculating the difference value between the maximum value of each color channel and the parameter value of the color channel corresponding to the characteristic point in the rectangle;
taking the difference value as a reverse color parameter value of a color channel corresponding to the characteristic point to obtain reverse color of the characteristic point;
and constructing corresponding characteristic pixel points according to the reverse color parameter values of the characteristic points of the image frame to be processed in the rectangle.
In one embodiment, the second determining module 430 is configured to:
performing Gaussian filtering on the standby image frame through a Gaussian filtering matrix;
determining background pixel points from the Gaussian filtered image according to a preset gray threshold, and calculating the average gray value of the background pixel points to obtain a first average gray value and the average gray values of all pixel points in the Gaussian filtered image to obtain a second average gray value;
determining a binarization threshold value according to the first average gray value and the second average gray value;
and carrying out gray level binarization on the Gaussian filtered image according to the binarization threshold value to obtain a black-and-white image frame.
In one embodiment, the second determining module 430 is configured to;
and calculating the average value of the first average gray value and the second average gray value to obtain a third average gray value, and taking the third average gray value as the binarization threshold value.
In one embodiment, the calculation module 440 is configured to:
calculating the variance of all pixel points in the black-and-white image frame and the gradient information of adjacent pixel points;
and according to the sides of the rectangle, the variance and the gradient information, performing edge calculation on the rectangle to obtain coordinates of four corners of the rectangle.
In one embodiment, the third determining module 450 is configured to:
screening pixel points in the black-and-white image frame according to the coordinates of the four corners to obtain standby pixel points;
and determining a target straight line corresponding to the side of the rectangle according to the spare pixel point based on a least square method.
In one embodiment, the standby pixel point is obtained through the following formula;
fabs(r)>1;
wherein r is a correlation function, r = E/F, E = sum [ (Xi-Xmean) × (Yi-Ymean) ], F = sqrt { sum [ (Xi-Xmean) ] } sqrt { sum [ (Yi-Ymean) × (Yi-Ymean) ] }, xmean and Ymean are an abscissa and an ordinate of any angle of the four angles, and Xi and Yi are respectively an abscissa and an ordinate of the i-th pixel point in the black-and-white image frame.
In one embodiment, the straight line corresponding to the side of the rectangle is determined by the following formula:
y=a*n i +b;
wherein a = (n × C-B × D)/(n × a-B × B), B = (a × D-B × C)/(n × a-B × B), a = sum (Xi × Xi),
B=sum(Xi),C=sum(Xi*Yi),D=sum(Yi),n i the number is the ith spare pixel point, and n is the total number of the spare pixel points.
An embodiment of the present disclosure further provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the feature point transformation method in the embedded system in any one of the foregoing embodiments.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-described embodiments are merely illustrative of several embodiments of the present disclosure, which are described in more detail and detailed, but are not to be construed as limiting the scope of the disclosure. It should be noted that, for those skilled in the art, various changes and modifications can be made without departing from the concept of the present disclosure, and these changes and modifications are all within the scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the appended claims.