CN114663287A - Control method of mobile phone scanner based on visual algorithm - Google Patents

Control method of mobile phone scanner based on visual algorithm Download PDF

Info

Publication number
CN114663287A
CN114663287A CN202210367479.7A CN202210367479A CN114663287A CN 114663287 A CN114663287 A CN 114663287A CN 202210367479 A CN202210367479 A CN 202210367479A CN 114663287 A CN114663287 A CN 114663287A
Authority
CN
China
Prior art keywords
point
picture
points
topleft
algorithm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210367479.7A
Other languages
Chinese (zh)
Inventor
张少举
吴海荣
林辉
王晨
黄根华
陈林
葛宝
张静
王宗玥
朱国印
杨彪
王超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Minshang Digital Technology Shenzhen Co ltd
Original Assignee
Minshang Digital Technology Shenzhen Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Minshang Digital Technology Shenzhen Co ltd filed Critical Minshang Digital Technology Shenzhen Co ltd
Priority to CN202210367479.7A priority Critical patent/CN114663287A/en
Publication of CN114663287A publication Critical patent/CN114663287A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04MTELEPHONIC COMMUNICATION
    • H04M1/00Substation equipment, e.g. for use by subscribers
    • H04M1/72Mobile telephones; Cordless telephones, i.e. devices for establishing wireless links to base stations without route selection
    • H04M1/724User interfaces specially adapted for cordless or mobile telephones
    • H04M1/72403User interfaces specially adapted for cordless or mobile telephones with means for local support of applications that increase the functionality
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/04Scanning arrangements, i.e. arrangements for the displacement of active reading or reproducing elements relative to the original or reproducing medium, or vice versa

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Image Processing (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to a control method of a mobile phone scanner based on a visual algorithm, wherein the scanner (1) obtains the resolution of a camera; (2) acquiring a picture according to a frame rate fps (frame rate) of 20, and scaling the picture according to a width of 500 pixels in an equal proportion manner; (3) carrying out picture graying treatment, detecting chromatic aberration to obtain a Threshold, and whitening the picture; (4) softening the picture by Gaussian filtering; (5) marking outline core point positions; (6) obtaining the core point position of the contour through an approximation algorithm: (7) selecting a picture outline meeting the requirements; zooming and restoring according to the step (5); a clipper (8) making initial boundary points as parameters; (9) connecting four side boundaries clockwise to form a quadrangle, covering the quadrangle on an original drawing, and setting anchor points at the four side boundaries respectively for dragging; (10) based on the coordinate vector, according to the four points and the length and width side length, the length and width of the target document are taken; (11) and pixel projection, namely filling pixels in a target range on the original picture into a new document matrix.

Description

Control method of mobile phone scanner based on visual algorithm
Technical Field
The invention belongs to the technical field of scanning, and particularly relates to a control method of a mobile phone scanner based on a visual algorithm.
Background
Due to the maturity of the visual algorithm, the document scanning work inside the enterprise is completely finished by a more convenient mobile phone, and a heavy physical scanner is not needed any more. And the mobile phone is carried about, and can be used for photographing and scanning anytime and anywhere, so that the mobile phone is more friendly to people who frequently go on a business trip.
The current visual algorithm library OpenCV spans computer platforms, is easily integrated to the application of various platforms of enterprises, and is not limited to Android, IOS, Windows, Linux, Unix and other systems.
Disclosure of Invention
The invention aims to provide a control method of a mobile phone scanner based on a visual algorithm, aiming at the problems that the scanning quality of the traditional scanning instrument cannot be stably output, the position of a document during scanning and the saturation of carbon powder can cause distortion, and especially when a plurality of documents are scanned in batches, the distortion rate of the result of the subsequent scanning is higher, and the subsequent work flow is influenced.
The technical solution of the invention is that the control method of the mobile phone scanner based on the visual algorithm comprises a scanner and a cutter, and is characterized in that,
the control method of the scanner comprises the following steps:
(1.1) traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
(1.2) collecting original pictures according to a frame rate fps (frame rate fps) of 20, and scaling the collected pictures uniformly according to an aspect ratio by 500 pixels;
(1.3) converting the color space of the picture from YUV to Gray, and carrying out graying processing;
(1.4) softening the picture by using Gaussian filtering to ensure that the pixel distribution is softer and the gray characteristic is not lost so as to keep the original characteristic of the picture;
(1.5) starting contour detection and marking the core point positions of the contour; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
(1.6) putting each contour point location into a coordinate system, and calculating the radian of the point location structure;
(1.7) extracting core four point positions meeting the conditions according to the point position characteristics of the quadrangle by combining the radians, wherein the core four point positions are arranged in a clockwise way: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline by an approximation algorithm (Ramer-Douglas-Peucker):
(1.8) further screening the detected plurality of profiles: the offset amplitude in the horizontal and vertical directions and the limit of the minimum side length, the outline has a closed characteristic and is a trapezoid;
(1.9) selecting a picture outline meeting the setting requirement, wherein the picture outline is an approximate rectangle; restoring according to the scaling strategy of the step (1.5); transmitting the scanned original picture and the positions of the angular points to a cutter;
the control method of the cutter comprises the following steps:
(2.1) taking the scanned original picture and the initial boundary point obtained from the scanner as parameters;
(2.2) connecting the four boundaries clockwise to form a quadrangle which covers the original image, and setting an anchor point at each of the four boundary points to drag the four boundary points along the direction of the corner point;
(2.3) cutting the picture into a standard rectangle on the assumption that the angular point just covers the document;
(2.4) based on the coordinate vector, calculating 4 side lengths of the length and the width according to four points, and taking the maximum value of the side lengths as the length and the width of the target document respectively;
and (2.5) pixel projection is carried out, pixels in a target range on the original picture are filled into a new document matrix, and because the area of the document matrix is certainly larger than that of an original projection source, the insufficient part is filled by using adjacent pixels.
Preferably, the method comprises the following steps: the graying processing of the step (1.3) further comprises: the Threshold value Threshold is obtained by automatically detecting the chromatic aberration, the whole picture is grayed out based on the Threshold value Threshold, the target is more prominent after graying, and the extra operation amount brought by the color space is also reduced.
Preferably, the method comprises the following steps: the topLeft point detection method in the step (1.6) comprises the following steps:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y2), bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft.
Preferably, the method comprises the following steps: the specific method for selecting the picture contour meeting the setting requirement in the step (1.7) comprises the following steps:
a. controlling four side lengths, subtracting the same coordinate from two adjacent left sides to obtain an upper side length by Math.abs (topRight.x-topleft.x), and analogizing other three side lengths in turn to control the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, and taking this absolute value as the offset, the offset is too large, which may cause distortion of the cropped picture.
Preferably, the method comprises the following steps: the approximation algorithm for obtaining the position of the core point on the contour in the step (1.7) further comprises:
(1.7.1) the starting curve is an ordered set of points or lines, the distance dimension ε > 0; the algorithm recursively divides the lines;
(1.7.2) initially, it gives all points between the first and last points, and automatically marks the first and last points to be kept;
(1.7.3) then finding the point farthest from the line segment with the first point and the last point as end points; this is obviously the point on the curve that is furthest from the approximate line segment between the end points;
(1.7.4) if the point is closer to the line segment than ε, discarding any points that are not currently marked as retained, while the simplified curve is not worse than ε;
(1.7.5) if the farthest point of the offline segment is more than approximately epsilon, then that point must be retained; the algorithm recursively calls itself using a first point and a farthest point, calls itself using a farthest point and a last point, including the farthest point marked as reserved;
(1.7.6) when the recursion is complete, a new output curve is generated that contains all and only those points that have been marked as reserved.
The other technical solution of the present invention is a control method of a mobile phone scanner based on a visual algorithm, which is characterized by comprising the following steps:
traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
secondly, collecting original pictures according to a frame rate fps ═ 20, and scaling the collected pictures uniformly according to a width of 500 pixels according to an aspect ratio;
thirdly, converting the color space of the picture from YUV to Gray, carrying out graying processing, automatically detecting chromatic aberration to obtain a Threshold, graying the whole picture based on the Threshold, and reducing the extra operation amount brought by the color space, wherein the target is more prominent after graying;
fourthly, softening the picture by using Gaussian filtering to enable the pixel distribution of the picture to be softer without losing the gray characteristic so as to keep the original characteristic of the picture;
fifthly, carrying out contour detection and marking the core point positions of the contours; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
sixthly, putting each contour point position into a coordinate system, and calculating the radian of a point position structure; the method for detecting the topLeft point comprises the following steps:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y 2); bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft;
and according to the point location characteristics of the quadrangle, extracting core four point locations meeting the conditions according to the radian, wherein the four point locations are arranged in a clockwise mode: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline by an approximation algorithm (Ramer-Douglas-Peucker): the specific method for selecting the picture contour meeting the setting requirement comprises the following steps:
a. controlling 4 side lengths, two adjacent left sides, subtracting the same coordinate, Math.
x-topleft.x) to obtain the upper side length, analogizing other 3 side lengths in turn, and controlling the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, taking this absolute value as the offset, the offset is too large, which may cause distortion of the clipped picture;
the approximation algorithm for obtaining the core point position on the contour further comprises:
(7.1) the starting curve is an ordered set of points or lines, the distance dimension epsilon > 0; the algorithm recursively divides the lines;
(7.2) initially, it gives all points between the first point and the last point, and automatically marks the first and last points to be kept;
(7.3) then finding a point farthest from the line segment with the first point and the last point as end points; this is obviously the point on the curve that is furthest from the approximate line segment between the end points;
(7.4) if the point is closer to the line segment than ε, discarding any points that are not currently marked as retained, and the simplified curve will not be worse than ε;
(7.5) if the point farthest from the offline segment is more than approximately epsilon, then that point must be retained; the algorithm recursively calls itself using the first point and the farthest point, calls itself using the farthest point and the last point, including the farthest point marked as retained;
(7.6) when the recursion is complete, generating a new output curve containing all and only those points that have been marked as reserved;
and further screening the detected plurality of contours: the offset amplitude in the horizontal and vertical directions and the limit of the minimum side length, the outline has a closed characteristic and is a trapezoid;
selecting a picture contour meeting a set requirement from a self-skin, wherein the picture contour is an approximate rectangle; reducing according to the scaling strategy of the step fifthly; and transmitting the scanned original picture and the positions of the angular points to a clipper.
The invention also provides a technical scheme of the control method of the mobile phone scanner clipping device based on the visual algorithm, which is characterized by comprising the following steps:
taking an original picture after receiving scanning and an initial boundary point obtained from a scanner as parameters;
connecting the four boundaries clockwise to form a quadrangle, covering the quadrangle on the original drawing, and setting an anchor point at each of the four boundary points to drag the quadrangle according to the direction of the corner point;
thirdly, if the angular point just covers the document at the moment, cutting the picture into a standard rectangle;
fourthly, based on the coordinate vector, calculating 4 side lengths of the length and the width according to four points, and taking the maximum value of the side lengths as the length and the width of the target document;
fifthly, pixel projection is carried out, pixels in the target range on the original picture are filled into a new document matrix, and because the area of the document matrix is larger than that of the original projection source, and the insufficient parts are filled by using adjacent pixels.
Compared with the prior art, the invention has the beneficial effects that:
the method has the advantages of convenient integration: all enterprises can conveniently expand the application in the enterprises based on the technical scheme of the application, and the method is not limited to pay scanning software on the market and does not need to worry about enterprise data leakage.
The invention comprises two core components: a scanner and a clipper. The cutter and the scanner work independently, and the cutter and the scanner are connected in series to complete the whole scanning and archiving process.
The vision algorithm library OpenCV is adopted to cross computer platforms, and is easily integrated to the application of various platforms of enterprises, and the vision algorithm library is not limited to Android, IOS, Windows, Linux, Unix and other systems.
Drawings
FIG. 1 is a flow chart of the control of a mobile phone scanner based on a vision algorithm according to the present invention;
fig. 2 is a control flow chart of the mobile phone scanner clipper based on the visual algorithm of the invention.
Detailed Description
The invention will be described in more detail below with reference to the accompanying drawings:
referring to fig. 1 and 2, a method for controlling a mobile phone scanner based on a visual algorithm includes a scanner and a clipper,
the control method of the scanner comprises the following steps:
(1.1) traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
(1.2) collecting an original picture according to a frame rate fps (frame rate fps) of 20, and scaling the collected picture according to an aspect ratio by 500 pixels;
(1.3) graying the reduced picture, automatically detecting chromatic aberration to obtain a Threshold, graying the whole picture based on the Threshold, wherein the target is more prominent after graying, and the extra operation amount brought by a color space is reduced;
(1.4) softening the picture by using Gaussian filtering to keep the original characteristics of the picture;
(1.5) starting contour detection and marking the core point positions of the contour; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
(1.6) the profile has a closed character and is a trapezoid with four vertices arranged clockwise: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline through an approximation algorithm:
the topLeft point detection method in the step (1.6) comprises the following steps:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y2), bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft;
(1.7) selecting a picture outline meeting the set requirement, wherein the picture outline is an approximate rectangle; restoring according to the scaling strategy of the step (1.5); transmitting the scanned original picture and the positions of the angular points to a cutter;
the specific method for selecting the picture contour meeting the setting requirement in the step (1.7) comprises the following steps:
a. controlling 4 side lengths, two adjacent left sides, subtracting the same coordinate, Math.
x-topleft.x) to obtain the upper side length, analogizing other 3 side lengths in turn, and controlling the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, taking this absolute value as the offset, the offset is too large, which may cause distortion of the clipped picture;
the control method of the cutter comprises the following steps:
(2.1) taking the scanned original picture and the initial boundary point obtained from the scanner as parameters;
(2.2) connecting the four boundaries clockwise to form a quadrangle which covers the original image, and setting an anchor point at each of the four boundary points to drag the four boundary points along the direction of the corner point;
(2.3) cutting the picture into a standard rectangle on the assumption that the angular point just covers the document;
(2.4) based on the coordinate vector, calculating 4 side lengths of the length and the width according to four points, and taking the maximum value of the side lengths as the length and the width of the target document respectively;
(2.5) pixel projection is carried out, pixels in a target range on the original picture are filled into a new document matrix, and because the area of the document matrix is larger than that of an original projection source, the insufficient part is filled by using adjacent pixels.
Referring to fig. 1, the method for controlling a scanner of a mobile phone scanner based on a visual algorithm includes the following steps:
traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
secondly, collecting original pictures according to a frame rate fps ═ 20, and scaling the collected pictures uniformly according to a width of 500 pixels according to an aspect ratio;
thirdly, converting the color space of the picture from YUV to Gray, carrying out graying processing, automatically detecting chromatic aberration to obtain a Threshold, graying the whole picture based on the Threshold, and reducing the extra operation amount brought by the color space, wherein the target is more prominent after graying;
fourthly, softening the picture by using Gaussian filtering to enable the pixel distribution of the picture to be softer without losing the gray characteristic so as to keep the original characteristic of the picture;
fifthly, carrying out contour detection and marking core point positions of the contours; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
sixthly, putting each contour point position into a coordinate system, and calculating the radian of a point position structure; the method for detecting the topLeft point comprises the following steps:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y2), bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft;
and according to the point location characteristics of the quadrangle, extracting core four point locations meeting the conditions according to the radian, wherein the four point locations are arranged in a clockwise mode: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline by an approximation algorithm (Ramer-Douglas-Peucker): the specific method for selecting the picture contour meeting the setting requirement comprises the following steps:
a. controlling 4 side lengths, subtracting the same coordinate from two adjacent left sides to obtain an upper side length by Math.abs (topRight.x-topleft.x), and analogizing other 3 side lengths in turn to control the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, taking this absolute value as the offset, the offset is too large, which may cause distortion of the clipped picture;
the approximation algorithm for obtaining the core point position on the contour further comprises:
(7.1) the starting curve is an ordered set of points or lines, the distance dimension epsilon > 0; the algorithm recursively divides the lines;
(7.2) initially, it gives all points between the first point and the last point, and automatically marks the first and last points to be kept;
(7.3) then finding a point farthest from the line segment with the first point and the last point as end points; this is obviously the point on the curve furthest from the approximate line segment between the endpoints;
(7.4) if the point is closer to the line segment than ε, discarding any points that are not currently marked as retained, while the reduced curve is no worse than ε;
(7.5) if the point farthest from the offline segment is more than approximately epsilon, then that point must be retained; the algorithm recursively calls itself using a first point and a farthest point, calls itself using a farthest point and a last point, including the farthest point marked as reserved;
(7.6) when the recursion is complete, generating a new output curve containing all and only those points that have been marked as reserved;
and further screening the detected plurality of contours: the offset amplitude in the horizontal and vertical directions and the limit of the minimum side length, the outline has a closed characteristic and is a trapezoid;
selecting a picture contour meeting a set requirement from a self-skin, wherein the picture contour is an approximate rectangle; reducing according to the scaling strategy of the step fifthly; and transmitting the scanned original picture and the positions of the angular points to a clipper.
Referring to fig. 2, the method for controlling a clipper of a mobile phone scanner based on a visual algorithm includes the following steps:
taking an original picture after receiving scanning and an initial boundary point obtained from a scanner as parameters;
connecting the four boundaries clockwise to form a quadrangle, covering the quadrangle on the original drawing, and setting an anchor point at each of the four boundary points to drag the quadrangle according to the direction of the corner point;
thirdly, if the angular point just covers the document at the moment, cutting the picture into a standard rectangle;
fourthly, based on the coordinate vector, calculating 4 side lengths of the length and the width according to four points, and taking the maximum value of the side lengths as the length and the width of the target document;
fifthly, pixel projection is carried out, pixels in the target range on the original picture are filled into a new document matrix, and because the area of the document matrix is larger than that of the original projection source, and the insufficient parts are filled by using adjacent pixels.
The above-mentioned embodiments are only preferred embodiments of the present invention, and all equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the claims of the present invention.

