(3) summary of the invention:
1, object: the object of the present invention is to provide a kind of data of the people's pin key position based on image to extract and measuring method, to adapt to the needs of current shopping at network.The method can be obtained the data of people's pin key position, and the success ratio of shopping online can by the data that obtain as a reference, for user provides footwear code and style more accurately, improve in online shoes store.Further, these data also can be used for shoemaking manufacturer provides special customize services for consumer.Therefore, this invention can help user to select or be customized to satisfied shoes, can save again the expense that businessman produces because of the service of replacing at sales section.
2, technical scheme: the present invention is achieved through the following technical solutions.
The data of a kind of people's pin key position based on image of the present invention are extracted and measuring method, and the method comprises following four steps:
Step 1: Image Acquisition
This programme is wide by proportionate relationship calculating pin length and pin between people's pin and A4 paper, and according to the proportionate relationship between instep height and the length of pin, calculates the true altitude of instep key position.Therefore, need to take two width images, a width is that (hereinafter to be referred as front, shining) shone in the front of pin, as Fig. 1 (a) is positive, shines as shown in image acquisition mode schematic diagram, requires pin to step down on white A4 paper, and camera is taken vertically downward directly over pin; Another width is that (hereinafter to be referred as side, shining) shone in the side of pin, requires camera, from the inner side of pin, pin is carried out to side projection, if Fig. 1 (b) side is according to image acquisition mode schematic diagram.Specific requirement and operation are as follows:
1. the acquisition method of positive photograph: white A4 paper minor face one side is pasted to wall and place; User steps down in pin on A4 paper, makes the axis of pin align with the axis of A4 paper as far as possible; Heel, by wall, makes the alignment of heel position HeA4 paper edge, and the length direction of pin is consistent with the length direction of A4 paper, and it is inner to guarantee that pin drops on A4 paper completely; Camera directly over pin between 50 centimetres to 70 centimetres, take that angle is perpendicular to the ground carries out imaging, keep A4 paper not crooked in image as far as possible, and guarantee to comprise completely in visual field A4 paper region.
2. the acquisition method of side photograph; Side, according to not needing A4 paper, only needs subscriber station before wall or a pure color baffle plate, and the outside of pin is by wall or baffle plate; Camera lens is from the outside imaging of the interior side direction pin of pin, apart from 30 centimetres to 50 centimetres of the distances of side pin, takes angle and is parallel to ground, and keep same height with instep;
3. in visual field, scene will be tried one's best simply: positive as requested only comprises pin, A4 paper and floor in visual field; The background of side photograph should be simple wall or baffle plate, avoids other chaff interference to occur; Require user to wear black or other dark socks, to guarantee that there is enough large contrast contrast on pin, A4 paper and floor simultaneously.
Step 2: detect four angular vertex coordinates of A4 paper, image is carried out to geometry correction
Image tends to produce geometric distortion in the process of obtaining or showing.Geometric distortion comprises translation, convergent-divergent, rotation and perspective and more complicated geometric distortion.The equation that arbitrarily geometric distortion all can transform to distorted coordinates system (x', y') by non-distorted coordinates system (x, y) defines.Suppose that f (x, y) is undistorted original image, g (x', y') is the geometric distortion result of f (x, y), can obtain the fundamental relation formula of geometry correction, as follows:
In formula, h
1(x, y) and h
2(x, y) is for proofreading and correct transforming function transformation function.In this programme, h
1(x, y) and h
2(x, y) is similar to polynomial expression below:
Because the actual relative coordinate of four angular vertexs of standard A 4 paper is known, in this programme using four angular vertexs of A4 paper as reference mark, by image processing techniques, detect the coordinate at four angles of A4 paper in geometric distortion image, and then utilize correction transforming function transformation function and bilinear interpolation method to carry out geometry distrotion correction to distorted image.Specific implementation process is as follows:
1. row rim detection is shone into in front.Utilize Sobel operator according to image, to carry out edge extracting to front, obtain the gradient map of image.In gradient map, the edge of target has become bright band, and target and background region is because grey scale change is more smooth, therefore in gradient map, has formed dark space;
2. to gradient image binaryzation.A4 paper and the formed edge of pin target occupy very little a part of region in image, are made as 0.1 of image area.Gradient map is carried out to statistics with histogram, and the edge pixel gray-scale value of image is higher, will be distributed in histogram position on the right side, but not edge pixel concentrates on the keep left position of side of histogram.The cumulative probability of compute histograms (being the pixels statistics of image border) left from the histogram rightmost side, and be that 0.1 corresponding gray-scale value is set as threshold value by cumulative probability, the pixel that is less than threshold value is set to 255, the pixel that is greater than threshold value is set to 0, thereby extracts the edge that comprises A4 paper and pin target;
3. four of Preliminary detection A4 paper angular vertex position coordinateses.To the aforementioned the bianry image 2. obtaining in step, on transverse axis, in the scope of [5 °, 5 °], take 1 ° image is carried out to Gray Projection as step-length.Because two of the left and right longitudinal edge of A4 paper is the strong edge in image, its can form extreme value on correct projecting direction.And according to priori, A4 paper is in the centre position of image, from image centre position to both sides, detect the extreme value of Gray Projection, just can detect two longitudinal edges in left and right and their deflection.Same way can detect two widthwise edges and their deflection up and down of A4 paper.Calculate the point of crossing between two longitudinal edges in left and right and upper and lower two widthwise edges, can obtain the rough coordinates of four angular vertex positions of A4 paper.
4. accurately detect four angular vertex position coordinateses of A4 paper.3. centered by four the angular vertex position coordinateses of A4 paper that obtain in by step, the subgraph of four 140 * 140 sizes of relevant position intercepting on former gray-scale map.In four subgraphs, the ratio of the shared image area in edge is set to 0.15, repeats step above 1. to 3., can obtain the accurate coordinates of four angular vertex positions of A4 paper.
5. image is carried out to geometry correction.The relative coordinate of actual four angular vertexs of A4 paper is known, utilizes above-mentioned correction transforming function transformation function and bilinear interpolation method to carry out geometry correction to distorted image.
6. intercept A4 paper subgraph, remove useless background.After image rectification, the region at A4 paper place is exactly the rectangle of a standard, and the length breadth ratio of rectangle is exactly the length breadth ratio of A4 paper.We intercept this rectangle from image, remove background.This subgraph inside intercepting is exactly the pin target that we will detect.We carry out for this A4 paper subimage in follow-up processing.
Step 3: the target of front pin is extracted and measured
By step 2, be truncated to A4 paper subimage, we will extract pin length and wide two data of pin from this number of sub images.Specific implementation process is as follows:
(1) detection of toe position
Toe is to drop in the first half region of A4 paper, and heel is to align with the base of A4 paper.Therefore can detect in the first half of A4 paper subgraph the position of toe, and it is long according to the proportionate relationship of pin and A4 paper, to calculate pin.Detailed process is:
1. intercept A4 paper subimage the first half subarea, utilize Sobel operator to carry out rim detection; According to priori, the edge that pin target forms in this subarea accounts for 0.06 of subarea area, and this programme carries out threshold value selection with 0.06 area ratio, and binaryzation is carried out in subarea.
2. in bianry image, have the noise spot being scattered, adopt closing operation of mathematical morphology to carry out filtering to binary map, the size of computing template is 5 * 5
3. to the bianry image after denoising, press from the top down each impact point of line search.Centered by this impact point, get 5 * 8 window, by the upper and lower doubling of window, on former gray-scale map, add up the gray scale difference of correspondence position in doubling window, and be averaging.And first meets gray scale difference mean value be greater than 30 impact point be the position of toe, with (x, y), represent.
(2) position probing of first metatarsal bone and fifth metatarsal bone
From professional angle, the width of sole refers to the distance between the first metatarsal bone of pin (inner side of pin) and fifth metatarsal bone (outside of pin).And first metatarsal bone is positioned at 69.5% position from heel to toe, fifth metatarsal bone is positioned at 62.5% position from heel to toe.Because first metatarsal bone and fifth metatarsal bone lay respectively at the both sides of sole, we detect this position of 2 by following process:
1. rim detection filtering are carried out in the subarea at forefoot place.Similar with the process of toe position probing, rim detection is carried out in the region, edge at the wide place of pin, and use closing operation of mathematical morphology filtering;
2. determine the horizontal ordinate position of first metatarsal bone.On A4 paper subgraph, the ordinate of corresponding 69.5% position from heel to toe, with 1 * 16 window, search for from right to left, by the right left doubling of window, on former gray-scale map, add up the gray scale difference of correspondence position in doubling window, it is exactly first metatarsal bone position that the average of gray scale difference is greater than 25 position, and the horizontal ordinate at this some place is designated as to x
inner.
3. determine the horizontal ordinate position of fifth metatarsal bone.2. similar with step, at heel, to 62.5% position of toe, with 1 * 16 window, to search for from left to right, first meets window left and right doubling gray scale difference mean value, and to be greater than 25 position be exactly the position of fifth metatarsal bone, and the horizontal ordinate at this some place is designated as to x
outer.
(3) pin length and the wide calculating of pin
The normal size of A4 paper is 210 millimeters * 297 millimeters.Suppose that A4 paper subgraph is the capable N row of M, making the A4 paper subimage lower left corner is true origin, if the coordinate of toe position in subimage is (x, y), the physical length of pin is 297 * y/M millimeter.Suppose that the sole width number of pixels of extracting is c on A4 paper subimage, by the abscissa value of first metatarsal bone and fifth metatarsal bone, can obtain c=x
inner-x
outer, and the developed width of pin is 210 * c/N millimeter.
Step 4: the target of side pin is extracted and measured
The side of pin is for extracting the height of key position instep according to image.From heel to toe 2/5,1/2 and 3/4, the instep height at these positions is shoe last designing important parameters used.While selecting footwear code, the people that instep is high can select than the footwear code of large one of normal foot, or in customization shoes, can suitably increase the height of shoe tree.Side is according in image, and heel to the distance of toe is exactly that pin is long, and from vola to instep just correspondence the pin of relevant position high.Suppose side according in heel in the left side of image, toe is on right side, the instep of key position detect and height measurement method as follows:
(1) detect heel and toe
Heel and toe be in the latter half of image, and in the image left and right sides, formed two edges longitudinally.Therefore at image in 1/2 interval from bottom to height, edge longitudinally in detected image, can navigate to the position of heel and toe.Detailed process is as follows:
1. adopt the gradient template of horizontal direction to carry out rim detection to image, the longitudinal edge of outstanding toe and heel.The template that adopts as follows:
2. the edge of heel and toe area occupied ratio in image is 0.1, with this area ratio as threshold value to image binaryzation, obtain edge binary map;
3. use 5 * 8 windows from left to right by row search, suppose that in window, impact point number is n, first window position that meets (n/ (5 * 8)) >0.9 is exactly the rough position of heel, with (x'
0, y'
0) expression, wherein x'
0for the horizontal ordinate of heel rough position, y'
0for ordinate.
4. with heel position coordinates (x'
0, y'
0) centered by, the subwindow of intercepting 20 * 20 carries out fine searching to heel position in window.Adopt gradient template [1-1] the calculation window inside gradient of x direction, the greatest gradient position of every row in search window, horizontal ordinate statistics is carried out in greatest gradient position to all row, has the accurate horizontal ordinate that maximum horizontal ordinates is heel position, and we use (x
0, y
0) represent the accurate coordinates position of heel.
5. same process, when starting left by row search from image right side, can obtain the coordinate position (x of toe
1, y
1).
(2) detect vola
Vola is positioned at the below of toe and heel ordinate, contacts with floor, has formed horizontal edge.But because there is radian at the arch of foot place of pin, so the edge that the bottom of pin becomes on image is not straight line.Thus, we using the bottom position of forefoot and as position, vola, detect the height at 1/2 and 3/4 place, and the bottom position of hind paw of usining detects 2/5 height as position, vola.Forefoot is generally 1/3 of pin length, and its horizontal ordinate is at [x
0-(x
1-x
0) * 2/3, x
1] in interval, the vola testing process of this position is:
1. with the gradient template of vertical direction, image is carried out to rim detection, outstanding transverse edge, template is;
2. on transverse edge image, horizontal ordinate is [x
0-(x
1-x
0) * 2/3, x
1], ordinate is [0, min (y
0, y
1)] interval in, the gray-level projection of calculated level direction, the ordinate at the row place of integrated value maximum is the ordinate in vola, is designated as y
2.
Hind paw vola detection method is similar.
(3) key position of instep detects
This sentences 1/2 is example from heel to toe, and the key position of introducing instep detects.Based on experience value, 1/2 place's instep height of people's pin is approximately 1/3 long left and right of pin, and therefore, the horizontal ordinate of 1/2 place's instep is (x
0+ x
1)/2, ordinate are approximately y
2+ (x
1-x
0)/3.Intercept the subarea window at 1/2 instep place, place, adopt region-growing method to cut apart this window area, in region, be divided into target and background two parts.Instep is the separatrix of target and background, and horizontal ordinate is (x
0+ x
1the separation at place)/2 is exactly people's pin 1/2 instep position, place, and we use y
3the ordinate that represents this point.
Same process, we can extract the instep position at 2/5 place and 3/4 place.
(4) the key position true altitude of instep is calculated
By above step, the distance between the toe of side photograph and sufficient heel is x
1-x
0individual pixel, 1/2 place's instep height is y
3-y
1individual pixel.According to pin, the long and pin proportionate relationship between high, can show that the true altitude of 1/2 place's instep is
we can calculate the instep height at 3/4 place and 2/5 place the same manner.
3, advantage and effect
Advantage of the present invention is: by standard A 4 paper as a reference, can effectively obtain the data of the key position of pin by geometry correction, image processing techniques.In 50 groups of view data that gather, pin is long, pin is wide and the height measurement results error of instep key position all within 2 millimeters.
According to footwear code and the long general computing formula of pin
According to half yardage error of calculation, can obtain the long error of pin within 2.5 millimeters, the error that and pin wide in conjunction with pin is high again and shoemaker's shoemaking standard used, pin is long, pin is wide and the measurement result maximum error of crucial instep height fixes on 2 millimeters, demand in the time of can meeting the person that purchases footwear and selecting footwear code and shoemaker's shoemaking, and methods experiment resultant error of the present invention is all within 2 millimeters.
(5) embodiment
In order to understand better technical scheme of the present invention, below in conjunction with accompanying drawing, embodiments of the present invention are further described:
The present invention realizes in conjunction with opencv1.0 under Microsoft Visual C++6.0 programmed environment.Positive, pin wide measurement procedure long according to pin is as shown in Fig. 2 (a), and process flow diagram 2 (b) is seen according to the measurement of instep key position height in side.Allocation of computer adopts: Intel Core i2E7300 processor, and dominant frequency 2.66GHz, internal memory 3GB, operating system is 32-bit Windows XP professional version.The data of this people's pin key position are extracted with measuring method and are comprised the following steps:
Step 1: press Fig. 1 (a), Fig. 1 (b), the form of image acquisition mode schematic diagram gathers positive photograph and side photograph, and concrete acquisition method is as follows:
1. the acquisition method of positive photograph: white A4 paper minor face one side is pasted to wall and place; User steps down in pin on A4 paper, makes the axis of pin align with the axis of A4 paper as far as possible; Heel, by wall, makes the alignment of heel position HeA4 paper edge, and the length direction of pin is consistent with the length direction of A4 paper, and it is inner to guarantee that pin drops on A4 paper completely; Camera directly over pin between 50 centimetres to 70 centimetres, take that angle is perpendicular to the ground carries out imaging, keep A4 paper not crooked in image as far as possible, and guarantee to comprise completely in visual field A4 paper region.
2. the acquisition method of side photograph; Side, according to not needing A4 paper, only needs subscriber station before wall or a pure color baffle plate, and the outside of pin is by wall or baffle plate; Camera lens is from the outside imaging of the interior side direction pin of pin, apart from 30 centimetres to 50 centimetres of the distances of side pin, takes angle and is parallel to ground, and keep same height with instep;
3. in visual field, scene will be tried one's best simply: positive as requested only comprises pin, A4 paper and floor in visual field; The background of side photograph should be simple wall or baffle plate, avoids other chaff interference to occur; Require user to wear black or other dark socks, to guarantee that there is enough large contrast contrast on pin, A4 paper and floor simultaneously.
Step 2: detect four angular vertex coordinates of A4 paper, image is carried out to geometry correction;
Specific implementation process is as follows:
1. Sobel operator is 3 * 3 the field based on gradient operator.The convolution mask of Sobel operator is by detection level direction gradient template
With detection of vertical direction gradient template
Form.Two templates are applied to respectively the positive image that shines, and root is opened in the horizontal direction of each pixel and square summation of the Grad of vertical direction again, can obtain the positive gradient map according to image;
2. rule of thumb, the area ratio of place, edge gradient map image accounts for 0.1.So, this method is by the histogram of statistical gradient figure, from gray-scale value, be 255 to start to calculate cumulative probability, by cumulative probability, be that 0.1 corresponding gray-scale value is set as threshold value, the pixel that is less than threshold value is set to 255, the pixel that is greater than threshold value is set to 0, thereby extracts the binary image that comprises A4 paper and pin object edge;
3. bianry image step being obtained in 2., on transverse axis, in the scope of [5 °, 5 °], take 1 ° image is carried out to Gray Projection as step-length.A4 paper is in the centre position of image, from image centre position to both sides, detects the extreme value of Gray Projection, detects two longitudinal edges in left and right and their deflection.Same way can detect two widthwise edges and their deflection up and down of A4 paper.Calculate the point of crossing between two longitudinal edges in left and right and upper and lower two widthwise edges, can obtain the rough coordinates of four angular vertex positions of A4 paper.
4. centered by four the angular vertex position coordinateses of A4 paper that obtain in 3. by step, the subgraph of four 140 * 140 sizes of relevant position intercepting on former gray-scale map.In four subgraphs, the ratio of the shared image area in edge is set to 0.15, repeats step above 1. to 3., can obtain the accurate coordinates of four angular vertex positions of A4 paper.
5. the relative coordinate of actual four angular vertexs of A4 paper is known, and transformation for mula is proofreaied and correct in the coordinate figure by four angular vertexs of A4 paper on correcting image and the substitution of actual coordinate value:
Wherein, x is the abscissa value on the summit on correcting image, and x' is corresponding actual abscissa value, and y is the abscissa value on the summit on correcting image, and y' is corresponding actual abscissa value.8 unknown numbers of 8 equations, solve a
i(i=0,1,2,3,4,5,6,7), obtain the correction transforming function transformation function of image.
Utilize above-mentioned the correction transforming function transformation function solving and bilinear interpolation method to carry out geometry correction to distorted image.
6. in the image from proofreading and correct, intercept rectangular area, A4 paper place, remove background.Obtain the A4 paper subimage with pin target.
Step 3: the target of front pin is extracted and measured;
By step 2, be truncated to A4 paper subimage, from this number of sub images, extract pin length and wide two data of pin.Specific implementation process is as follows:
(1) detection of toe position
Toe is to drop in the first half region of A4 paper, and sufficient heel is to align with the base of A4 paper.Therefore can detect in the first half of A4 paper subgraph the position of toe, and it is long according to the proportionate relationship of pin and A4 paper, to calculate pin.Detailed process is:
1. intercept A4 paper subimage the first half subarea, utilize Sobel operator to carry out rim detection, the area ratio with 0.06 carries out threshold value selection, and binaryzation is carried out in subarea.
2. in bianry image, have the noise spot being scattered, adopt closing operation of mathematical morphology to carry out filtering to binary map, the size of computing template is 5 * 5
3. to the bianry image after denoising, press from the top down each impact point of line search.Centered by this impact point, get 5 * 8 window, by the upper and lower doubling of window, on former gray-scale map, add up the gray scale difference of correspondence position in doubling window, and be averaging.And first meets gray scale difference mean value be greater than 30 impact point be the position of toe, with (x, y), represent.
(2) position probing of first metatarsal bone and fifth metatarsal bone
Because first metatarsal bone and fifth metatarsal bone lay respectively at the both sides of sole, by following process, detect this position of 2:
1. rim detection filtering are carried out in the subarea at forefoot place.Similar with the process of toe position probing, to the region, edge at the wide place of pin, utilize the longitudinal template of Sobel operator to carry out longitudinal edge detection, and use closing operation of mathematical morphology filtering;
2. determine the horizontal ordinate position of first metatarsal bone.On A4 paper subgraph, the ordinate of corresponding 69.5% position from heel to toe, with 1 * 16 window, search for from right to left, by the right left doubling of window, on former gray-scale map, add up the gray scale difference of correspondence position in doubling window, it is exactly first metatarsal bone position that the average of gray scale difference is greater than 25 position, and the horizontal ordinate at this some place is designated as to x
inner.
3. determine the horizontal ordinate position of fifth metatarsal bone.2. similar with step, at heel, to 62.5% position of toe, with 1 * 16 window, to search for from left to right, first meets window left and right doubling gray scale difference mean value, and to be greater than 25 position be exactly the position of fifth metatarsal bone, and the horizontal ordinate at this some place is designated as to x
outer.
(3) pin length and the wide calculating of pin
The size of A4 paper subimage is M * N, and its actual size is 210 millimeters * 297 millimeters.Toe coordinate is (x, y), and the physical length of pin is 297 * y/M millimeter, and the developed width of pin is 210 * (x
inner-x
outer)/N millimeter.
Step 4: the target of side pin is extracted and measured;
Suppose side according to mesopodium heel in the left side of image, toe is on right side, the detection of instep key position and height measurement method are as follows:
(1) detect heel and toe
In 1/2 interval at image from bottom to height, edge longitudinally in detected image, can navigate to the position of heel and toe.Detailed process is as follows:
1. adopt the gradient template of vertical direction to carry out rim detection to image, the longitudinal edge of outstanding toe and heel.The template that adopts as follows:
2. the edge of heel and toe area occupied ratio in image is 0.1, with this area ratio as threshold value to image binaryzation, obtain edge binary map;
3. use 5 * 8 window from left to right by row search, suppose that in window, impact point number is n, the position rough position (x' that first window position that meets n/ (5 * 8) >25 is exactly sufficient heel
0, y'
0).With (x'
0, y'
0) centered by 20 * 20 windows in fine searching, determine the exact position (x of heel
0, y
0).
4. same process, when starting left by row search from image right side, navigates to the exact position (x of toe
1, y
1).
(2) detect vola
The bottom position of forefoot of usining detects as position, vola.Forefoot is generally 1/3 of pin length, and its horizontal ordinate is positioned at (x
0-(x
1-x
0) * 2/3, x
1), the vola testing process of this position is:
1. with the gradient template of horizontal direction, image is carried out to rim detection, outstanding transverse edge, template is;
2. on transverse edge image, horizontal ordinate is (x
0-(x
1-x
0) * 2/3, x
1), ordinate is (0, min (y
0, y
1)) interval in, the gray-level projection of calculated level direction, the ordinate at the row place of integrated value maximum is the ordinate in vola, is designated as y
2.
(3) detection of instep key position
The instep height of 2/5,1/2,3/4 position from heel to toe is the critical data of pin.This sentences 1/2 is example from sufficient heel to toe, introduces the detection of instep key position.
The horizontal ordinate of 1/2 place's instep is (x
0+ x
1)/2, ordinate are approximately y
2+ (x
1-x
0)/3.Intercept the subarea window at 1/2 instep place, place, adopt region-growing method to cut apart this window area, in region, be divided into target and background two parts.Instep is the separatrix of target and background, and horizontal ordinate is (x
0+ x
1the separation at place)/2 is exactly people's pin 1/2 instep position, place, uses y
3represent.
Same process, we can extract the instep position at 2/5 place and 3/4 place.Wherein, the instep height at 2/5 place is usingd hind paw bottom and is calculated as vola.
(4) true altitude of instep key position is calculated
According to pin, the long and pin proportionate relationship between high, can show that the true altitude of 1/2 place's instep is
we can calculate the instep height at 3/4 and 3/5 place the same manner.