Camera calibration method and system for scanning translation pen
By collecting and preprocessing images in the scanning translation pen, establishing a reference data table and comparing the width and height values of pixel points, and determining the coordinate data of the effective window boundary line, the misjudgment and deviation problems of camera calibration in the prior art are solved, and an efficient and accurate calibration process is achieved, and production efficiency and product quality are improved.
Patent Information
- Application Number
- CN202210411161.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-19
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2042-04-19
AI Technical Summary
The existing camera calibration calibration methods of scanning translation pens have problems such as manual misjudgment, inconsistent ambient light and mold materials, and the difficulty in accurately determining the boundaries of effective windows by black and white comparison algorithms, resulting in low production efficiency and unstable product quality.
By starting the calibration calibration program preset in the scanning translation pen, collecting continuous images and preprocessing, selecting images to be detected, establishing a reference data table, selecting pixel points along the Y-axis and X-axis directions and assigning width and height values, real-time comparison is made to determine the coordinate data of the effective window boundary line, and store the final boundary line coordinate value for subsequent direct reading for calibration.
It realizes efficient calibration and calibration of the scanning translation pen camera, avoids deviations caused by factors such as manual misjudgment and ambient light, and improves production efficiency and product quality.
Smart Images

Figure CN114913527B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of scanning translation pens, and in particular to a camera calibration method and system for a scanning translation pen. Background Art
[0002] With the continuous development of image processing technology, image and text recognition based on embedded processors can achieve a relatively high accuracy rate. Therefore, intelligent scanning translation pens and dictionary pens based on image and text recognition have been born. Users can easily find unfamiliar words, even a paragraph of text or an article by scanning. The definition of the effective visual boundary of the image captured by the camera of the scanning translation pen is the core requirement of the product. It directly affects the subsequent image and text recognition and algorithm processing results, and is a key factor in the quality of the product.
[0003] In the prior art, the effective window boundary line of the camera of the scanning translation pen is calibrated during the actual production process, and the calibration method has the following main disadvantages:
[0004] 1. Manual calibration method: In actual production, manual calibration requires special personnel training to complete the calibration of the camera. In addition, everyone’s understanding of the calibration method and the judgment criteria are different, so it is easy to misjudge the effective window boundary line of the camera, resulting in low production efficiency.
[0005] 2. The simple black and white contrast algorithm has strict requirements on ambient light and mold results. However, in actual operation, it is difficult to ensure that the ambient light and mold materials are completely consistent, which can easily cause deviations;
[0006] 3. The common judgment method requires the use of paper with fine grids, which appear black to the naked eye. If the paper has black stains or dust spots, they cannot be seen by the naked eye, which can easily lead to misjudgment of the effective window boundary line of the camera.
[0007] It can be seen that the traditional calibration method often fails due to uneven light, material deviation of the mold, material deviation of the camera module, stains on the calibration paper, etc., which makes the production efficiency of the scanning translation pen low. At the same time, it is easy to misjudge the effective window boundary of the camera, affecting product quality and user experience. Summary of the invention
[0008] The purpose of the present invention is to provide a method and system for calibrating the camera of a scanning translation pen, which can calibrate the effective window boundary line of the camera at one time after the scanning translation pen is produced, and the calibration process is simple and efficient.
[0009] The embodiment of the present invention is achieved as follows:
[0010] In a first aspect, an embodiment of the present application provides a method for calibrating a camera of a scanning translation pen, which comprises the following steps:
[0011] Start the calibration program preset in the scanning translation pen, and slide the pen tip of the scanning translation pen on a flat pure white calibration paper to capture several consecutive images;
[0012] Preprocess all continuous images to obtain a series of sample images, and select one of them as the image to be detected;
[0013] Obtaining coordinate data of boundary points in the image to be detected, and establishing a reference data table based on the coordinate data;
[0014] Starting from the center point position coordinates of the image to be detected, according to the coordinates of the boundary points in the reference data table, several pixel points are selected continuously along the Y-axis and X-axis directions, and the pixel points selected on the Y-axis are assigned width values from small to large, and the pixel points selected on the X-axis are assigned height values from small to large;
[0015] Compare the pixel points assigned with width value and the pixel points assigned with width and height value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point;
[0016] According to the coordinate data of the effective window boundary line obtained by detection, the final coordinate values (x1, y1) and (x2, y2) of the effective window boundary line are calculated and stored;
[0017] When the scanning translation pen is started again, the coordinate values of (x1, y1) and (x2, y2) are directly read, and the effective area range of the camera to capture the image is calibrated according to the coordinate values of (x1, y1) and (x2, y2).
[0018] Based on the first aspect, in some embodiments of the present invention, the step of preprocessing all continuous images to obtain a series of sample images specifically includes:
[0019] Perform noise reduction on all continuous images;
[0020] Grayscale the denoised image;
[0021] The grayscale image is binarized to obtain a series of sample images.
[0022] In some embodiments of the present invention, the step of preprocessing all the continuous images further includes: performing edge detection on the grayscale images to obtain a series of sample images.
[0023] In some embodiments of the present invention, the step of selecting one image from a series of sample images as the image to be detected specifically includes:
[0024] Get the brightness value of each pixel in each sample image;
[0025] Calculate the brightness difference of each image, obtain the difference data, and calculate the median of the difference data;
[0026] The sample image whose brightness difference is closest to the median is taken as the image to be detected.
[0027] In some embodiments of the present invention, starting from the center point position coordinates of the image to be detected, according to the coordinates of the boundary points in the reference data table, a number of pixel points are continuously selected along the Y-axis and X-axis directions respectively, and the pixel points selected on the Y-axis are assigned width values from small to large, and the pixel points selected on the X-axis are assigned height values from small to large. Specifically, the steps include:
[0028] From the center point position (x a ,y a ) and select N points at equal intervals along the Y axis according to the coordinates of the boundary points in the benchmark data table. 1 pixel points, select N points at equal intervals downward 2 pixels, and assign a width value w from small to large to each pixel n ;
[0029] Take x a -w n / 2 as the left border value of the pixel, x a +w n / 2 as the right border value of the pixel point, and get the left and right border values of the point;
[0030] Starting from the center point of the image to be detected, select M points along the X-axis at equal intervals to the left according to the coordinates of the boundary points in the reference data table. 1 pixels, select M equally spaced points to the right 2 pixels, and assign each pixel a high value h from small to large n ;
[0031] Take y a +h n / 2 as the upper border value of the pixel point, y a -h n / 2 is used as the lower border value of the pixel point to obtain the upper and lower border values of the point.
[0032] In some embodiments of the present invention, the step of comparing the pixel points assigned with width values and the pixel points assigned with width and height values with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel points specifically includes:
[0033] For the pixel point selected along the Y axis direction, the left and right border values are compared with the horizontal coordinates of the left and right border points corresponding to the pixel point in the reference data table in real time until -w n / 2 or w n / 2 is equal to the horizontal coordinate of the boundary point, then the coordinate data of the left and right effective window boundary lines corresponding to the pixel point are determined;
[0034] For the pixel points selected along the X-axis direction, the upper and lower border values are compared with the ordinates of the upper and lower boundary points corresponding to the pixel points in the reference data table in real time until -h n / 2 or h n / 2 is equal to the vertical coordinate of the boundary point, then the coordinate data of the upper and lower effective window boundary lines corresponding to the pixel point are determined.
[0035] In some embodiments of the present invention, the steps of calculating and obtaining the final coordinate values (x1, y1) and (x2, y2) of the effective window boundary line according to the detected coordinate data of the effective window boundary line and storing them specifically include:
[0036] The coordinate data of the left and right effective window boundary lines of the pixel points selected along the Y-axis direction are averaged to obtain the left and right effective window boundary line values x1 and x2;
[0037] The coordinate data of the upper and lower effective window boundary lines of the pixel points selected along the X-axis direction are averaged to obtain the upper and lower effective window boundary line values y1 and y2;
[0038] The coordinate values (x1, y1) and (x2, y2) are taken as the coordinate values of the effective window boundary line and stored.
[0039] In a second aspect, an embodiment of the present application provides a camera calibration system for a scanning translation pen, which includes:
[0040] An image acquisition module is used to start a calibration program preset in the scanning translation pen, so that the pen tip of the scanning translation pen slides on a flat pure white calibration paper to acquire a number of continuous images;
[0041] The image acquisition module to be detected is used to pre-process all continuous images to obtain a series of sample images, and select one of them as the image to be detected;
[0042] A reference data table establishment module is used to obtain the coordinate data of the boundary points in the image to be detected and establish a reference data table according to the coordinate data;
[0043] The boundary detection module is used to start from the center point position coordinates of the image to be detected, and continuously select a number of pixel points along the Y-axis and X-axis directions according to the coordinates of the boundary points in the reference data table, and assign width values from small to large to the pixel points selected on the Y-axis, and assign height values from small to large to the pixel points selected on the X-axis;
[0044] A comparison module is used to compare the pixel points assigned with width value and the pixel points assigned with width and height value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point;
[0045] The effective window boundary line calculation module is used to calculate and obtain the final effective window boundary line coordinate values (x1, y1) and (x2, y2) according to the detected effective window boundary line coordinate data and store them;
[0046] The effective window boundary line reading module is used to directly read the (x1, y1) and (x2, y2) coordinate values when the scanning translation pen is started again, and calibrate the effective area range of the camera to capture the image according to the (x1, y1) and (x2, y2) coordinate values.
[0047] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory for storing one or more programs; and a processor. When the one or more programs are executed by the processor, the method described in any one of the first aspects is implemented.
[0048] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any one of the above-mentioned first aspects.
[0049] Compared with the prior art, the embodiments of the present invention have at least the following advantages or beneficial effects:
[0050] The embodiment of the present invention provides a camera calibration method and system for a scanning translation pen. First, a plurality of continuous images are collected and preprocessed using an assembled scanning translation pen. Then, the image to be detected is selected according to its brightness change trend, and a reference data table is established according to the coordinate data of each pixel in the image to be detected. Then, starting from the center point position coordinates of the image to be detected, according to the coordinates of the boundary points in the reference data table, a plurality of pixel points are selected continuously along the Y-axis and X-axis directions respectively, and the pixel points selected on the Y-axis are assigned width values from small to large, and the pixel points selected on the X-axis are assigned height values from small to large. By comparing the pixel points assigned width values and the pixel points assigned width and height values with the boundary points in the reference data table in real time, the coordinate data of the effective window boundary line corresponding to the pixel point is determined. Finally, according to the coordinate data of the effective window boundary line detected, the coordinate values (x1, y1) and (x2, y2) of the final effective window boundary line are calculated and obtained and stored. When the scanning translation pen is started again, the effective area range of the camera intercepted image is directly calibrated according to the coordinate values of (x1, y1) and (x2, y2). This method has a simple operation process and is easy to implement. It not only avoids the calibration deviation caused by ambient light and mold materials during the production process of the scanning translation pen, but also avoids the misjudgment of the effective window boundary line of the camera during manual calibration, effectively improving the calibration efficiency of the camera of the scanning translation pen. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 A flowchart of an embodiment of a method for calibrating a camera of a scanning translation pen according to the present invention;
[0053] Figure 2 An image captured by a camera in an embodiment of a method for calibrating a camera of a scanning translation pen of the present invention;
[0054] Figure 3 An image obtained after preprocessing an image captured by a camera in an embodiment of a method for calibrating a camera of a scanning translation pen of the present invention;
[0055] Figure 4 A schematic diagram of assigning width values to pixel points selected along the Y-axis direction in an embodiment of a camera calibration method for a scanning translation pen of the present invention;
[0056] Figure 5 A schematic diagram of assigning high values to pixel points selected along the X-axis direction in an embodiment of a camera calibration method for a scanning translation pen of the present invention;
[0057] Figure 6 A schematic diagram of detecting and determining left and right effective window boundary line data corresponding to pixel points selected along the Y-axis direction in an embodiment of a camera calibration method for a scanning translation pen of the present invention;
[0058] Figure 7 A schematic diagram of detecting and determining upper and lower effective window boundary line data corresponding to pixel points selected along the X-axis direction in an embodiment of a camera calibration method for a scanning translation pen of the present invention;
[0059] Figure 8 A schematic diagram of determining the coordinate values (x1, y1) and (x2, y2) of the effective window boundary line in an embodiment of a camera calibration method for a scanning translation pen of the present invention;
[0060] Fig. 9 A schematic diagram of a calibrated effective window boundary line in accordance with an embodiment of a method for calibrating a camera of a scanning translation pen according to the present invention;
[0061] Fig.10 It is a structural block diagram of an embodiment of a camera calibration system for a scanning translation pen of the present invention;
[0062] Fig.11 A structural block diagram of an electronic device provided by an embodiment of the present invention.
[0063] Icons: 11. Image acquisition module; 12. Image acquisition module for detection; 13. Reference data table establishment module; 14. Boundary detection module; 15. Comparison module; 16. Valid window boundary line calculation module; 17. Valid window boundary line reading module; 101. Memory; 102. Processor; 103. Communication interface. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0065] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0066] Example
[0067] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0068] See also Figure 1 , Figure 1 The flowchart of the camera calibration method of a scanning translation pen provided in an embodiment of the present application is shown. The camera calibration method of the scanning translation pen specifically includes the following steps:
[0069] Step S1: Start the calibration program preset in the scanning translation pen, and slide the pen tip of the scanning translation pen on a flat pure white calibration paper to collect several continuous images.
[0070] In the above steps, for example, you can first prepare a non-reflective pure white paper as a calibration paper and place it flat. Then start the calibration program preset in the scanning translation pen, and tilt the scanning translation pen 60-80 degrees to slide it on the calibration paper for a certain distance. During the process, the camera of the scanning translation pen will capture an image at regular intervals. To improve the accuracy of the calibration, more than 20 continuous images can be collected to facilitate the selection of reference images for analysis later. Figure 2 As shown, Figure 2 A collected image.
[0071] Step S2: pre-process all continuous images to obtain a series of sample images, and select one of them as the image to be detected.
[0072] In the above steps, the collected continuous images are preprocessed, which is conducive to the subsequent analysis of the brightness change trend of the pixels in each image, so as to select a more suitable image to be detected. Exemplarily, the preprocessing method includes grayscale processing, binarization processing, etc. Specifically, the steps of preprocessing all continuous images are as follows:
[0073] Step S2-1: Perform noise reduction processing on all continuous images; since the image may be contaminated by noise during the acquisition and transmission process, which may affect the image quality, filtering processing can be performed before analyzing the image to eliminate the noise components in the image and obtain a smoother image. Exemplarily, a median filter can be used for median filtering. While removing noise, the median filter can also protect the sharp edges of the image, and causes less blur than a linear smoothing filter of the same size, thereby providing a basis for subsequent grayscale processing and edge detection processing.
[0074] Step S2-2: grayscale the image after noise reduction; since the collected image adopts the RGB color mode, the three components of RGB need to be processed separately when processing the image. In fact, RGB cannot reflect the morphological characteristics of the image, but only adjusts the color from the optical principle, so the image can be grayscaled to improve the calculation speed and facilitate the subsequent analysis of the brightness change trend of the image. Exemplarily, the average value method can be used for grayscale processing. By calculating the average value of the brightness of the three RGB components of each pixel in the image, the gray value of the pixel is obtained, thereby obtaining a grayscale image. The method is simple and the calculation is fast.
[0075] Step S2-3: Binarize the grayscale image to obtain a series of sample images. In this step, the grayscale value of each pixel in the grayscale image is compared with a preset threshold. If the grayscale value is less than or equal to the threshold, it becomes 0 (black), and if the grayscale value is greater than the threshold, it becomes 255 (white). Figure 3 As shown), the collective properties of the image are only related to the positions of points with pixel values of 0 or 255, and no longer involve multi-level values of pixels, which makes processing simpler and reduces the amount of data processing and compression.
[0076] The above-mentioned step of preprocessing all continuous images also includes:
[0077] Step S2-4: Perform edge detection on the grayscaled image. The purpose of edge detection is to detect and identify the set of pixels with drastic brightness changes in the image, which can greatly reduce the amount of data and eliminate irrelevant information, retaining important structural attributes of the image, such as the boundary line of the image, to facilitate the subsequent calibration of the effective window boundary line of the camera of the scanning translation pen.
[0078] After all the continuous images are preprocessed through the above steps, the steps to select one as the image to be detected are as follows:
[0079] Step S2-5: Obtain the brightness value of each pixel in each sample image; during the grayscale processing of the above image, the grayscale value of each pixel in the image can be obtained, which can be directly used as the brightness value of the pixel, providing basic data for subsequent calculation of brightness difference and analysis of brightness changes.
[0080] Step S2-6: Calculate the brightness difference of each image, obtain the difference data, and calculate the median of the difference data; by calculating the brightness difference of each image, the general brightness change of each image can be obtained, and then the images with the smallest brightness difference and the largest brightness difference are removed, and the median (median) of the brightness difference of the remaining images is calculated to provide a data basis for the subsequent selection of the image to be detected.
[0081] Step S2-7: Take the sample image whose brightness difference is closest to the median as the image to be detected. Taking the sample image whose brightness difference is closest to the median as the image to be detected is helpful to explore and calibrate the effective window boundary line of the camera of the scanning translation pen.
[0082] Step S3: Obtain the coordinate data of the boundary points in the image to be detected, and establish a reference data table according to the coordinate data.
[0083] In the above steps, for the image to be detected after the binarization processing, the OpenCV software library can be used to extract the edge contour and the coordinates of the corresponding boundary points from the image to be detected, and a reference data table can be established for storage, which can then be used as a comparison basis for later detection and determination of the effective window boundary line of the camera scanning the translation pen. The process of using the OpenCV software library to extract the contour belongs to the prior art and will not be repeated here.
[0084] Step S4: Starting from the center point position coordinates of the image to be detected, according to the coordinates of the boundary points in the reference data table, several pixel points are selected continuously along the Y-axis and X-axis directions respectively, and the pixel points selected on the Y-axis are assigned width values from small to large, and the pixel points selected on the X-axis are assigned height values from small to large.
[0085] Step S5: Compare the pixel points assigned with width value and the pixel points assigned with width and height value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point.
[0086] In the above steps S4-S5, firstly, the center point position of the image to be detected is obtained according to the length and width of the image to be detected (the center point position is at half of the length and width), and then according to the coordinates of the boundary points in the reference data table, several pixels are selected continuously along the Y-axis and X-axis directions respectively, and the pixel points selected on the Y-axis are assigned width values from small to large to obtain the left and right border values, and the pixel points selected on the X-axis are assigned height values from small to large to obtain the upper and lower border values. Then, the pixel points assigned with width values and the pixel points assigned with width and height values are compared with the boundary points in the reference data table in real time, and the width value or height value of a certain pixel point is adjusted from small to large, so that the left and right borders of the selected pixel points on the Y-axis are gradually approached to the left and right effective window boundary lines corresponding to the pixel points, and the upper and lower borders of the selected pixel points on the X-axis are gradually approached to the upper and lower effective window boundary lines corresponding to the pixel points, thereby obtaining the coordinate data of the effective window boundary lines corresponding to each.
[0087] The above steps start from the center point position coordinates of the image to be detected, and according to the coordinates of the boundary points in the reference data table, continuously select a number of pixel points along the Y-axis and X-axis directions, and assign width values from small to large to the pixel points selected on the Y-axis, and assign height values from small to large to the pixel points selected on the X-axis, specifically include:
[0088] Step S4-1: Starting from the center point of the image to be detected, select N points at equal intervals upward along the Y axis according to the coordinates of the boundary points in the reference data table. 1 pixel points, select N points at equal intervals downward 2 pixels, and assign a width value w from small to large to each pixel n ;
[0089] Step S4-2: Take x a -w n / 2 as the left border value of the pixel, x a +w n / 2 as the right border value of the pixel point, and get the left and right border values of the point;
[0090] In the above steps, illustratively, the center point position is first determined according to the length and width of the image to be detected. For example, if the pixel of the image to be detected is 320×240, the coordinates of the center point position are (160,120). Then, starting from the center point (160,120), 35 pixels are selected at equal intervals upward along the Y axis, and 30 pixels are selected at equal intervals downward. In this process, it is easy to know that the horizontal coordinates of these points are all 160. Then, width values w are assigned to each selected pixel point from small to large from top to bottom. n , and take x a -w n / 2 as the left border value of the pixel, xa +w n / 2 as the right border value of the pixel point, and get the left and right border values of the point for subsequent comparison. For example, see Figure 4 For a selected point (160,180), if a width value of 200 is assigned to it, the left border of the point is 160-200 / 2=60, and the right border is 160+200 / 2=260; if a width value of 280 is assigned to it, the left border of the point is 20, and the right border is 300.
[0091] Step S4-3: Starting from the center point of the image to be detected, select M points at equal intervals to the left along the X-axis direction according to the coordinates of the boundary points in the reference data table. 1 pixels, select M equally spaced points to the right 2 pixels, and assign each pixel a high value h from small to large n ;
[0092] Step S4-4: Get y a +h n / 2 as the upper border value of the pixel point, y a -h n / 2 is used as the lower border value of the pixel point to obtain the upper and lower border values of the point.
[0093] In the above steps, for example, starting from the center point (160, 120), 40 pixels are selected at equal intervals to the left along the X-axis direction, and 40 pixels are selected at equal intervals downward. In this process, it is easy to know that the vertical coordinates of these points are all 120. Then, each selected pixel point is assigned a high value h from small to large from left to right. n , and take y a +h n / 2 as the upper border value of the pixel point, y a -h n / 2 as the lower border value of the pixel point, and get the upper and lower border values of the point for subsequent comparison. For example, see Figure 5 For a selected point (240,120), if a high value of 160 is assigned to it, the upper border of the point is 120+160 / 2=200, and the lower border is 120-160 / 2=40; if a high value of 220 is assigned to it, the upper border of the point is 230, and the lower border is 10.
[0094] See also Figure 5 The above-mentioned step of comparing the pixel points assigned with width value and the pixel points assigned with width and height value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point specifically includes:
[0095] Step S5-1: For a pixel point selected along the Y axis, compare its left and right border values with the horizontal coordinates of the left and right border points corresponding to the pixel point in the reference data table in real time until x a -w n / 2 or x a +w n / 2 is equal to the horizontal coordinate of the boundary point, then the coordinate data of the left and right effective window boundary lines corresponding to the pixel point are determined;
[0096] For example, the point (160, 180) selected upward from the center of the image is assumed to have the corresponding left boundary point coordinates (20, 180) and the right boundary point coordinates (320, 180). When the point (160, 180) is assigned a width value of 200, the left border of the point is 60 and the right border is 260. Compared with the horizontal coordinates of the left and right boundary points, the left and right borders of the point are both within the boundary. Therefore, the width value is increased until the point (160, 180) is assigned a width value of 280, the left border is 20 and the right border is 300. At this time, the left border coincides with the left boundary (e.g. Figure 6 As shown), the left and right border values at this time are recorded as the coordinate data of the left and right effective window boundary lines corresponding to this point, providing a data basis for the subsequent calculation of the final effective window boundary line.
[0097] Step S5-2: For the pixel point selected along the X-axis direction, compare the upper and lower border values with the ordinates of the upper and lower boundary points corresponding to the pixel point in the reference data table in real time until the y a -h n / 2 or y a +h n / 2 is equal to the vertical coordinate of the boundary point, then the coordinate data of the upper and lower effective window boundary lines corresponding to the pixel point are determined.
[0098] For example, the point (240,120) selected to the left along the center of the image is assumed to have the corresponding upper boundary point coordinates (240,230) and the lower boundary point coordinates (240,0). When the point (240,120) is assigned a height value of 160, the upper border of the point is 200 and the lower border is 40. Compared with the vertical coordinates of the upper and lower boundary points, the upper and lower borders of the point are both within the boundary. Therefore, the height value is increased until the point (240,120) is assigned a height value of 220, the upper border is 230 and the lower border is 10. At this time, the upper border coincides with the upper boundary (e.g. Figure 7 As shown), the upper and lower border values at this time are recorded as the coordinate data of the upper and lower effective window boundary lines corresponding to this point, providing a data basis for the subsequent calculation of the final effective window boundary line.
[0099] Step S6: According to the detected effective window boundary line coordinate data, calculate and obtain the final effective window boundary line coordinate values (x1, y1) and (x2, y2) and store them. For details, please refer to Figure 8-Figure 9 , which comprises the following steps:
[0100] Step S6-1: Calculate the average value of the coordinate data of the left and right effective window boundaries of the pixel points selected along the Y-axis direction to obtain the left and right effective window boundary values x1 and x2;
[0101] For example, the center point position coordinates are (160, 120), the horizontal coordinates of the left and right effective window boundary lines of the pixel point (160, 180) selected along the Y-axis direction are 20 and 300, and the horizontal coordinates of the left and right effective window boundary lines of the point (160, 60) are 10 and 310. Then the left effective window boundary line x1 of the camera is (20+10) / 2=15, and the right effective window boundary line x2 is (300+310) / 2=305, so that the left and right effective window boundary line values are 15 and 305.
[0102] Step S6-2: Calculate the average value of the coordinate data of the upper and lower effective window boundary lines of the pixel points selected along the X-axis direction to obtain the upper and lower effective window boundary line values y1 and y2;
[0103] For example, the center point position coordinates are (160, 120), the ordinates of the upper and lower effective window boundary lines of the pixel point (240, 120) selected along the X-axis direction are 230 and 0, and the ordinates of the upper and lower effective window boundary lines of the point (80, 120) are 230 and 10. Then, the upper effective window boundary line y1 of the camera is (230+230) / 2 is 230, and the lower effective window boundary line y2 is (10+0) / 2 is 5, so that the upper and lower effective window boundary line values are 230 and 5.
[0104] Step S6-3: The coordinate values (x1, y1) and (x2, y2) are taken as the coordinate values of the effective window boundary line and stored.
[0105] See also Figure 8 , the above steps S6-1 and S6-2 have calculated the left effective window boundary line x1=15, the right effective window boundary line x2=305, the upper effective window boundary line y1=230, and the lower effective window boundary line y2=5 of the camera, so the coordinate values of the final effective window boundary lines obtained by combination are (15,230) and (305,5). At this time, by scanning the display screen on the translation pen, you can see the image scanned by the camera and the effective window boundary lines determined after calibration, such as Fig. 9Then click the confirmation button on the display screen to save the effective window boundary line data, and finally shut down the machine to complete the calibration process.
[0106] Step S7: When the scanning translation pen is started again, the coordinate values of (x1, y1) and (x2, y2) are directly read, and the effective area range of the camera to capture the image is calibrated according to the coordinate values of (x1, y1) and (x2, y2).
[0107] In the above step S6-3, the effective window boundary line data has been obtained, and the calibration process has been completed. Therefore, when the scanning translation pen is turned on again, the camera will directly read the effective window boundary line data (x1, y1) and (x2, y2) to calibrate the effective area range of the camera to capture the image.
[0108] Based on the same inventive concept, please refer to Fig.10 The present invention also proposes a camera calibration system for a scanning translation pen, which specifically includes:
[0109] The image acquisition module 11 is used to start the calibration program preset in the scanning translation pen, so that the pen tip of the scanning translation pen slides on a flat pure white calibration paper to acquire a number of continuous images;
[0110] The image acquisition module 12 is used to pre-process all the continuous images to obtain a series of sample images, and select one of them as the image to be detected;
[0111] A reference data table establishment module 13 is used to obtain the coordinate data of the boundary points in the image to be detected and establish a reference data table according to the coordinate data;
[0112] The boundary detection module 14 is used to start from the center point position coordinates of the image to be detected, and continuously select a number of pixel points along the Y-axis and X-axis directions according to the coordinates of the boundary points in the reference data table, and assign width values from small to large to the pixel points selected on the Y-axis, and assign height values from small to large to the pixel points selected on the X-axis;
[0113] A comparison module 15 is used to compare the pixel points assigned with the width value and the pixel points assigned with the width and height value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point;
[0114] The effective window boundary line calculation module 16 is used to calculate and obtain the final effective window boundary line coordinate values (x1, y1) and (x2, y2) according to the detected effective window boundary line coordinate data and store them;
[0115] The effective window boundary line reading module 17 is used to directly read the coordinate values of (x1, y1) and (x2, y2) when the scanning translation pen is started again, and calibrate the effective area range of the camera to capture the image according to the coordinate values of (x1, y1) and (x2, y2).
[0116] See also Fig.11 , Fig.11 A schematic block diagram of an electronic device provided in an embodiment of the present application. The electronic device includes a memory 101, a processor 102 and a communication interface 103, and the memory 101, the processor 102 and the communication interface 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. The memory 101 can be used to store software programs and modules, such as program instructions / modules corresponding to the electronic device device 300 provided in an embodiment of the present application, and the processor 102 executes various functional applications and data processing by executing the software programs and modules stored in the memory 101. The communication interface 103 can be used for signaling or data communication with other node devices.
[0117] Among them, the memory 101 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.
[0118] The processor 102 may be an integrated circuit chip with signal processing capability. The processor 102 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0119] Understandably, Fig.11 The structure shown is for illustration only. The electronic device may also include Fig.11 More or fewer components as shown, or with Fig.11 Different configurations shown. Fig.11 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0120] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0121] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0122] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0123] In summary, the embodiment of the present application provides a method and system for calibrating the camera of a scanning translation pen, which pre-processes the captured image and selects the image to be detected by starting the calibration program preset in the pen, and then captures the coordinates of the boundary points of the image to be detected, and then starts from the center point of the image to be detected, and continuously selects a number of pixel points along the Y-axis and X-axis directions respectively, and detects and determines the coordinate data of the effective window boundary line by assigning high values or width values from small to large to these pixel points, and stores them, thereby completing the calibration process. This method can calibrate the effective window boundary line of the camera at one time after the scanning translation pen is produced, and the calibration process is simple and efficient.
[0124] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0125] It will be apparent to those skilled in the art that the present application is not limited to the details of the exemplary embodiments described above, and that the present application can be implemented in other specific forms without departing from the spirit or essential features of the present application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present application. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A method for calibrating a camera of a scanning translation pen, characterized in that: The following steps are involved: Start the calibration program preset in the scanning translation pen, and slide the pen tip of the scanning translation pen on a flat pure white calibration paper to capture several consecutive images; Preprocess all continuous images to obtain a series of sample images, and select one of them as the image to be detected; Obtaining coordinate data of boundary points in the image to be detected, and establishing a reference data table based on the coordinate data; Starting from the center point position coordinates of the image to be detected, according to the coordinates of the boundary points in the reference data table, several pixel points are selected continuously along the Y-axis and X-axis directions, and the pixel points selected on the Y-axis are assigned width values from small to large, and the pixel points selected on the X-axis are assigned height values from small to large; Compare the pixel points assigned with wide values and the pixel points assigned with high values with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel points; According to the coordinate data of the effective window boundary line obtained by detection, the final coordinate values (x1, y1) and (x2, y2) of the effective window boundary line are calculated and stored; When the scanning translation pen is started again, the coordinate values of (x1, y1) and (x2, y2) are directly read, and the effective area range of the camera to capture the image is calibrated according to the coordinate values of (x1, y1) and (x2, y2).
2. The camera calibration method for a scanning translation pen as claimed in claim 1, characterized in that: The step of preprocessing all the continuous images to obtain a series of sample images specifically includes: Perform noise reduction on all continuous images; Grayscale the denoised image; The grayscale image is binarized to obtain a series of sample images.
3. The camera calibration method of the scanning translation pen as claimed in claim 2, characterized in that: The steps also include: Perform edge detection on the grayscale image to obtain a series of sample images.
4. The camera calibration method for a scanning translation pen as claimed in claim 1, characterized in that: The step of selecting an image to be detected specifically includes: Get the brightness value of each pixel in each sample image; Calculate the brightness difference of each image, obtain the difference data, and calculate the median of the difference data; The sample image whose brightness difference is closest to the median is taken as the image to be detected.
5. The camera calibration method for a scanning translation pen as claimed in claim 1, characterized in that: The steps of starting from the center point position coordinates of the image to be detected, continuously selecting a number of pixel points along the Y-axis and X-axis directions respectively according to the coordinates of the boundary points in the reference data table, and assigning width values from small to large to the pixel points selected on the Y-axis, and assigning height values from small to large to the pixel points selected on the X-axis specifically include: From the center point position (x a ,y a ), according to the coordinates of the boundary points in the reference data table, select N1 pixels at equal intervals upward along the Y axis, select N2 pixels at equal intervals downward, and assign a width value w from small to large to each pixel. n ; Take x a -w n / 2 as the left border value of the pixel, x a +w n / 2 as the right border value of the pixel point, and get the left and right border values of the point; Starting from the center point of the image to be detected, according to the coordinates of the boundary points in the reference data table, select M1 pixels at equal intervals to the left along the X-axis, and select M2 pixels at equal intervals to the right, and assign each pixel a high value h from small to large. n ; Take y a +h n / 2 as the upper border value of the pixel point, y a -h n / 2 is used as the lower border value of the pixel point to obtain the upper and lower border values of the point.
6. The camera calibration method for a scanning translation pen as claimed in claim 5, characterized in that: The step of comparing the pixel points assigned with wide values and the pixel points assigned with high values with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel points specifically includes: For the pixel point selected along the Y axis direction, the left and right border values are compared with the horizontal coordinates of the left and right border points corresponding to the pixel point in the reference data table in real time until x a -w n / 2 or x a +w n / 2 is equal to the horizontal coordinate of the boundary point, then the coordinate data of the left and right effective window boundary lines corresponding to the pixel point are determined; For the pixel point selected along the X-axis direction, the upper and lower border values are compared with the ordinates of the upper and lower boundary points corresponding to the pixel point in the reference data table in real time until the y a +h n / 2 or y a -h n / 2 is equal to the vertical coordinate of the boundary point, then the coordinate data of the upper and lower effective window boundary lines corresponding to the pixel point are determined.
7. The camera calibration method for a scanning translation pen as claimed in claim 1, characterized in that: The step of calculating and obtaining the final coordinate values (x1, y1) and (x2, y2) of the effective window boundary line according to the detected coordinate data of the effective window boundary line and storing them specifically includes: The coordinate data of the left and right effective window boundary lines of the pixel points selected along the Y-axis direction are averaged to obtain the left and right effective window boundary line values x1 and x2; The coordinate data of the upper and lower effective window boundary lines of the pixel points selected along the X-axis direction are averaged to obtain the upper and lower effective window boundary line values y1 and y2; The coordinate values (x1, y1) and (x2, y2) are taken as the coordinate values of the effective window boundary line and stored.
8. A camera calibration system for a scanning translation pen, characterized in that: include: An image acquisition module is used to start a calibration program preset in the scanning translation pen, so that the pen tip of the scanning translation pen slides on a flat pure white calibration paper to acquire a number of continuous images; The image acquisition module to be detected is used to pre-process all continuous images to obtain a series of sample images, and select one of them as the image to be detected; A reference data table establishment module is used to obtain the coordinate data of the boundary points in the image to be detected and establish a reference data table according to the coordinate data; The boundary detection module is used to start from the center point position coordinates of the image to be detected, and continuously select a number of pixel points along the Y-axis and X-axis directions according to the coordinates of the boundary points in the reference data table, and assign width values from small to large to the pixel points selected on the Y-axis, and assign height values from small to large to the pixel points selected on the X-axis; A comparison module is used to compare the pixel points assigned with a wide value and the pixel points assigned with a high value with the boundary points in the reference data table in real time to determine the coordinate data of the effective window boundary line corresponding to the pixel point; The effective window boundary line calculation module is used to calculate and obtain the final effective window boundary line coordinate values (x1, y1) and (x2, y2) according to the detected effective window boundary line coordinate data and store them; The effective window boundary line reading module is used to directly read the (x1, y1) and (x2, y2) coordinate values when the scanning translation pen is started again, and calibrate the effective area range of the camera to capture the image according to the (x1, y1) and (x2, y2) coordinate values.
9. An electronic device, characterized in that: include: A memory for storing one or more programs; processor; When the one or more programs are executed by the processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Camera calibration device and method applied to scanning translation pen and dictionary pen
CN111783769A
Camera calibration device applied to scanning translation pen and dictionary pen
CN212341886U