Claims (7)

1. A control method of a mobile phone scanner based on a visual algorithm comprises a scanner and a cutter, and is characterized in that the control method of the scanner comprises the following steps:
(1.1) traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
(1.2) collecting original pictures according to a frame rate fps (frame rate fps) of 20, and scaling the collected pictures according to an aspect ratio by uniformly according to 500 pixels of the pictures;
(1.3) converting the color space of the picture from YUV to Gray, and carrying out graying processing;
(1.4) softening the picture by using Gaussian filtering to ensure that the pixel distribution is softer and the gray characteristic is not lost so as to retain the original characteristic of the picture;
(1.5) starting contour detection and marking the core point positions of the contour; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
(1.6) putting each contour point location into a coordinate system, and calculating the radian of the point location structure;
(1.7) extracting core four point positions meeting the conditions according to the point position characteristics of the quadrangle by combining the radians, wherein the core four point positions are arranged in a clockwise way: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline by an approximation algorithm (Ramer-Douglas-Peucker):
(1.8) further screening the detected plurality of profiles: the offset amplitude in the horizontal and vertical directions and the limit of the minimum side length, the outline has a closed characteristic and is a trapezoid;
(1.9) selecting a picture outline meeting the setting requirement, wherein the picture outline is an approximate rectangle; restoring according to the scaling strategy of the step (1.5); transmitting the scanned original picture and the positions of the angular points to a cutter;
the control method of the cutter comprises the following steps:
(2.1) taking the scanned original picture and the initial boundary point obtained from the scanner as parameters;
(2.2) connecting the four boundaries clockwise to form a quadrangle which covers the original image, and setting an anchor point at each of the four boundary points to drag the four boundary points along the direction of the corner point;
(2.3) cutting the picture into a standard rectangle on the assumption that the angular point just covers the document;
(2.4) based on the coordinate vector, calculating four side lengths of the length and the width according to four points, and taking the maximum value of the four side lengths as the length and the width of the target document respectively;
(2.5) pixel projection is carried out, pixels in a target range on the original picture are filled into a new document matrix, and because the area of the document matrix is larger than that of an original projection source, the insufficient part is filled by using adjacent pixels.
2. The control method for mobile phone scanner based on visual algorithm of claim 1, wherein the graying process of step (1.3) further comprises: the Threshold value Threshold is obtained by automatically detecting the chromatic aberration, the whole picture is grayed out based on the Threshold value Threshold, the target is more prominent after graying, and the extra operation amount brought by the color space is also reduced.
3. The method for controlling a mobile phone scanner based on a visual algorithm according to claim 1, wherein the step (1.6) of detecting the topLeft point comprises:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y2), bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft.
4. The method for controlling the mobile phone scanner based on the visual algorithm as claimed in claim 1, wherein the specific method for selecting the picture profile meeting the setting requirement in step (1.7) comprises:
a. controlling four side lengths, subtracting the same coordinate from two adjacent left sides to obtain an upper side length by Math.abs (topRight.x-topleft.x), and analogizing other three side lengths in turn to control the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, and taking this absolute value as the offset, the offset is too large, which may cause distortion of the cropped picture.
5. The vision algorithm-based control method for mobile phone scanner of claim 1, wherein the step (1.7) of obtaining an approximation algorithm for the position of the core point on the contour further comprises:
(1.7.1) the starting curve is an ordered set of points or lines, the distance dimension ε > 0; the algorithm recursively divides the lines;
(1.7.2) initially, it gives all points between the first and last points, and automatically marks the first and last points to be kept;
(1.7.3) then finding the point farthest from the line segment with the first point and the last point as end points; this is obviously the point on the curve that is furthest from the approximate line segment between the end points;
(1.7.4) if the point is closer to the line segment than ε, discarding any points that are not currently marked as retained, while the simplified curve is not worse than ε;
(1.7.5) if the farthest point of the offline segment is more than approximately epsilon, then that point must be retained; the algorithm recursively calls itself using a first point and a farthest point, calls itself using a farthest point and a last point, including the farthest point marked as reserved;
(1.7.6) when the recursion is complete, a new output curve is generated that contains all and only those points that have been marked as reserved.
6. A control method of a mobile phone scanner based on a visual algorithm is characterized by comprising the following steps:
traversing the resolution supported by the camera, and acquiring and adopting the highest resolution;
secondly, collecting original pictures according to a frame rate fps ═ 20, and scaling the collected pictures uniformly according to a width of 500 pixels according to an aspect ratio;
thirdly, converting the color space of the picture from YUV to Gray, carrying out graying processing, automatically detecting chromatic aberration to obtain a Threshold, graying the whole picture based on the Threshold, and reducing the extra operation amount brought by the color space, wherein the target is more prominent after graying;
fourthly, softening the picture by using Gaussian filtering to enable the pixel distribution of the picture to be softer without losing the gray characteristic so as to keep the original characteristic of the picture;
fifthly, carrying out contour detection and marking the core point positions of the contours; calculating the outline approximate perimeter based on the core point position, and taking 1/50 empirical value of the perimeter as precision;
sixthly, placing each outline point location into a coordinate system, and calculating the radian of a point location structure; the method for detecting the topLeft point comprises the following steps:
a. establishing a core point coordinate system comprising the corner points: topLeft (x1, y1), topRight (x2, y2), bottomRight (x3, y3), bottomLeft (x4, y 4);
b. adding the x and y points of each vertex, and sorting according to sum values, wherein the minimum is topLeft, and the maximum is bottomRight; subtracting the x and y points of each vertex, and sorting according to the difference value, wherein the minimum is topRight, and the maximum is bottomLeft;
and according to the point location characteristics of the quadrangle, extracting core four point locations meeting the conditions according to the radian, wherein the four point locations are arranged in a clockwise mode: top left topLeft, top right topRight, bottom right, bottom left; introducing quadrilateral mimicry characteristics and precision, and obtaining the position of a core point on the outline by an approximation algorithm (Ramer-Douglas-Peucker): the specific method for selecting the picture contour meeting the setting requirement comprises the following steps:
a. and 4 side lengths are controlled, two adjacent left sides are subtracted from the same coordinate, and Math.
x-topleft.x) to obtain the upper side length, analogizing other three side lengths in turn, and controlling the minimum range of the side lengths based on empirical values;
b. controlling the vertical and horizontal offset, ideally, math.abs (topleft.x-bottomleft.x) should be equal to 0, but this is not a standard rectangle, taking this absolute value as the offset, the offset is too large, which may cause distortion of the clipped picture;
the approximation algorithm for obtaining the core point position on the contour further comprises:
(7.1) the starting curve is an ordered set of points or lines, the distance dimension epsilon > 0; the algorithm recursively divides the lines;
(7.2) initially, it gives all points between the first point and the last point, and automatically marks the first and last points to be kept;
(7.3) then finding a point farthest from the line segment with the first point and the last point as end points; this is obviously the point on the curve furthest from the approximate line segment between the endpoints;
(7.4) if the point is closer to the line segment than ε, discarding any points that are not currently marked as retained, and the simplified curve will not be worse than ε;
(7.5) if the point farthest from the offline segment is more than approximately epsilon, then that point must be retained; the algorithm recursively calls itself using a first point and a farthest point, calls itself using a farthest point and a last point, including the farthest point marked as reserved;
(7.6) when the recursion is complete, generating a new output curve containing all and only those points that have been marked as reserved;
and further screening the detected plurality of contours: the offset amplitude in the horizontal and vertical directions and the limit of the minimum side length, the outline has a closed characteristic and is a trapezoid;
selecting a picture contour meeting a set requirement from a self-skin, wherein the picture contour is an approximate rectangle; reducing according to the scaling strategy of the step fifthly; and transmitting the scanned original picture and the positions of the angular points to a clipper.
7. A control method of a mobile phone scanner clipper based on a visual algorithm is characterized by comprising the following steps:
taking an original picture after receiving scanning and an initial boundary point obtained from a scanner as parameters;
connecting the four boundaries clockwise to form a quadrangle, covering the quadrangle on the original drawing, and setting an anchor point at each of the four boundary points to drag the quadrangle according to the direction of the corner point;
thirdly, if the angular point just covers the document at the moment, cutting the picture into a standard rectangle;
fourthly, based on the coordinate vector, calculating four side lengths of the length and the width according to the four points, and taking the maximum value of the four side lengths as the length and the width of the target document;
fifthly, pixel projection is carried out, pixels in the target range on the original picture are filled into a new document matrix, and because the area of the document matrix is larger than that of the original projection source, and the insufficient parts are filled by using adjacent pixels.
CN202210367479.7A 2022-04-08 2022-04-08 Control method of mobile phone scanner based on visual algorithm Pending CN114663287A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210367479.7A CN114663287A (en) 2022-04-08 2022-04-08 Control method of mobile phone scanner based on visual algorithm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210367479.7A CN114663287A (en) 2022-04-08 2022-04-08 Control method of mobile phone scanner based on visual algorithm

