Disclosure of Invention
An object of the embodiments of the present application is to provide an electronic device, a lens association method and an apparatus, so as to improve convenience of lens association.
To achieve the above object, an embodiment of the present application provides an electronic device, including: the device comprises a first lens module, a second lens module, a projection component and a processor; wherein,
the projection component is used for projecting light spots;
the first lens module is used for acquiring a first light spot image aiming at the light spot;
the second lens module is used for acquiring a second light spot image aiming at the light spot;
the processor is configured to obtain a correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image through calibration.
Optionally, the first lens module includes a long-focus lens, the second lens module includes a short-focus lens, the first light spot image corresponds to a partial region of the second light spot image, and an angle of the first lens module changes along with an angle of the projection component.
Optionally, the apparatus further includes a third lens module, and an angle of the third lens module changes synchronously with an angle of the projection component;
the third lens module is used for acquiring a third light spot image aiming at the light spot, and the third light spot image corresponds to a partial area of the second light spot image;
the processor is specifically configured to obtain a correlation result among the first lens module, the second lens module, and the three lens modules based on the first light spot image, the second light spot image, and the third light spot image through calibration.
Optionally, the first lens module includes a first lens and a first imaging device, the first lens is configured to collect optical signals for the light spot, and the first imaging device is configured to convert the optical signals collected by the first lens into electrical signals to obtain a first light spot image;
the second lens module comprises a second lens and a second imaging device, the second lens is used for collecting optical signals aiming at the light spots, and the second imaging device is used for converting the optical signals collected by the second lens into electric signals to obtain a second light spot image.
In order to achieve the above object, an embodiment of the present application further provides a lens association method, including:
acquiring a first light spot image; the first light spot image is an image collected by the first lens module aiming at a light spot projected by the projection component;
acquiring a second light spot image; the second light spot image is an image acquired by a second lens module aiming at the light spot;
and calibrating to obtain a correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image.
Optionally, the light spot comprises a positioning area; the calibration obtaining of the correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image includes:
determining a plurality of corner points in the first light spot image as first corner points;
determining a plurality of corner points in the second light spot image as second corner points;
matching the first corner point with the second corner point according to the position relation between the positioning area and each corner point to obtain a plurality of matching point pairs;
and calibrating to obtain a correlation result between the first lens module and the second lens module according to the coordinate value of the center point of the matching point.
Optionally, the first lens module includes a long-focus lens, the second lens module includes a short-focus lens, and the first light spot image corresponds to a partial region of the second light spot image.
Optionally, the light spot further includes an encoded texture region, and the rectangular block included in the positioning region is different in size from the rectangular block included in the encoded texture region.
In order to achieve the above object, an embodiment of the present application further provides a lens related apparatus, including:
the first acquisition module is used for acquiring a first light spot image; the first light spot image is an image collected by the first lens module aiming at a light spot projected by the projection component;
the second acquisition module is used for acquiring a second light spot image; the second light spot image is an image acquired by a second lens module aiming at the light spot;
and the calibration module is used for calibrating to obtain a correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image.
Optionally, the light spot comprises a positioning area; the calibration module is specifically configured to:
determining a plurality of corner points in the first light spot image as first corner points;
determining a plurality of corner points in the second light spot image as second corner points;
matching the first corner point with the second corner point according to the position relation between the positioning area and each corner point to obtain a plurality of matching point pairs;
and calibrating to obtain a correlation result between the first lens module and the second lens module according to the coordinate value of the center point of the matching point.
Optionally, the first lens module includes a long-focus lens, the second lens module includes a short-focus lens, and the first light spot image corresponds to a partial region of the second light spot image.
Optionally, the light spot further includes an encoded texture region, and the rectangular block included in the positioning region is different in size from the rectangular block included in the encoded texture region.
In order to achieve the above object, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any of the lens association methods described above.
The electronic equipment that this application embodiment provided includes: the device comprises a first lens module, a second lens module, a projection component and a processor; wherein the projection component projects a light spot; the first lens module acquires a first light spot image aiming at the light spot; the second lens module acquires a second light spot image aiming at the light spots; and the processor is used for calibrating and obtaining the correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image. Therefore, in the scheme, the light spots are projected by the projection component, the lens modules respectively acquire images aiming at the light spots, the processor automatically calibrates the correlation result aiming at the images acquired by the lens modules, the whole calibration process does not need human participation, and the convenience of lens correlation is improved.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve the foregoing technical problems, embodiments of the present application provide an electronic device, a lens association method, and a lens association apparatus.
Referring to fig. 1, the electronic device may include a first lens module, a second lens module, a projection part, and a processor; wherein,
a projection component for projecting a light spot;
the first lens module is used for acquiring a first light spot image aiming at the light spot;
the second lens module is used for acquiring a second light spot image aiming at the light spots;
and the processor is used for calibrating and obtaining the correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image.
The apparatus provided in the embodiment of the present application includes at least two lens modules, which are described below by taking two lens modules as an example, and for distinguishing descriptions, one of the lens modules is referred to as a first lens module, and the other lens module is referred to as a second lens module; the image collected by the first lens module aiming at the light spot is called a first light spot image, and the image collected by the second lens module aiming at the light spot is called a second light spot image.
For example, the lens module may include a lens and an imaging device, and the imaging device may be a CCD (charge coupled device), a CMOS (Complementary Metal oxide semiconductor), and the like, and is not limited in particular. The lens collects optical signals, and the imaging device converts the optical signals into electric signals, so that images are obtained.
In this way, the first lens module comprises a first lens and a first imaging device, the first lens is used for collecting optical signals aiming at the light spots, and the first imaging device is used for converting the optical signals collected by the first lens into electric signals to obtain a first light spot image;
the second lens module comprises a second lens and a second imaging device, the second lens is used for collecting optical signals aiming at the light spots, and the second imaging device is used for converting the optical signals collected by the second lens into electric signals to obtain a second light spot image.
First camera lens module and second camera lens module are all carried out image acquisition to the facula, and as an embodiment, first camera lens module includes long focal length lens, and the second camera lens module includes short focal length lens, and perhaps said first camera lens is long focal length lens, and above-mentioned second camera lens is short focal length lens. The visual angle of short focal length lens is great, and the visual angle of long focal length lens is less, and under this condition, can regard the image that includes the second lens module collection of short focal length lens as the main picture, regard the image that includes the first lens module collection of long focal length lens as the sprite. Referring to fig. 2, the first spot image corresponds to a partial area of the second spot image, or the second spot image corresponds to a large scene, and the first spot image corresponds to a small scene, which is a part of the large scene.
In one case, as shown in fig. 2, the light spot range may be slightly larger than the collection range of the first light spot image, or the first light spot image is a part of the light spot, in which case, the central point of the light spot range and the central point of the first light spot image may be approximately coincident. Alternatively, the first spot image may substantially coincide with the spot range, or the spot range may be slightly smaller than the acquisition range of the first spot image.
Referring to fig. 3, the angle (or referred to as a collection direction) and the focal length of the two lens modules, and the angle (or referred to as a projection direction) of the projection unit are adjustable. Alternatively, the focal length of the projection component is also adjustable, and is not limited. In this embodiment, the angle of the first lens module changes synchronously with the angle of the projection component, so that the small scene corresponding to the long-focus lens substantially coincides with the light spot projected by the projection component, or the long-focus lens is aligned to the light spot.
In one embodiment, the light spot may include a positioning region and an encoded texture region, wherein the positioning region includes rectangular blocks having different sizes from those of the encoded texture region. For example, referring to fig. 4a, the positioning area is a part of the middle area, and the positioning area includes four small rectangles and a cross line; the coding texture area is a residual area, and the coding texture area is a checkerboard with black and white. For another example, referring to fig. 4b, the positioning area is a middle row and a middle column, the remaining area is the coding texture area, and the checkerboard size of the positioning area is larger than the size of the coding texture area.
The processor calibrates the two lens modules based on the first light spot image and the second light spot image. Specifically, a plurality of corner points in the first spot image may be determined as the first corner points; determining a plurality of corner points in the second light spot image as second corner points; matching the first corner point with the second corner point according to the position relation between the positioning area and each corner point to obtain a plurality of matching point pairs; and calibrating to obtain a correlation result between the first lens module and the second lens module according to the coordinate values of the angular points in the matching point pairs.
The corner point can be understood as the intersection of a black checkerboard and a white checkerboard, such as shown in fig. 5. For example, a Harris corner detection algorithm may be adopted to detect the first light spot image and the second light spot image respectively, so as to obtain corners in the images. For the purpose of distinguishing the description, a corner point in the first spot image is referred to as a first corner point, and a corner point in the second spot image is referred to as a second corner point.
As another example, the checkerboard corners have features unique to some corners, and based on these features, a filter template may be set, and the corners in the image may be identified according to the filter template.
The corresponding relation between the first corner point and the second corner point can be determined based on the positioning area in the light spot image, and a matching point pair is formed according to the corresponding relation, wherein one matching point pair comprises a first corner point and a second corner point, and the first corner point and the second corner point correspond to the same point in the projected light spot. According to the coordinate values of the two angular points in the matching point pair, the internal parameter of the lens module and the external parameter between the lens modules can be obtained through calibration, according to the internal parameter and the external parameter, the mapping relation between the pixel point coordinate in the first light spot image and the pixel point coordinate in the second light spot image can be obtained, and the mapping relation can be used as the correlation result between the lens modules.
Specifically, in one case, the aberration correction may be performed on the speckle image to obtain a corrected image, and then the internal parameters such as the focal length and the principal point coordinates of the lens module may be solved based on the corrected image. For example, the internal parameters such as the focal length and the principal point coordinates may be calculated by the zhang's scaling method or the opencv (Open Source Computer Vision Library). The specific manner of calibrating the internal reference is not limited.
And then, solving external parameters between the lens modules through an optimization function, such as a reprojection error function or a solvePnP function, wherein the external parameters comprise a rotation relation and a translation relation.
After the correlation result between the lens modules is obtained through calibration, coordinate mapping can be performed between the images collected by the two lens modules, for example, a first lens module comprising a long-focus lens collects a face image, a second lens module comprising a short-focus lens collects a whole-body image of a person, and the face image and the whole-body image can be mapped through the correlation result, so that a face region is determined in the whole-body image.
By applying the electronic equipment provided by the embodiment of the application, the light spots are projected by the projection component, the lens modules respectively collect images aiming at the light spots, the processor automatically calibrates the correlation result aiming at the images collected by the lens modules, the whole calibration process does not need human participation, and the convenience of lens correlation is improved.
In some related schemes, a fixed calibration board is usually required to be arranged, and a camera acquires a calibration image for the calibration board, so that the calibration of the camera is realized through the calibration image. In some environments with poor conditions, such as desert, mountain, etc., it is very inconvenient to set a fixed calibration board. By adopting the electronic equipment provided by the embodiment of the application, the projection component projects the light spot, a fixed calibration plate is not required to be arranged, and the calibration convenience is improved.
In the foregoing, two lens modules are taken as an example for description, the embodiment of the present application does not limit the number of the lens modules, the electronic device may include more than two lens modules, and the specific association scheme is similar.
As an embodiment, the apparatus further includes a third lens module, an angle of which changes synchronously with an angle of the projection component;
the third lens module is used for acquiring a third light spot image aiming at the light spot, and the third light spot image corresponds to a partial area of the second light spot image;
the processor is specifically configured to obtain a correlation result among the first lens module, the second lens module, and the three lens modules based on the first light spot image, the second light spot image, and the third light spot image through calibration.
In this embodiment, the third lens module also includes a long-focus lens. In one case, referring to fig. 6a, the focal length of the third lens module is greater than that of the first lens module, and the third speckle image corresponds to a partial region of the first speckle image. In another case, referring to fig. 6b, the focal length of the third lens module is smaller than that of the first lens module, and the first light spot image corresponds to a partial area of the third light spot image. In yet another case, it is also possible that, referring to fig. 6c, the first spot image and the third spot image may partially coincide.
The image collected by the second lens module including the short-focus lens can be used as a main picture, and the image collected by the first lens module including the long-focus lens and the image collected by the third lens module can be used as a sub-picture. One or more sub-pictures may be provided, and are not particularly limited.
The electronic device provided by the embodiment of the application can also be understood as a lens correlation system.
The embodiment of the application also provides a lens association method and a lens association device, and the method and the device can be applied to a processor in electronic equipment, or can also be applied to other electronic equipment, and are not limited specifically.
Fig. 7 is a schematic flowchart of a lens association method according to an embodiment of the present application, including:
s701: and acquiring a first light spot image. The first light spot image is an image collected by the first lens module aiming at the light spot projected by the projection component.
S702: and acquiring a second light spot image. And the second light spot image is an image acquired by the second lens module aiming at the light spot.
In the embodiment of the invention, the projection component projects the light spot, and different lens modules respectively acquire images aiming at the light spot to obtain a light spot image. For distinguishing descriptions, one of the lens modules is called a first lens module, and the other lens module is called a second lens module; the image collected by the first lens module aiming at the light spot is called a first light spot image, and the image collected by the second lens module aiming at the light spot is called a second light spot image.
For example, the lens module may include a lens and an imaging device, and the imaging device may be a CCD (charge coupled device), a CMOS (Complementary Metal oxide semiconductor), and the like, and is not limited in particular.
In one embodiment, the first lens module includes a long-focus lens, and the second lens module includes a short-focus lens. The visual angle of short focal length lens is great, and the visual angle of long focal length lens is less, and under this condition, can regard the image that includes the second lens module collection of short focal length lens as the main picture, regard the image that includes the first lens module collection of long focal length lens as the sprite. Referring to fig. 2, the first spot image corresponds to a partial area of the second spot image, or the second spot image corresponds to a large scene, and the first spot image corresponds to a small scene, which is a part of the large scene.
In one case, as shown in fig. 2, the light spot range may be slightly larger than the collection range of the first light spot image, or the first light spot image is a part of the light spot, in which case, the central point of the light spot range and the central point of the first light spot image may be approximately coincident. Alternatively, the first spot image may substantially coincide with the spot range, or the spot range may be slightly smaller than the acquisition range of the first spot image.
In this embodiment, the angle of the first lens module changes synchronously with the angle of the projection component, so that the small scene corresponding to the long-focus lens substantially coincides with the light spot projected by the projection component, or the long-focus lens is aligned to the light spot.
In one embodiment, the light spot may include a positioning region and an encoded texture region, wherein the positioning region includes rectangular blocks having different sizes from those of the encoded texture region. For example, referring to fig. 4a, the positioning area is a part of the middle area, and the positioning area includes four small rectangles and a cross line; the coding texture area is a residual area, and the coding texture area is a checkerboard with black and white. For another example, referring to fig. 4b, the positioning area is a middle row and a middle column, the remaining area is the coding texture area, and the checkerboard size of the positioning area is larger than the size of the coding texture area.
S703: and calibrating to obtain a correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image.
As an embodiment, a plurality of corner points in the first spot image may be determined as the first corner points; determining a plurality of corner points in the second light spot image as second corner points; matching the first corner point with the second corner point according to the position relation between the positioning area and each corner point to obtain a plurality of matching point pairs; and calibrating to obtain a correlation result between the first lens module and the second lens module according to the coordinate values of the angular points in the matching point pairs.
The corner point can be understood as the intersection of a black checkerboard and a white checkerboard, such as shown in fig. 5. For example, a Harris corner detection algorithm may be adopted to detect the first light spot image and the second light spot image respectively, so as to obtain corners in the images. For the purpose of distinguishing the description, a corner point in the first spot image is referred to as a first corner point, and a corner point in the second spot image is referred to as a second corner point.
As another example, the checkerboard corners have features unique to some corners, and based on these features, a filter template may be set, and the corners in the image may be identified according to the filter template.
The corresponding relation between the first corner point and the second corner point can be determined based on the positioning area in the light spot image, and a matching point pair is formed according to the corresponding relation, wherein one matching point pair comprises a first corner point and a second corner point, and the first corner point and the second corner point correspond to the same point in the projected light spot. According to the coordinate values of the two angular points in the matching point pair, the internal parameter of the lens module and the external parameter between the lens modules can be obtained through calibration, according to the internal parameter and the external parameter, the mapping relation between the pixel point coordinate in the first light spot image and the pixel point coordinate in the second light spot image can be obtained, and the mapping relation can be used as the correlation result between the lens modules.
Specifically, in one case, the aberration correction may be performed on the speckle image to obtain a corrected image, and then the internal parameters such as the focal length and the principal point coordinates of the lens module may be solved based on the corrected image. For example, the internal parameters such as the focal length and the principal point coordinates can be calculated by the method in the zhang's scaling method or opencv (Open Source Computer Vision Library). The specific manner of calibrating the internal reference is not limited.
And then, solving external parameters between the lens modules through an optimization function, such as a reprojection error function or a solvePnP function, wherein the external parameters comprise a rotation relation and a translation relation.
After the correlation result between the lens modules is obtained through calibration, coordinate mapping can be performed between the images collected by the two lens modules, for example, a first lens module comprising a long-focus lens collects a face image, a second lens module comprising a short-focus lens collects a whole-body image of a person, and the face image and the whole-body image can be mapped through the correlation result, so that a face region is determined in the whole-body image.
By applying the lens association method provided by the embodiment of the application, the association result is automatically calibrated aiming at the image collected by each lens module, the whole calibration process does not need human participation, and the convenience of lens association is improved.
An embodiment of the present application further provides a lens association apparatus, as shown in fig. 8, including:
a first obtainingmodule 801, configured to obtain a first spot image; the first light spot image is an image collected by the first lens module aiming at a light spot projected by the projection component;
a second obtainingmodule 802, configured to obtain a second light spot image; the second light spot image is an image acquired by a second lens module aiming at the light spot;
acalibration module 803, configured to calibrate to obtain a correlation result between the first lens module and the second lens module based on the first light spot image and the second light spot image.
In one embodiment, the spot of light includes a localized area; thecalibration module 803 is specifically configured to:
determining a plurality of corner points in the first light spot image as first corner points;
determining a plurality of corner points in the second light spot image as second corner points;
matching the first corner point with the second corner point according to the position relation between the positioning area and each corner point to obtain a plurality of matching point pairs;
and calibrating to obtain a correlation result between the first lens module and the second lens module according to the coordinate value of the center point of the matching point.
In one embodiment, the first lens module includes a long focal length lens, the second lens module includes a short focal length lens, and the first light spot image corresponds to a partial region of the second light spot image.
In one embodiment, the light spot further includes an encoded texture region, and the positioning region includes a rectangular block having a different size from a rectangular block included in the encoded texture region.
An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements any of the lens association methods described above.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the method embodiment, the apparatus embodiment, the device embodiment, and the computer-readable storage medium embodiment, since they are substantially similar to the device embodiment, the description is relatively simple, and the relevant points can be referred to the partial description of the device embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.