An automatic refractometer based on intelligent terminal
By fixing a smart terminal camera to the optical path peripheral device of the refractometer, and utilizing feature point recognition and automatic image correction technology, the problems of large size, small measurement range and limited accuracy of existing refractometer equipment are solved, realizing high-precision, low-cost and widely applicable solution concentration measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGNAN UNIV
- Filing Date
- 2023-07-27
- Publication Date
- 2026-06-09
Smart Images

Figure CN117007528B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an automatic calibration refractometer based on a smart terminal, belonging to the field of intelligent optical instruments. Background Technology
[0002] Refractive index is a simple and accurate method for determining the concentration of a solution. For many binary systems, the refractive index has a fixed relationship with the composition, and therefore it is often used as a parameter for detecting components. Refractive index is an important optical property of transparent materials. When the refractive index of the material being measured is between 1.30 and 1.70, the total internal reflection method has the advantages of convenient and rapid operation and low environmental requirements.
[0003] Currently, commercial refractometers can be divided into two types: visual refractometers and digital refractometers. Visual refractometers are large and long, making them inconvenient to carry, store, and use. They also produce errors due to visual readings and have problems with automatically taking, recording, analyzing, and displaying readings. Their measurement range is only 0-60%. Digital refractometers can automatically display readings, but they cannot record or analyze readings. Their measurement range is also 0-60%, and their versatility is not high.
[0004] CN104730033A, published on June 24, 2015, discloses a digital measurement method for a refractometer based on a smart terminal. The method connects a commercial refractometer to a smart terminal via a connector, wherein the camera lens and the refractometer eyepiece are set opposite to each other. The method includes: original color image → scale target area → drawing projection curve to obtain the resolution height at the boundary between light and dark → calculating the actual refractive reading at the boundary between light and dark → calculating the concentration of the solution to be tested. This invention connects a visual refractometer to a smart terminal, replacing the human eye to solve the problem of inaccurate readings of the visual refractometer. However, this invention still has the following problems: (1) It requires the use of a commercially available visual refractometer. On the one hand, the measurement range is limited by the visual refractometer. The detection range of the visual refractometer is generally 0-60%, which is small. On the other hand, the visual refractometer is large and long, making it inconvenient to carry, store, and use. Thirdly, the reading accuracy is affected by the accuracy of the refractometer itself. This invention essentially still depends on the scale of the refractometer, and the accuracy of the scale will also affect the final reading accuracy. (2) It requires a connector to connect the visual refractometer to the smart terminal. On the one hand, each time the visual refractometer and the smart terminal are connected, there will be a deviation in position and angle between the two, which will affect the measurement results of refractive index and concentration. On the other hand, when the user uses the device, slight shaking during hand operation will also affect the image acquisition and ultimately affect the measurement accuracy. Summary of the Invention
[0005] To address at least one of the aforementioned problems, this invention proposes an automatic calibration refractometer based on a smart terminal. The device is simple, low-cost, highly versatile, highly accurate, and has a wide measurement range. It can also perform real-time data reading, analysis, and display functions at the field of use.
[0006] The first objective of this invention is to provide an automatic calibration refractometer based on a smart terminal, comprising a refractometer optical path peripheral device and a smart terminal; the smart terminal can be fixed to the refractometer optical path peripheral device via a fixing device for the refractometer optical path peripheral device.
[0007] In one embodiment, the refractometer's optical path peripheral device includes a packaging box 5, a detection chamber 1, a blackened grooved prism 7, a detection light source 2, a white plate 4 with three feature positioning points, and a fixing device 3; wherein the blackened grooved prism 7, the detection light source 2, the white plate 4 with three feature positioning points, and the battery 6 are all placed inside the packaging box 5; the groove of the blackened grooved prism 7 faces downward, and the upper surface of the blackened grooved prism 7 is in close contact with the upper surface inside the packaging box 5, and is located on the far left side of the packaging box 5; the detection chamber 1 is fixed to the upper surface of the blackened grooved prism 7; The detection light source 2 is placed on the left side of the blackened groove prism 7; the white board 4 is fixed at a certain angle inside the packaging box at the lower right corner, and the upper surface of the white board 4 can receive the total internal reflection light of the detection light source 2 after passing through the blackened groove prism 7; the fixing device 3 is placed on the upper right side of the packaging box 5, and the smart terminal can be fixed on the fixing device 3 in the optical path peripheral device of the refractometer, and the camera of the smart terminal can vertically capture the white board 4; the packaging box 5 is sealed except for the contact points with the detection chamber 1 and the contact points with the fixing device 3.
[0008] In one embodiment, the fixing device 3 is an open buckle;
[0009] In one embodiment, the detection chamber 1 is attached and fixed to the upper surface of the blackened grooved prism 7;
[0010] In one embodiment, the detection light source 2 is a monochromatic LED; optionally, the wavelength range of the monochromatic LED is approximately 586–589 nm.
[0011] In one embodiment, the whiteboard 4 is fixed at a 30-35° angle to the lower right corner of the packaging box.
[0012] In one embodiment, a battery 6 is also included to power the detection light source 2; optionally, it is placed below the detection light source 2.
[0013] In one embodiment, the detection chamber 1 is used to hold the solution to be tested, and the liquid to be tested is in direct contact with the upper surface of the blackened grooved prism 7.
[0014] In one embodiment, the detection chamber 1 has a circular groove in the middle with different diameters on the upper and lower bottom surfaces; alternatively, it is a white 3D printed component.
[0015] In one embodiment, the whiteboard 4 contains three feature points, corresponding to three random corners of a square.
[0016] In one embodiment, the smart terminal includes a switch module, an image acquisition module, an image processing module, a computing module, a storage module, and an output module; wherein the switch module is connected to the image acquisition module, the image processing module, the computing module, the storage module, and the output module; the image acquisition module is connected to the image processing module, the image processing module is connected to the computing module and the storage module; and the computing module is connected to the output module.
[0017] The image acquisition module acquires image information from the whiteboard 4 based on the refractometer optical path peripheral device obtained by the smart terminal camera, and transmits it to the image processing module for image processing. The image processing module processes the image to obtain the boundary line pixel position and transmits the information to the calculation module. The calculation module calculates the refractive index and / or further calculates the concentration of the solution based on the boundary line pixel position. The calculation module visualizes the calculated information through the output module.
[0018] Optionally, the results from the output module can be displayed on the smart terminal screen.
[0019] In one implementation, the switch module, image acquisition module, image processing module, calculation module, storage module, and output module are integrated into a single smart terminal APP to achieve their functions.
[0020] In one embodiment, the image acquisition module is connected to a smart terminal camera to obtain image information; furthermore, the image acquisition module needs to first capture the target area and then perform automatic image correction.
[0021] In one implementation, the target region picking employs a feature point recognition method. This method involves identifying three feature points (or "position detection patterns") within the image, corresponding to three random positions within the four corners of a square. These position detection patterns aim to help the software quickly and accurately locate elements within the image. The patterns are designed to be accurately identified even when the image is rotated or tilted. Each feature point (position detection pattern) can be composed of a 7x7 black and white square surrounded by two white and black borders.
[0022] In one implementation, the automatic image correction involves first reducing noise and then performing trapezoidal correction on the image. Due to perspective, the captured bounding box is not a perfect rectangle; automatic correction improves the accuracy of the final detection. The setting of feature points, combined with target area pickup in the image acquisition module and automatic image correction, effectively solves the problems of slight displacement deviations in the fixed camera after switching to a new smart terminal, or horizontal distortion caused by the smart terminal not being perfectly horizontal. It also effectively avoids the impact of slight shaking during use on image acquisition and measurement accuracy.
[0023] The peripheral device and the smart terminal are independent of each other, and are connected by a snap-fit during use. Each connection introduces slight deviations in position and angle, which can cause changes in the position of the boundary line recognized by the image, resulting in errors in the final refractive index calculation. To eliminate this error, the device of this invention fixes three feature points on a whiteboard. By recognizing these feature points, it automatically corrects the correspondence between the image recognition boundary line position and the refractive index, achieving the effect of accurately obtaining the refractive index of the object under test even when there are connection errors between the peripheral device and the smart terminal.
[0024] In one embodiment, the image processing module first converts the image acquired by the image acquisition module to grayscale, then intelligently selects a binarization threshold for the grayscale image, and finally obtains the pixel position of the boundary line through edge calculation.
[0025] In one implementation, the grayscale conversion specifically refers to first obtaining the values (RGB values) of the red, green, and blue channels of each pixel, and then using the grayscale calculation formula: GRAY=R*0.2989+G*0.5870+B*0.1140, filling the calculated grayscale pixels back into their original positions to generate a grayscale image of the original image.
[0026] In one implementation, the intelligent selection of the binarization threshold specifically refers to first calculating the grayscale histogram of the image, and then calculating the probabilities of the foreground and background: An initial threshold is selected, and the grayscale histogram is divided into two parts: one part represents pixels with grayscale values lower than (or equal to) the threshold (i.e., background), and the other part represents pixels with grayscale values higher than the threshold (i.e., foreground). Next, the number of pixels in the foreground and background is calculated, and then divided by the total number of pixels to obtain the probabilities of the foreground and background. Then, the average grayscale of the foreground and background is calculated, which is the average of their respective pixel grayscale values. With the probabilities and average grayscale of the foreground and background, the inter-class variance can be calculated. The inter-class variance is a metric that measures the difference between the foreground and background, and its calculation formula is: Inter-class variance = Foreground probability * Background probability * (Foreground average grayscale - Background average grayscale)². Next, all possible thresholds can be iterated over, and the above steps are repeated for each threshold to calculate the corresponding inter-class variance. The threshold that maximizes the inter-class variance is the optimal threshold, and the required binarized image is generated based on this threshold.
[0027] In one implementation, the edge algorithm specifically refers to calculating the sum of the gray values of all pixels in each row, storing the sum of the gray values of each row in an array, calculating the gradient change of the gray values in each row, and identifying the pixel position of the largest gray gradient change as the boundary, i.e., the dividing line pixel position.
[0028] In one implementation, the calculation module calculates the refractive index using a built-in algorithm and converts it into the concentration of the solution. The built-in algorithm includes either a linear relationship between the boundary pixel position and the refractive index, or a linear relationship between the boundary pixel position and the concentration of the solution.
[0029] In one implementation, the smart terminal may be a smartphone, tablet computer, or the like.
[0030] In one embodiment, the smart terminal further includes a display module; it can automatically store the identified refractive index and solution concentration data; furthermore, it can generate charts and data with one click for easy access.
[0031] The second objective of this invention is to provide an application of an automatic calibration refractometer based on a smart terminal in the identification of images and measurement of solution concentration.
[0032] In one embodiment, the solution may be alcohol, glucose, or sodium chloride.
[0033] In one embodiment, the process of measuring solution concentration includes the following steps:
[0034] (1) Add the solution to be tested to the detection chamber;
[0035] (2) The scattered light emitted by the detection light source 2 passes through the prism and shines into the solution to be tested. The light that meets the condition of total internal reflection will be reflected onto the whiteboard to be photographed by the smart terminal, thus leaving a light spot on the whiteboard.
[0036] (3) The image acquisition module of the smart terminal obtains the light spot image;
[0037] (4) The image processing module obtains the pixel position of the boundary line;
[0038] (5) The built-in algorithm in the calculation module can calculate the refractive index based on the pixel position of the boundary line and convert it into the concentration of the solution to be tested.
[0039] In one embodiment, the working steps of the image acquisition module are as follows:
[0040] (1) Target area picking: The smart terminal picks up three feature points in the whiteboard 4 and automatically outlines the recognition area with a red line;
[0041] (2) Automatic image correction: First, noise reduction is performed, and then trapezoidal correction is performed on the image to form a strict rectangular box so that only the image information within the rectangular box can be recognized in the future.
[0042] In one implementation, the image processing module works by converting the image obtained from the image acquisition module to grayscale, then using an edge algorithm to calculate the sum of grayscale values of all pixels in each row, storing the sum of grayscale values of each row into an array, and calculating the gradient change of grayscale values in each row. The pixel position of the boundary line is determined by the maximum grayscale gradient change.
[0043] In one embodiment, the application further includes: first establishing a linear relationship between the boundary line pixel position and the solution concentration, or a linear relationship between the boundary line pixel position and the refractive index. Specifically, different concentrations of a certain solution are first prepared, then the solutions are added to the detection chamber, and the boundary line pixel positions obtainable with solutions of different concentrations are detected using the above method, thus obtaining the linear relationship between the boundary line pixel position and the concentration. Further, the linear relationship curve is stored as a built-in algorithm in the storage module and / or the calculation module, and the calculation module can call this built-in algorithm during use.
[0044] In one embodiment, the application further includes: performing automatic calibration before measuring the solution; the automatic calibration uses deionized water to correct for slight movement of the device, with the default concentration of the deionized water solution being 0; the APP program assigns a displacement variable ΔT to the solution concentration calculation formula to improve the accuracy of solution concentration recognition. The boundary line position and concentration have a linear relationship; when the camera position deviates, the program needs to add a displacement variable to correct it to its correct position.
[0045] Advantages and effects of the present invention:
[0046] (1) Compared with traditional refractometers, this invention uses a closed device and replaces the CCD in the traditional refractometer with a smart terminal. The device has a higher degree of integration and does not require the purchase of an additional CCD. It only needs to be connected to the existing smart terminal camera. The cost is lower than that of traditional refractometers. The smart terminal is placed on a fixed open bracket to pick up the image after the refracted light passes through the prism for image processing.
[0047] (2) The device of the present invention has the advantages of being simple, small in size, low in cost and simple in optical path, and is suitable for production scale-up.
[0048] (3) The device of the present invention has a large measurement range and can measure solutions with a concentration of 0-80%.
[0049] (4) The device of the present invention has high processing accuracy. The present invention, through the setting of the positioning module and the target area picking and automatic image correction of the image acquisition module, can effectively solve the problem that the camera fixed by the clip may have a slight displacement deviation each time after the smart terminal is replaced, or that the smart terminal will not be completely horizontal and there will be horizontal distortion when shooting. It can also effectively avoid the impact of slight shaking during use on image acquisition and measurement accuracy.
[0050] (5) Furthermore, the intelligent terminal can automatically pick up the target to be identified and complete the trapezoidal correction without additional operations, saving operational steps compared to traditional refractometers. At the same time, the calibration process reduces manual errors. Furthermore, the intelligent terminal can automatically store the identified refractive index and solution concentration data, and can generate charts and data with one click for easy reference.
[0051] (6) The present invention is more accurate than the human eye when reading. The human eye is limited by the precision of the ruler (minimum scale 1mm), while the boundary recognition algorithm used in the present invention is based on pixels (40mm contains 1068 rows of pixels, with a precision of 0.04mm).
[0052] (7) This invention can measure the concentration of different solutions and has strong universality. Attached Figure Description
[0053] Figure 1 This is a picture of a prism with a blacked-out groove.
[0054] Figure 2 This is a hardware structure diagram of the present invention. 1 is the detection chamber, 2 is the detection light source, 3 is the fixing device, 4 is the white board, 5 is the packaging box, 6 is the battery compartment, and 7 is the blackened groove prism. Among them, a is a front view after removing the front baffle of the packaging box, b is a top view, c is a left view, and d is a three-dimensional view after removing the front baffle of the packaging box.
[0055] Figure 3 This is a flowchart illustrating the principle of the present invention.
[0056] Figure 4 It is the image that was read.
[0057] Figure 5 This is a diagram illustrating the selection of solution types within the app.
[0058] Figure 6 It is a feature point-assisted localization map. Detailed Implementation
[0059] 1. Materials
[0060] The black-coated grooved prism 1 was purchased from Taobao. Its dimensions are 14*6.1mm, wall thickness 4mm, and groove 3.5mm. Figure 1 As shown;
[0061] The blackened groove prism is a modification of a triangular prism: using the face of a quadrilateral as the base (lower surface), it is divided along a face parallel to the bottom to obtain a hexahedron with the small triangular prism at the top removed. Then, a groove is vertically carved downwards from the upper surface of the hexahedron (mainly for easy fixation). The face containing the groove is then blackened, thus obtaining the blackened groove prism.
[0062] In this invention, the length and width of the lower surface are both 14mm, the height of the hexahedron is 6.1mm, the groove depth is 3.5mm, the groove is located in the center of the upper surface, and the shortest distance between the groove and the left and right surfaces is 4mm (i.e., the wall thickness is 4mm).
[0063] 2. Positioning technology:
[0064] It contains three feature points. An open-source QR code library is used to identify these three points and define a rectangular area to be identified (the selected area is as follows). Figure 4 As shown), the feature points are not included to prevent them from being identified when identifying the boundary. All captured images have been automatically cropped to exclude these three points (the principle is explained in detail in Example 2).
[0065] 3. Linear relationship between glucose solution concentration and pixel position
[0066] According to known literature (Hu Chao, Zhu Zhexin, Zhu Jiangfeng. Study on the relationship between density and refractive index of glucose solution by optical beat method [J]. University Physics Experiment, 2012, 25(06):3-5.), it is known that the concentration of glucose solution is linearly related to the refractive index. According to the principle of refractometer, the position of the dividing line pixel and the solution concentration can be regarded as linearly related. Based on the known relationship between the concentration of glucose solution and the position of the dividing line pixel, the liquid concentration can be calculated by the linear expression of the program (the principle is given in detail in Example 2).
[0067] Example 1: An Automatic Calibration Refractometer Based on a Smart Terminal
[0068] An automatic calibration refractometer based on a smart terminal includes, for example: Figure 2 The refractometer optical path peripheral device and the smart terminal shown are described; the smart terminal can be fixed to the refractometer optical path peripheral device through the fixing device of the refractometer optical path peripheral device.
[0069] The refractometer's optical path peripheral device includes a packaging box 5, a detection chamber 1, a black-coated grooved prism 7, a detection light source 2, a white board 4 with three feature positioning points, and a fixing device 3; wherein the black-coated grooved prism 7, the detection light source 2, the white board 4 with three feature positioning points, and the battery 6 are all placed inside the packaging box 5; the groove of the black-coated grooved prism 7 faces downward, and the upper surface of the black-coated grooved prism 7 is in close contact with the upper surface inside the packaging box 5, and is located on the far left side of the packaging box 5; the detection chamber 1 is fixed to the upper surface of the black-coated grooved prism 7; the detection light source 2 is located to the left of the black-coated grooved prism 7. The white board 4 with three feature positioning points is fixed at a certain angle inside the packaging box in the lower right corner, and the upper surface of the white board 4 with three feature positioning points can receive the total internal reflection light of the detection light source 2 after passing through the blackened groove prism 7; the fixing device 3 is placed in the upper right of the packaging box 5, and the smart terminal can be fixed on the fixing device 3 in the optical path peripheral device of the refractometer, and the camera of the smart terminal can vertically capture the white board 4 with three feature positioning points; the packaging box 5 is closed except for the contact points with the detection chamber 1 and the contact points with the fixing device 3.
[0070] Optionally, the fixing device 3 is a snap-fit with an opening;
[0071] Optionally, the detection chamber 1 is glued and fixed to the upper surface of the blackened grooved prism 7;
[0072] Optionally, the detection light source 2 is a monochromatic LED; optionally, the wavelength range of the monochromatic LED is approximately 586–589 nm.
[0073] Optionally, the whiteboard 4 is fixed at a 30-35° angle to the lower right corner of the packaging box.
[0074] Optionally, it also includes a battery 6 to power the detection light source 2; optionally, it is placed below the detection light source 2.
[0075] Optionally, the detection chamber 1 is used to hold the solution to be tested, and the liquid to be tested is in direct contact with the upper surface of the blackened grooved prism 7.
[0076] Optionally, the detection chamber 1 has a circular groove in the middle with different diameters on the upper and lower bottom surfaces; alternatively, it is a white 3D printed component.
[0077] The whiteboard 4 contains three feature points, corresponding to three random corners of a square.
[0078] The intelligent terminal includes a switch module, an image acquisition module, an image processing module, a calculation module, a storage module, and an output module. The switch module is connected to all four modules: image acquisition, image processing, calculation, storage, and output. The image acquisition module is connected to the image processing module, which in turn is connected to the calculation and storage modules. The calculation module is connected to the output module. The image acquisition module acquires image information from the whiteboard 4 (based on the refractometer optical path peripheral device) via the intelligent terminal's camera and transmits it to the image processing module for image processing. The image processing module obtains the boundary line pixel positions and transmits this information to the calculation module. The calculation module calculates the refractive index and / or further calculates the solution concentration based on the boundary line pixel positions. The calculation module then visualizes the calculated information through the output module.
[0079] The image acquisition module is connected to the camera of the smart terminal to obtain image information; furthermore, the image acquisition module needs to first pick up the target area and then perform automatic image correction.
[0080] The target region picking employs a feature point recognition method. This method involves identifying three feature points (or "position detection patterns") within the image, corresponding to three random positions within the four corners of a square. These position detection patterns aim to help the software quickly and accurately locate elements within the image. The design of these patterns ensures accurate identification even when the image is rotated or tilted. Each feature point (position detection pattern) can be composed of a 7x7 black and white square surrounded by two white and black borders.
[0081] The automatic image correction process involves first reducing noise and then applying trapezoidal correction to the image. Due to perspective, the captured bounding box is not a perfect rectangle; automatic correction improves the accuracy of the final detection. The feature point recognition settings, combined with target area pickup in the image acquisition module and automatic image correction, effectively address the issues of slight displacement deviations in the camera fixed to the clip after switching smart terminals, image distortion caused by tilting during smart terminal shooting, and the impact of human shaking on image acquisition and measurement accuracy.
[0082] The image processing module first converts the image acquired by the image acquisition module to grayscale, then intelligently selects a binarization threshold for the grayscale image, and finally obtains the pixel position of the boundary line through edge calculation.
[0083] The grayscale conversion specifically refers to first obtaining the values of the red, green, and blue channels (RGB values) of each pixel, and then using the grayscale calculation formula: GRAY=R*0.2989+G*0.5870+B*0.1140, filling the calculated grayscale pixels back into their original positions to generate a grayscale image of the original image.
[0084] The intelligent selection of the binarization threshold specifically refers to first calculating the grayscale histogram of the image, and then calculating the probabilities of the foreground and background: An initial threshold is selected, and the grayscale histogram is divided into two parts: one part represents pixels with grayscale values lower than (or equal to) the threshold (i.e., background), and the other part represents pixels with grayscale values higher than the threshold (i.e., foreground). Next, the number of pixels in the foreground and background is calculated, and then divided by the total number of pixels to obtain the probabilities of the foreground and background. Then, the average grayscale of the foreground and background is calculated, which is the average of their respective pixel grayscale values. With the probabilities and average grayscale of the foreground and background, the inter-class variance can be calculated. The inter-class variance is a metric that measures the difference between the foreground and background, and its formula is: Inter-class variance = Foreground probability * Background probability * (Foreground average grayscale - Background average grayscale)². Next, all possible thresholds can be iterated over, and the above steps are repeated for each threshold to calculate the corresponding inter-class variance. The threshold that maximizes the inter-class variance is the optimal threshold, and the required binarized image is generated based on this threshold.
[0085] The edge algorithm specifically refers to calculating the sum of the gray values of all pixels in each row, storing the sum of the gray values of each row in an array, calculating the gradient change of the gray values in each row, and identifying the pixel position of the largest gray gradient change as the boundary, i.e., the dividing line.
[0086] The calculation module calculates the refractive index using a built-in algorithm and converts it into the concentration of the solution. The built-in algorithm includes either a linear relationship between the boundary pixel position and the refractive index, or a linear relationship between the boundary pixel position and the concentration of the solution.
[0087] Optionally, the smart terminal may be a smartphone, tablet computer, or the like.
[0088] Optionally, the switch module, image acquisition module, image processing module, calculation module, storage module, and output module are integrated into a single smart terminal APP to realize their functions.
[0089] Optionally, the smart terminal also includes a display module; it can automatically store the identified refractive index and solution concentration data; furthermore, it can generate charts and data with one click for easy access.
[0090] Optionally, the smart terminal also includes a deionized water calibration module; when the solution to be tested is deionized water, the solution concentration corresponding to the boundary pixel position is "0", thereby realizing the calibration of the boundary pixel position.
[0091] In one embodiment, the application further includes: performing automatic calibration before measuring the solution; the automatic calibration uses deionized water to correct for slight movement of the device, with the default concentration of the deionized water solution being 0; the APP program assigns a displacement variable ΔT to the solution concentration calculation formula to improve the accuracy of solution concentration recognition. The boundary line position and concentration have a linear relationship; when the camera position deviates, the program needs to add a displacement variable to correct it to its correct position.
[0092] Example 2: Application of an automatic calibration refractometer based on a smart terminal in measuring the concentration of glucose solution.
[0093] (1) Structure of an automatic calibration refractometer based on a smart terminal
[0094] An automatic calibration refractometer based on a smart terminal includes, for example: Figure 2 The refractometer optical path peripheral device and the smart terminal shown are described; the smart terminal can be fixed to the refractometer optical path peripheral device through the fixing device of the refractometer optical path peripheral device.
[0095] The refractometer's optical path peripheral device includes a packaging box 5, a detection chamber 1, a black-coated grooved prism 7, a detection light source 2, a white board 4 with three feature positioning points, and a fixing device 3; wherein the black-coated grooved prism 7, the detection light source 2, the positioning module, the white board 4, and the battery 6 are all placed inside the packaging box 5; the groove of the black-coated grooved prism 7 faces downward, and the upper surface of the black-coated grooved prism 7 is in close contact with the upper surface inside the packaging box 5, and is located on the far left side of the packaging box 5; the detection chamber 1 is fixed to the upper surface of the black-coated grooved prism 7; the detection light source 2 is located on the left side of the black-coated grooved prism 7. The whiteboard 4 with three feature positioning points is fixed at a certain angle in the lower right corner inside the packaging box, and the upper surface of the whiteboard 4 with three feature positioning points can receive the total internal reflection light of the detection light source 2 after passing through the blackened groove prism 7; the fixing device 3 is placed in the upper right corner of the packaging box 5, and the smart terminal can be fixed on the fixing device 3 in the optical path peripheral device of the refractometer, and the camera of the smart terminal can vertically capture the whiteboard 4 with feature points; the packaging box 5 is closed except for the contact points with the detection chamber 1 and the contact points with the fixing device 3.
[0096] The fixing device 3 is a perforated buckle;
[0097] The detection chamber 1 is glued to the upper surface of the blackened grooved prism 7 with 502 glue;
[0098] The detection light source 2 is a monochromatic LED with a wavelength of 589nm, incident at an angle of 45° upwards;
[0099] The whiteboard 4 is fixed at a 30° angle to the lower right corner of the packaging box.
[0100] It also includes a battery 6 to power the detection light source 2; optionally, it is placed below the detection light source 2.
[0101] The detection chamber 1 is used to hold the solution to be tested, and the liquid to be tested is in direct contact with the upper surface of the blackened grooved prism 7.
[0102] The detection chamber 1 has a circular groove in the middle with different diameters on the upper and lower bottom surfaces; alternatively, it is a white 3D printed component.
[0103] Whiteboard 4 contains three feature points, corresponding to three random corners of a square.
[0104] (2)Reference Figure 3 The principle flowchart is used to analyze the glucose solution sample.
[0105] a. Secure the smart terminal to the mounting device (snap fastener) of the optical path peripheral device of the refractometer;
[0106] b. Activate the switch module. The switch module, image acquisition module, image processing module, calculation module, storage module, and output module are all integrated into a mobile app. Open the mobile app; the app has a built-in algorithm. Select to measure the glucose solution concentration.
[0107] c. Deionized water calibration (only for first use; after fixation, it can be used directly without calibration): Add deionized water, click "Deionized water calibration" on the APP interface, and if the measurement result is not 0.00%, it will be corrected to 0.00%;
[0108] d. After calibration, add the glucose solution to be measured;
[0109] e. Repeat the measurement multiple times;
[0110] f. The APP automatically records data.
[0111] The mobile app needs to include a built-in algorithm that reflects the relationship between the boundary line position and the glucose solution concentration. This algorithm can be directly applied to the boundary line position captured on the whiteboard 4. Figure 4 As shown, the concentration of the sample to be tested is calculated.
[0112] like Figure 5 As shown, the experimental results are: solution concentrations of 46.39%, 61.45%, 59.90%, 55.83%, and 71.35%.
[0113] The APP works as follows:
[0114] A. Feature point localization section
[0115] like Figure 6 The image shown is an image on a whiteboard containing three feature points (or "position detection patterns"), corresponding to three random positions within the four corners of a square. These position detection patterns aim to help the software quickly and accurately locate elements within an image. They are designed to be accurately identified even when the image is rotated or tilted. Each feature point (position detection pattern) can be a 7x7 black and white square surrounded by two white and black borders.
[0116] B. Trapezoidal Correction Section
[0117] After locating feature points, the software can use this positional information to determine the image's size, orientation, and tilt. It then adjusts and corrects the image to make it rectangular, allowing for subsequent image processing. Through the preceding steps, three feature points (location patterns) have been found. These three points can then be used to determine the image's orientation and predict the position of the fourth corner point. Defining target coordinates: A target coordinate system needs to be defined, representing the desired position and shape of the image. Calculating the perspective transformation matrix: With the source and target coordinates, a perspective transformation matrix can be calculated. This matrix describes how to move from the source coordinates to the target coordinates. In the calculation, typically four pairs of corresponding points (here, the four corner points of the captured image and the four corner points of the target coordinates) are used to calculate this matrix. A system of linear equations is established using the coordinate information of these points, and then this system of equations is solved to obtain the perspective transformation matrix. To illustrate this process, assume the source image contains four points (x1, y1), (x2, y2), (x3, y3), and (x4, y4), and the target image contains four points (u1, v1), (u2, v2), (u3, v3), and (u4, v4). The goal is to find a 3x3 matrix:
[0118] [a,b,c]
[0119] [d,e,f]
[0120] [g,h,1]
[0121] This matrix can be solved using the following system of equations:
[0122] x1*a+y1*b+c=u1*(x1*g+y1*h+1)
[0123] x1*d+y1*e+f=v1*(x1*g+y1*h+1)
[0124] x2*a+y2*b+c=u2*(x2*g+y2*h+1)
[0125] x2*d+y2*e+f=v2*(x2*g+y2*h+1)
[0126] x3*a+y3*b+c=u3*(x3*g+y3*h+1)
[0127] x3*d+y3*e+f=v3*(x3*g+y3*h+1)
[0128] x4*a+y4*b+c=u4*(x4*g+y4*h+1)
[0129] x4*d+y4*e+f=v4*(x4*g+y4*h+1)
[0130] This system of equations has 8 unknowns (a, b, c, d, e, f, g, h) and 8 equations, so a solution can be found.
[0131] Applying perspective transformation: With the perspective transformation matrix, it can be applied to the original image to obtain a new image, in which the image has been corrected to the expected shape. In this process, the new position of each pixel is calculated using the transformation matrix and the original position. With the new position, an interpolation algorithm can be used to calculate the value of the new pixel. When it is necessary to determine the value of a pixel, but the value is not directly given, interpolation can be performed using the four surrounding known pixels (top left, top right, bottom left, bottom right). Suppose we want to find a pixel value at coordinates (x, y), and we have four surrounding pixels: (x1, y1), (x2, y1), (x1, y2), and (x2, y2), with values Q11, Q12, Q21, and Q22 respectively. First, linear interpolation is performed in the x-direction to obtain the pixel values of points (x, y1) and (x, y2):
[0132] R1=(x2-x) / (x2-x1)*Q11+(x-x1) / (x2-x1)*Q21
[0133] R2=(x2-x) / (x2-x1)*Q12+(x-x1) / (x2-x1)*Q22
[0134] Then, linear interpolation is performed in the y-direction to obtain the pixel value of the point (x, y):
[0135] P=(y2-y) / (y2-y1)*R1+(y-y1) / (y2-y1)*R2
[0136] This gives us the value P of the new pixel.
[0137] C. Rectangular area cropping section
[0138] The standard rectangular image has been obtained above. When selecting the image, subtract the pixel rows and columns occupied by the feature points to obtain an internal rectangular region image that does not contain the feature points.
[0139] D. Image Processing
[0140] To facilitate recognition, the image captured by the smart terminal's camera is first converted to grayscale. First, the values of the red, green, and blue channels (RGB values) of each pixel are obtained. Then, the grayscale calculation formula is used: GRAY = R * 0.2989 + G * 0.5870 + B * 0.1140. The calculated grayscale pixels are then filled back into their original positions to generate a grayscale image of the original image.
[0141] The generated grayscale image can then undergo further binarization to more easily identify the black and white block pattern of feature points. Binarization divides all pixels into black and white by setting a threshold; pixel values greater than the threshold are set to white, and those less than the threshold are set to black. In terms of grayscale values, values greater than the threshold are set to 255, and values less than the threshold are set to 0.
[0142] To improve recognition efficiency in dark environments, instead of the traditional single threshold method, a binarized thresholding approach based on intelligent analysis is used. First, the grayscale histogram of the image needs to be calculated. This is a graph representing the frequency of occurrence of each grayscale level in the image. The probabilities of foreground and background are calculated: an initial threshold is chosen, and then the grayscale histogram is divided into two parts: one part represents pixels with grayscale values below (or equal to) the threshold (i.e., background), and the other part represents pixels with grayscale values above the threshold (i.e., foreground). The number of foreground and background pixels can be calculated, and then divided by the total number of pixels to obtain the probabilities of foreground and background. The average grayscale of foreground and background is calculated: the average grayscale of foreground and background pixels is the average of their respective pixel grayscale values. The inter-class variance is calculated: with the probabilities and average grayscale of foreground and background, the inter-class variance can be calculated. Inter-class variance is a metric that measures the difference between foreground and background, and the formula is: Inter-class variance = Foreground probability * Background probability * (Foreground average grayscale - Background average grayscale)². Finding the maximum inter-class variance: Next, we can iterate through all possible thresholds, repeating the above steps for each threshold to calculate the corresponding inter-class variance. The threshold that maximizes the inter-class variance is the optimal threshold. The required binarized image is then generated based on this threshold.
[0143] Using this feature, each row of pixels is scanned to try to find areas that match the black-and-white ratio of this feature point, which allows them to be located quickly and accurately in the image.
[0144] E. Boundary Recognition Section
[0145] The binarized image is processed by an edge detection algorithm. The sum of the gray values of all pixels in each row is calculated. The sum of the gray values of each row is stored in an array. The gradient change of the gray values in each row is calculated. The pixel position with the largest gray gradient change is identified as the boundary, i.e., the dividing line pixel position.
[0146] F. Concentration Calculation Section
[0147] The boundary line position is linearly related to the solution concentration. F represents the decimal representation of the proportion of the rectangular area containing the boundary line from top to bottom, Y represents the calculated concentration, and k and b are set according to different solutions. In this glucose solution measurement, k is -93.75 and b is 87.5. Substituting into the formula:
[0148] Y = k * F + b
[0149] The solution concentration values are calculated by fitting the intercept and slope of different preset solution concentrations.
[0150] Meanwhile, because the whiteboard has a long observation range and covers a wide area, the concentration range is 0-80%.
[0151] Example 3: Application of an automatic calibration refractometer based on a smart terminal in measuring solution concentration
[0152] Referring to the detection method of Example 2, the solution concentration was measured using the automatic calibrated refractometer of Example 1. The steps included:
[0153] (1) Fix the smart terminal on the fixing device (snap) of the optical path peripheral device of the refractometer;
[0154] (2) Start the switch module; the switch module, image acquisition module, image processing module, calculation module, storage module, and output module are integrated into a mobile app, so open the mobile app; the mobile app has built-in algorithms, such as the linear relationship between different solution concentrations and the pixel position of the boundary line; the main interface of the mobile app also allows you to select the type of solution to be measured, such as ethanol, etc. Figure 5 As shown;
[0155] (3) Deionized water calibration (only for the first use; after fixation, it can be used directly without calibration): Add deionized water, click "Deionized water calibration" on the APP interface, and if the measurement result is not 0.00%, it will be corrected to 0.00%;
[0156] (4) After calibration, add the same solution with the concentration to be measured.
[0157] (5) The smart terminal acquires an image of the solution to be tested, performs image processing, and obtains the concentration of the solution to be tested;
[0158] (6) Repeat the measurement multiple times;
[0159] (7) The APP automatically records data.
[0160] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be determined by the claims.
Claims
1. An automatic calibration refractometer based on a smart terminal, characterized in that, The device includes a refractometer optical path peripheral device and a smart terminal. The smart terminal can be fixed to the refractometer optical path peripheral device via a fixing device. The refractometer optical path peripheral device includes a packaging box, a detection chamber, a blackened grooved prism, a detection light source, a white board with three feature positioning points, and a fixing device. The blackened grooved prism, the detection light source, the white board with three feature positioning points, and the battery are all placed inside the packaging box. The groove of the blackened grooved prism faces downward, and its upper surface is in close contact with the upper surface inside the packaging box, located on the far left side of the packaging box. The detection chamber is fixed to the upper surface of the blackened grooved prism. The detection light source is located on the left side of the blackened grooved prism. The white board is fixed at a certain angle in the lower right corner inside the packaging box, and the upper surface of the white board can receive the total internal reflection light from the detection light source after passing through the blackened grooved prism. The fixing device is located on the upper right of the packaging box. The smart terminal can be fixed on the fixing device in the optical path peripheral device of the refractometer, and the camera of the smart terminal can capture the whiteboard vertically. The packaging box is sealed except for the part that is not sealed in contact with the detection chamber and the part that is not sealed in contact with the fixing device.
2. The automatic calibration refractometer based on a smart terminal according to claim 1, characterized in that, The fixing device is an open buckle; the detection chamber is pasted and fixed to the upper surface of the blackened grooved prism; the detection light source is a monochrome LED with a wavelength range of 586~589nm; the white board is fixed at 30-35° to the lower right corner of the packaging box.
3. The automatic calibration refractometer based on a smart terminal according to claim 1, characterized in that, It also includes a battery to power the detection light source, which is placed below the detection light source; the detection chamber is used to hold the solution to be tested, and the liquid to be tested is in direct contact with the upper surface of the blackened grooved prism; the detection chamber has a circular groove in the middle with different diameters on the upper and lower bottom surfaces; it is a white 3D printed component; the white board contains three feature points, corresponding to three random corners of a square.
4. The automatic calibration refractometer based on a smart terminal according to claim 1, characterized in that, The smart terminal includes a switch module, an image acquisition module, an image processing module, a computing module, a storage module, and an output module; The switch module is connected to the image acquisition module, image processing module, calculation module, storage module, and output module; the image acquisition module is connected to the image processing module; the image processing module is connected to the calculation module and storage module; and the calculation module is connected to the output module. The image acquisition module acquires image information from the whiteboard on the optical path peripheral device of the refractometer obtained by the camera of the smart terminal, and transmits it to the image processing module for image processing. The image processing module processes the image to obtain the position of the boundary line pixel and transmits the information to the calculation module. The calculation module calculates the refractive index and further calculates the concentration of the solution based on the position of the boundary line pixel. The calculation module visualizes the calculated information through the output module. The output module's results can be displayed on the smart terminal screen.
5. The automatic calibration refractometer based on a smart terminal according to claim 4, characterized in that, The switching module, image acquisition module, image processing module, calculation module, storage module, and output module are integrated into one APP to realize their functions.
6. The automatic calibration refractometer based on a smart terminal according to claim 4, characterized in that, The image acquisition module is connected to the camera of the smart terminal to obtain image information; furthermore, the image acquisition module needs to first pick up the target area and then perform automatic image correction.
7. The automatic calibration refractometer based on a smart terminal according to claim 4, characterized in that... To eliminate minor positional and angular deviations that may occur during each connection, the image acquisition module employs a feature point recognition method for target area picking. This feature point recognition method refers to the use of three feature points in the image, corresponding to three random positions among the four corners of a square. This method ensures that the refractive index of the object under test can still be accurately obtained even when there are connection errors between the peripheral device and the smart terminal.
8. The automatic calibration refractometer based on a smart terminal according to claim 4, characterized in that, In the smart terminal, the image processing module first converts the image acquired by the image acquisition module to grayscale, then intelligently selects a binarization threshold for the grayscale image, and finally obtains the pixel position of the boundary line through edge calculation. The grayscale conversion specifically refers to first obtaining the values of the red, green, and blue channels for each pixel, and then using the grayscale calculation formula: GRAY=R 0.2989+G 0.5870+B 0.1140, fill the calculated grayscale pixels back into their original positions to generate a grayscale image of the original image; The intelligent selection of the binarization threshold specifically refers to first calculating the grayscale histogram of the image, and then calculating the probabilities of foreground and background: An initial threshold is selected, and the grayscale histogram is divided into background and foreground parts. The background represents pixels with grayscale values lower than or equal to the threshold, and the foreground represents pixels with grayscale values higher than the threshold. Next, the number of pixels in the foreground and background is calculated, and then divided by the total number of pixels to obtain the probabilities of foreground and background. Then, the average grayscale of the foreground and background is calculated, which is the average of their respective pixel grayscale values. With the probabilities and average grayscale of the foreground and background, the inter-class variance can be calculated. The inter-class variance is a metric that measures the difference between the foreground and background, and its calculation formula is: Inter-class variance = Foreground probability Background probability (Foreground average gray level - background average gray level)², next, iterate through all possible thresholds, repeat the above steps for each threshold, calculate the corresponding inter-class variance, the threshold that maximizes the inter-class variance is the given optimal threshold, and generate the required binarized image based on this threshold. The edge calculation specifically refers to calculating the sum of the gray values of all pixels in each row, storing the sum of the gray values of each row in an array, calculating the gradient change of the gray values in each row, and identifying the pixel position of the largest gray gradient change as the boundary, i.e., the dividing line pixel position.
9. The automatic calibration refractometer based on a smart terminal according to claim 4, characterized in that, In the smart terminal, the calculation module calculates the refractive index using an algorithm built into the APP and converts it into the concentration of the solution.
10. A method for identifying the concentration of a solution in an image, characterized in that, The method utilizes the automatic calibration refractometer based on a smart terminal as described in claims 1-9; the solution is alcohol, glucose, and sodium chloride.
11. The method according to claim 10, characterized in that, The measurement of solution concentration includes the following steps: (1) Add the solution to be tested into the detection chamber; (2) An extended beam of light is emitted from the detection light source and shines into the solution to be tested through a prism. The light that meets the condition of total internal reflection will be reflected onto the whiteboard to be photographed by the smart terminal, leaving a light-dark boundary pattern on the whiteboard with 3 characteristic calibration points. (3) The image acquisition module of the intelligent terminal obtains the light-dark boundary image of feature points and total internal reflection of the light source; (4) The image processing module corrects the image using three feature points and then calculates the relative positions of the boundary line pixels; (5) The built-in algorithm in the calculation module can calculate the refractive index based on the pixel position of the boundary line and convert it into the concentration of the solution to be tested; The method further includes: first establishing a linear relationship between the boundary line pixel position and the solution concentration, or a linear relationship between the boundary line pixel position and the refractive index.