Publications (1)

Publication Number Publication Date
CN114663287A true CN114663287A (en) 2022-06-24

Family

ID=82034899

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210367479.7A Pending CN114663287A (en) 2022-04-08 2022-04-08 Control method of mobile phone scanner based on visual algorithm

Country Status (1)

Country Link
CN (1) CN114663287A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100073735A1 (en) * 2008-05-06 2010-03-25 Compulink Management Center, Inc. Camera-based document imaging
CN109359652A (en) * 2018-11-23 2019-02-19 浙江理工大学 A method of the fast automatic extraction rectangular scanning part from digital photograph

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100073735A1 (en) * 2008-05-06 2010-03-25 Compulink Management Center, Inc. Camera-based document imaging
CN109359652A (en) * 2018-11-23 2019-02-19 浙江理工大学 A method of the fast automatic extraction rectangular scanning part from digital photograph

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
IRACER: "OpenCV-轮廓操作一站式详解:查找/筛选/绘制/形状描述与重心标注", pages 5, Retrieved from the Internet <URL:blog.csdn.net/iracer/article/details/90695914> *
VICTOR OLUFEMI: "Building your document scanner", pages 1 - 7, Retrieved from the Internet <URL:medium.com/@victorolufemi/build-a-document-scanner-with-opencv-ff9f645a4085> *
国服第一奶妈: "矩形重心python_Python OpenCV查找图中的四边形/矩形", pages 2, Retrieved from the Internet <URL:blog.csdn.net/weixin_42144086/article/details/113453270> *

