Summary of the invention
The object of the invention is to provide a kind of length measurement method based on mobile terminal, in order to solve the problem increasing mobile terminal cost in prior art by arranging the measurement mechanisms such as traditional tape measure.
For achieving the above object, realize of the present invention
The length-measuring appliance based on mobile terminal is utilized to carry out the method for linear measure longimetry, should based on length-measuring appliance of mobile terminal and a datum length element with the use of, the length of this datum length element is known, should comprise based on the length-measuring appliance of mobile terminal: image unit, for taking the image of datum length element and object under test; Computing unit, the pixel number that the image for calculating datum length element and object under test comprises, and the length gauge of benchmark length member calculates the length of object under test, it is characterized in that the method comprises the steps:
The image of datum length element and object under test is taken by image unit;
The pixel number that the image that computing unit calculates datum length element and object under test comprises, and the length gauge of benchmark length member calculates the length of object under test;
This image unit is the camera of YUV422 standard, the color of each pixel and brightness are represented by 8 bit data wherein, comprise Y, U, V totally 3 class data, wherein Y has four, and U has two, and V has 2, form is: Y0U0Y1V0Y2U1Y3V1, the statistical value of number of pixels, when carrying out pixel statistics, if respectively there is one digit number value different in Y, U, V data of adjacent two pixels, is then added one by computing unit;
When shared by the image of computing unit measuring targets, pixel is added up, diverse ways is adopted for difform image, wherein for the image in single pixel, if respectively there is one digit number value different in Y, U, V data of adjacent two pixels, then the statistical value of number of pixels is added one; For the image in two row's pixels, then obtain rough estimates value according to above-mentioned method, obtain pixel number shared by physical length divided by two afterwards; Row is greater than to the image of two, pixel number A=2a+2 (b-2) shared by the girth first obtaining image, wherein a represents pixel number shared by many row image length directions, b represents pixel number shared by many row picture traverse directions, so can derive pixel number a=(A-2 (b-2))/2 shared by many row image length directions; For the image in irregular figure, still many row's pixels just can according to pixel number a shared by aforesaid way statistical computation to final length for single pixel first need to judge its width, if there are 45 degree of oblique angles to connect pixel, suppose that this pixel has N number of, then introduce the correction of 2^ (1/2) during statistics, by formula a '=a+ (2^ (1/2)-1) N, thus draw pixel number a ' shared by final length.
According to above-mentioned principal character, an input block should be also comprised based on the length-measuring appliance of mobile terminal, after the image that image unit photographs datum length element and object under test, computing unit receives the order of the input of input block and determines to represent the image of object under test and the image of datum length element, thus the number of computing unit to respective image edge pixels point is added up.
According to above-mentioned principal character, pixel number shared by the image of computing unit statistics datum length element, obtained the length value of each pixel representative divided by this number by the length of datum length element, thus pixel number shared by the image counting object under test again, be multiplied by the length value of each pixel representative afterwards again and draw the length of object under test.
Compared with prior art, the present invention obtains the image of datum length element and object under test by the image unit of mobile terminal, the pixel number that the image calculating datum length element and object under test afterwards comprises, and the length gauge of benchmark length member calculates the length of object under test, so realize by image processing techniques the function measuring length, do not need the hardware setting increasing mobile terminal, thus be beneficial to the convenience and interest that increase mobile terminal use.
Embodiment
Below in conjunction with accompanying drawing, enforcement the specific embodiment of the present invention is described in detail.
Refer to shown in Fig. 1, for implementing the functional module structure schematic diagram of the length-measuring appliance based on mobile terminal of the present invention, implement the length-measuring appliance based on mobile terminal of the present invention in use usually with a datum length element with the use of, the length of this datum length element is known, and implements the length-measuring appliance based on mobile terminal of the present invention and comprise:
Image unit, for taking the image of datum length element and object under test;
Computing unit, the pixel number that the image calculating datum length element and object under test comprises, and the length gauge of benchmark length member calculates the length of object under test.
In the specific implementation, above-mentioned datum length element can be the vertical small hanging given together when buying mobile terminal, and its length is fixing known, or pointer, or the object that other length are known.And image unit is the camera of this mobile terminal, and computing unit can be the baseband processing chip of mobile terminal, and the present invention like this does not need extra element, thus is easier to implement.In addition, implement the length-measuring appliance based on mobile terminal of the present invention and also comprise an input block, this input block can be the man-machine inputting interface (as button or touch-screen etc.) of mobile terminal, after the image that image unit photographs datum length element and object under test, computing unit receives the order of the input of input block and determines to represent the image of object under test and the image of datum length element, thus the number of computing unit to respective image edge pixels point is added up.
Refer to shown in Fig. 2, for implementing the process flow diagram of the length measurement method based on mobile terminal of the present invention, implementing the length measurement method based on mobile terminal of the present invention and comprising the steps:
The image of datum length element and object under test is taken by image unit;
The pixel number that the image that computing unit calculates datum length element and object under test comprises, and the length gauge of benchmark length member calculates the length of object under test.
Refer to shown in Fig. 3, for enforcement schematic diagram of the present invention, as long as wherein pixel number shared by the image of statistics datum length element, obtained the length value u of each pixel representative divided by this number by the length of datum length element, thus pixel number shared by the image counting object under test again, be multiplied by unit length value u more afterwards, just can draw the length of object under test, realize the function of linear measure longimetry thus.
In the specific implementation, if for the camera of YUV422 standard conventional at present, its image transmitted in preview and imaging process is all made up of pixel one by one, and the color of each pixel and brightness are represented by 8 bit data wherein, and form is: Y0U0Y1V0Y2U1Y3V1.Therefore, according to this technical characterstic, we can add up pixel shared by the object edge in appointed area, namely in appointed area, adjacent two picture element point chromatic brightness have obvious difference, in the specific implementation, background is chosen and larger the carrying out of measured object color contrast is measured due to test process suggestion, so represent the Y of color and brightness in data bit respectively, U, V value has obvious difference, therefore generally can by corresponding Y (4), U (2), the different pixel of one digit number value is respectively had just to regard as obvious difference in V (2) 3 class data, just the statistical value of number of pixels is added one, and according to the imaging characteristics of testee, the statistical value of number of pixels is processed, finally pixel number shared by the image of datum length element, draw the physical length of object under test.
Because testee profile and imaging are uncertain, after its imaging, shared pixel mode is unique, for different imaging characteristicses, also different to the statistical of pixel shared by it, shown in specific as follows:
(1) for the image in single pixel
As shown in Figure 4, for the image in single pixel, only in appointed area, adjacent two picture element point chromatic brightness need have obvious difference, the standard of concrete judgement is the same, just the statistical value of number of pixels is added one, each pixel like this does not repeat contrast and statistics, and this statistical value is pixel number shared by physical length.
(2) for the image in many row's pixels
As shown in Figure 5, for the image in many row's pixels, the account form of pixel then needs to calculate on the basis of single pixel statistical.Such as, for the image only having two row's pixels, then rough estimates value is obtained pixel number shared by physical length divided by two; Row is greater than to the image of two, statistical method single at present add up that the image of many rows obtains actual be many row's images girth shared by pixel number A, so need to calculate pixel number shared by many row image length directions to it, i.e. pixel number A=2a+2 (b-2) shared by girth, wherein a represents pixel number shared by many row image length directions, b represents pixel number shared by many row picture traverse directions, so can derive pixel number a=shared by length (A-2 (b-2))/2.
(3) for the image in irregular figure
As shown in Figure 6, for the image of irregular shape, still many row's pixels just can according to pixel number a shared by aforesaid way statistical computation to final length for single pixel only need to judge its width.Wherein pixel is connected for existence 45 degree of oblique angles, suppose to have N number of, the correction then can introducing 2^ (1/2) during statistics makes statistical value more accurate, and concrete formula is a '=a+ (2^ (1/2)-1) N, thus draws pixel number a ' shared by final length.
In actual applications, because camera has distant effect, so preferably object under test and datum length element are placed on same level, image unit viewing angles-both vertical is in this plane, and select and object under test and the larger background of datum length element aberration, improve the accuracy rate of pixel statistics after imaging.Whole process also needs man-machine interaction, point out to represent the color lump of object under test and the color lump of datum length element in the image captured by image unit, thus computing unit is added up along the number of pixel corresponding color lump graph edge, draw pixel number shared by pixel number shared by object under test physical length and datum length element physical length, computing unit is according to the pixel number of the fixed-length value of the datum length element preset with the image of the datum length element recorded, obtain the length of unit picture element point representative, obtain the physical length (namely the pixel number of the image of object under test is multiplied by unit picture element point length) of determinand further.
Be understandable that, for those of ordinary skills, can be equal to according to technical scheme of the present invention and inventive concept thereof and replace or change, and all these change or replace the protection domain that all should belong to the claim appended by the present invention.