Similar Documents

Publication Publication Date Title
EP3477931B1 (en) Image processing method and device, readable storage medium and electronic device
US7734088B2 (en) Low-bandwidth image streaming
US9495582B2 (en) Digital makeup
JP3828210B2 (en) Image contrast enhancement method
US6987535B1 (en) Image processing apparatus, image processing method, and storage medium
AU727503B2 (en) Image filtering method and apparatus
CN107864337B (en) Sketch image processing method, device and equipment and computer readable storage medium
US8472747B2 (en) Image composition device, image composition method, and storage medium storing program
EP2059028A1 (en) Apparatus and method for digital image stabilization using object tracking
EP0650287A2 (en) Image processing method and apparatus
JP2003058894A (en) Method and device for segmenting pixeled image
KR20070093995A (en) Motion vector calculation method, hand-movement correction device using the method, imaging device, and motion picture generation device
CN111563908B (en) Image processing method and related device
CN112132836A (en) Video image clipping method and device, electronic equipment and storage medium
EP1139284A2 (en) Method and apparatus for performing local color correction
CN104683634A (en) Determining Apparatus, Mobile Terminal Apparatus, And Recording Medium
JP5703255B2 (en) Image processing apparatus, image processing method, and program
CN105791636A (en) Video processing system
US7724981B2 (en) Adaptive contrast control systems and methods
JP2005520440A (en) Variational model for spatially dependent gamut mapping
KR20180127913A (en) Image processing apparatus, image processing method, and storage medium
JP2011141600A (en) Image processing apparatus, method, and program
CN114663287A (en) Control method of mobile phone scanner based on visual algorithm
JP2005260657A (en) Photographing apparatus, image processing method and program therefor
CN110288531B (en) Method and tool for assisting operator in making standard identity card photo

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination