Camera focusing method, apparatus and robot
By acquiring and filtering camera images in real time, and using image gradients and template similarity to determine the camera's focusing direction, the problem of occluded images affecting focusing is solved, enabling fast and accurate focusing of the camera.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, it is difficult to achieve fast and accurate focusing during camera focusing, especially when a finger enters the field of view, causing image obstruction and affecting the determination of the focusing direction.
By acquiring target images captured by the camera in real time, determining whether there is occlusion, discarding occluded images, and using the gradient change trend of the image group and the similarity of the template image to determine the accurate real-time focusing direction, the camera focal length is adjusted until the preset conditions are met.
It enables fast and accurate focusing of the camera even when it is obstructed, ensuring the accuracy of the focusing direction and improving focusing efficiency.
Smart Images

Figure CN116823858B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a camera focusing method, apparatus and robot. Background Technology
[0002] Camera focusing is a crucial component of zoom image acquisition systems. Because these systems require continuous, real-time adjustments to the camera's focal length based on the object's height to acquire high-quality images, achieving fast and accurate camera focusing has become a pressing issue for those skilled in the art. Summary of the Invention
[0003] Therefore, it is necessary to provide a camera focusing method, device, and robot that can achieve fast and accurate focusing of the camera, addressing the aforementioned technical problems.
[0004] Firstly, this application provides a camera focusing method. The method includes:
[0005] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0006] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0007] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0008] In one embodiment, the target image refers to an image that is not occluded.
[0009] In one embodiment, determining the real-time focusing direction corresponding to the target image acquired in real time, based on the camera's initial focusing direction, includes:
[0010] For the current target image captured in real time, determine whether the current target image meets the second preset condition. The second preset condition includes that the image group composed of the current target image and the target images previously acquired in real time meet the third preset condition.
[0011] If the current target image meets the second preset condition, the focusing direction is redefined based on the image group composed of the current target image and the initial focusing direction, and the redefined focusing direction is used as the real-time focusing direction corresponding to the current target image; if the current target image does not meet the second preset condition, the initial focusing direction is used as the real-time focusing direction corresponding to the current target image.
[0012] In one embodiment, the third preset condition includes that all target images in the image group composed of the current target image exhibit an increasing or decreasing gradient according to the shooting time sequence, and the third preset condition also includes that the gradient difference between any two adjacent target images in the image group composed of the current target image is greater than the first preset threshold.
[0013] In one embodiment, the focusing direction is re-determined based on the image group consisting of the current target image and the initial focusing direction, including:
[0014] If all target images in the image group consisting of the current target image show an increasing gradient according to the shooting time sequence, then the initial focusing direction is used as the redefined focusing direction. If all target images in the image group consisting of the current target image show a decreasing gradient according to the shooting time sequence, then the opposite focusing direction of the initial focusing direction is used as the redefined focusing direction.
[0015] In one embodiment, for the current target image captured in real time, the first preset condition includes that in the image group composed of the current target image and the target images previously acquired in real time, all target images show a gradient decrease according to the shooting time sequence and the gradient difference between each two adjacent target images is greater than a second preset threshold.
[0016] In one embodiment, the process of determining the target image includes:
[0017] For the current image captured in real time, determine whether there is occlusion in the current image based on the template image. If there is no occlusion, the current image is used as the target image. If there is occlusion, the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0018] In one embodiment, determining whether the current image is occluded based on the template image includes:
[0019] Edges are cropped from both the template image and the current image to obtain cropped images corresponding to the template image and the current image, respectively. The cropped image corresponding to the template image is used as the template edge image, and the cropped image corresponding to the current image is used as the current edge image. The position of the template edge image in the template image corresponds to the position of the current edge image in the current image.
[0020] Determine the similarity value between the template edge image and the current edge image;
[0021] If the similarity value between the template edge image and the current edge image is greater than the third preset threshold, it is determined that the current image does not have occlusion; otherwise, it is determined that the current image has occlusion.
[0022] Secondly, this application also provides a camera focusing device. The device includes:
[0023] The acquisition module is used to acquire images of the target scene captured by the camera in real time during the process of focusing the camera according to the initial focusing direction;
[0024] The first determining module is used to determine the real-time focusing direction corresponding to the target image acquired in real time, based on the initial focusing direction, when the image acquired in real time is the target image.
[0025] The focusing module is used to adjust the camera's focus in real time according to the real-time focusing direction until the first preset condition is met, at which point the focusing ends.
[0026] Thirdly, this application also provides a robot. The robot includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0027] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0028] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0029] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0030] The aforementioned camera focusing method, apparatus, and robot acquire images of the target scene captured by the camera in real time while focusing the camera according to the initial focusing direction. If the acquired image is the target image, the real-time focusing direction corresponding to the acquired target image is determined based on the initial focusing direction. The camera is then focused in real time according to this real-time focusing direction until a first preset condition is met. Since the camera's real-time focusing direction is determined based on the real-time images of the target scene captured by the camera, an accurate real-time focusing direction is obtained, thereby achieving fast and accurate focusing of the camera. Attached Figure Description
[0031] Figure 1 This is a flowchart illustrating a camera focusing method in one embodiment;
[0032] Figure 2 This is a schematic diagram of an image captured by the camera in a camera focusing method in one embodiment, when a finger enters the field of view and obstructs the shooting scene.
[0033] Figure 3This is a structural block diagram of a camera focusing device in one embodiment;
[0034] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0035] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0036] Camera focusing is a crucial component of zoom image acquisition systems. Because these systems require continuous, real-time adjustments to the camera's focal length based on the object's height to acquire high-quality images, achieving fast and accurate camera focusing has become a pressing issue for those skilled in the art.
[0037] It is understood that the terms "first," "second," etc., used in this application may be used to describe various technical terms herein, but unless otherwise specified, these technical terms are not limited to these terms. These terms are only used to distinguish one technical term from another. For example, without departing from the scope of this application, the first preset threshold and the second preset threshold may be the same or different.
[0038] To address the problems existing in the aforementioned related technologies, this application provides a camera focusing method. This method can be applied to a server, a terminal, or a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. The server can be a standalone server or a server cluster composed of multiple servers. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. It should be noted that the quantity "multiple" mentioned in the embodiments of this application refers to a quantity of "at least two," for example, "multiple" means "at least two."
[0039] In one embodiment, such as Figure 1 As shown, a camera focusing method is provided. This embodiment illustrates the application of this method to a server, and the method includes the following steps:
[0040] 102. During the process of focusing the camera according to the initial focusing direction, the image of the target scene captured by the camera is acquired in real time.
[0041] It should be noted that the camera can be a camera using a small lens without a focus ring, and the process of focusing the camera mainly refers to manually turning the lens to focus. In conjunction with the embodiments of this application, a specific application scenario is as follows: the server processes the acquired image and feeds the processing result back to the camera to guide the user in focusing the camera.
[0042] 104. If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0043] 106. Adjust the camera focus in real time according to the real-time focus direction until the first preset condition is met, then stop focusing.
[0044] In the aforementioned camera focusing method, during the focusing process according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time. If the acquired image is the target image, the real-time focusing direction corresponding to the acquired target image is determined based on the initial focusing direction. The camera is then focused in real time according to the real-time focusing direction until a first preset condition is met, at which point the focusing process ends. Since the camera's real-time focusing direction is determined based on the images of the target scene captured in real time, an accurate real-time focusing direction is obtained, thereby achieving fast and accurate focusing of the camera and enabling rapid batch focusing of devices equipped with the camera.
[0045] In one embodiment, the target image refers to an image that is not occluded.
[0046] It should be noted that since most cameras use small lenses without a focus ring, it's inevitable that fingers will sometimes enter the field of view and obstruct the shooting scene during focusing. When the camera captures the target scene at the moment this happens, it will obtain an image with the obstruction. Because the obstructed image affects the determination of the real-time focus direction, it may result in an incorrect focus direction, ultimately affecting the camera's fast and accurate focusing. Therefore, by discarding the obstructed image and retaining the unobstructed image, the camera's accurate real-time focus direction can be obtained based on the real-time acquired unobstructed image, thus achieving fast and accurate focusing.
[0047] Specifically, the process of determining the target image includes, but is not limited to: for the current image captured in real time, dividing the current image into blocks to obtain a set of block regions corresponding to the current image; determining the maximum average gray value based on the average gray value of each block region in the set of block regions; determining whether the current image has occlusion based on the difference between the average gray value of each block region and the maximum average gray value; if there is no occlusion, the current image is used as the target image; if there is occlusion, the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0048] Specifically, the presence of occlusion in the current image is determined based on the difference between the average grayscale value and the maximum average grayscale value of each segmented region. This includes: if the difference between the average grayscale value and the maximum average grayscale value of all segments corresponding to the current image is greater than a fourth preset threshold, then the current image is determined to be occluded; otherwise, the current image is determined not to be occluded. It is understandable that since occluded areas typically have higher grayscale values, the presence of occlusion in the current image can be determined relatively accurately based on the difference in grayscale values.
[0049] In this embodiment, since the target image refers to an image without occlusion, the camera's accurate real-time focusing direction can be obtained, thereby enabling fast and accurate focusing of the camera.
[0050] In one embodiment, determining the real-time focus direction corresponding to the target image acquired in real time, based on the camera's initial focus direction, includes:
[0051] For the current target image captured in real time, determine whether the current target image meets the second preset condition. The second preset condition includes that the image group composed of the current target image and the target images previously acquired in real time meet the third preset condition.
[0052] The number of frames of the target image previously acquired in real time can be 4 frames, and the number of frames of the image group can be 5 frames.
[0053] If the current target image meets the second preset condition, the focusing direction is redefined based on the image group composed of the current target image and the initial focusing direction, and the redefined focusing direction is used as the real-time focusing direction corresponding to the current target image; if the current target image does not meet the second preset condition, the initial focusing direction is used as the real-time focusing direction corresponding to the current target image.
[0054] In this embodiment, the system determines whether the current target image, captured in real-time, meets a second preset condition. The second preset condition includes that the image group comprised of the current target image and previously acquired target images meets a third preset condition. If the current target image meets the second preset condition, the focusing direction is redefined based on the image group and the initial focusing direction, and this redefined focusing direction is used as the real-time focusing direction corresponding to the current target image. If the current target image does not meet the second preset condition, the initial focusing direction is used as the real-time focusing direction corresponding to the current target image. Because the camera's real-time focusing direction is determined in real-time, the camera will not focus in an incorrect direction, thus ensuring that the camera can quickly and accurately complete focusing.
[0055] In one embodiment, the third preset condition includes all target images in the image group composed of the current target image showing an increasing or decreasing gradient according to the shooting time sequence, and the third preset condition also includes the gradient difference between any two adjacent target images in the image group composed of the current target image being greater than the first preset threshold.
[0056] The first preset threshold can be 0.1.
[0057] It should be noted that for any target image in the image group consisting of the current target image, the gradient of any target image can be calculated using at least one of the Sobel operator, the Scharr operator, or the Laplacian operator. This application embodiment does not specifically limit this. Specifically, the process of determining the gradient corresponding to any target image can be as follows: calculate the gradient of each pixel in any target image; obtain the gradient of any target image based on the gradient of each pixel in any target image.
[0058] It's important to note that the reason the real-time focus direction for the current target image can be determined based on the gradient trends of all target images in the image group comprised of the current target image is because the gradient of a target image is positively correlated with its sharpness. A larger gradient indicates higher sharpness, and vice versa. The trend in sharpness reflects the correctness of the focus direction. Furthermore, since the real-time focus direction is determined based on the gradient trends of all target images in the image group, occluded images will have very small gradients due to the occlusion. Based on the aforementioned sharpness quantification, occluded images will be identified as having low sharpness. However, in reality, occluded images may have high sharpness, leading to inaccurate sharpness identification and misleading the focus direction determination. Therefore, by discarding occluded images and using the real-time acquired, unoccluded images, the accurate real-time focus direction of the camera can be obtained, enabling fast and accurate focusing.
[0059] In this embodiment, the third preset condition includes that all target images in the image group composed of the current target image exhibit an increasing or decreasing gradient according to the shooting sequence. The third preset condition also includes that the gradient difference between any two adjacent target images in the image group composed of the current target image is greater than a first preset threshold. On one hand, by observing the gradient change trend, it can be determined whether the focusing direction is correct during manual focusing, thereby obtaining the camera's accurate real-time focusing direction and ensuring that the camera can quickly and accurately complete focusing. On the other hand, since the gradient difference between any two adjacent target images in the image group composed of the current target image is greater than the first preset threshold, gradient jitter caused by environmental factors is excluded from being mistakenly identified as gradient changes generated during the focusing process, thus obtaining the camera's accurate real-time focusing direction.
[0060] In one embodiment, redetermining the focus direction based on an image group consisting of the current target image and an initial focus direction includes:
[0061] If all target images in the image group consisting of the current target image show an increasing gradient according to the shooting time sequence, then the initial focusing direction is used as the redefined focusing direction. If all target images in the image group consisting of the current target image show a decreasing gradient according to the shooting time sequence, then the opposite focusing direction of the initial focusing direction is used as the redefined focusing direction.
[0062] Understandably, if all target images in the image group comprised of the current target image show an increasing gradient in sharpness according to their shooting sequence (i.e., all target images in the image group comprised of the current target image show an increasing sharpness according to their shooting sequence), then the initial focusing direction can be determined to be correct, and therefore, the initial focusing direction is used as the redefined focusing direction. Conversely, if all target images in the image group comprised of the current target image show a decreasing gradient in sharpness according to their shooting sequence (i.e., all target images in the image group comprised of the current target image show a decreasing sharpness according to their shooting sequence), then the initial focusing direction can be determined to be incorrect, and therefore, the opposite focusing direction is used as the redefined focusing direction.
[0063] In this embodiment, if all target images in the image group composed of the current target image show an increasing gradient according to the shooting sequence, the initial focusing direction is used as the redefined focusing direction. Conversely, if all target images in the image group composed of the current target image show a decreasing gradient according to the shooting sequence, the opposite focusing direction is used as the redefined focusing direction. Because the gradient change trend can determine whether the focusing direction is correct during manual focusing, the camera's accurate real-time focusing direction can be obtained, thus ensuring that the camera can quickly and accurately complete focusing.
[0064] In one embodiment, for the current target image captured in real time, the first preset condition includes that in the image group composed of the current target image and the target images previously acquired in real time, all target images show a gradient decrease according to the shooting time sequence and the gradient difference between each two adjacent target images is greater than a second preset threshold.
[0065] It should be noted that the value of the second preset threshold can be the same as or different from the value of the first preset threshold.
[0066] Specifically, assuming the camera focuses along the accurate real-time focusing direction, it can be understood that during this focusing process, the camera will inevitably produce a target image with the highest gradient correspondence. This is determined by checking if a target image with the highest gradient correspondence has been found until a first preset condition is met.
[0067] In practical applications, the server records the gradient corresponding to the target image during the camera focusing process and the target focusing direction corresponding to the image group that meets the first preset condition. Based on the recording results, the maximum gradient is determined. After focusing ends, the camera continues to focus in the opposite direction to the target focusing direction. During this focusing process, images of the target scene captured by the camera are acquired in real time, and it is determined whether the difference between the gradient corresponding to the real-time acquired image and the maximum gradient is less than a sixth preset threshold. If it is less, focusing ends, and the camera takes a picture based on the current focusing value. If it is greater, the process of acquiring images of the target scene captured by the camera in real time continues until the difference between the gradient corresponding to the real-time acquired image and the maximum gradient is less than the sixth preset threshold, at which point focusing ends.
[0068] In one embodiment, the process of determining the target image includes: for the current image captured in real time, determining whether the current image has occlusion based on the template image; if there is no occlusion, the current image is used as the target image; if there is occlusion, the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0069] Specifically, determining whether the current image is occluded based on the template image includes: determining the similarity value between the template image and the current image; if the similarity value between the template image and the current image is greater than a fifth preset threshold, then the current image is determined to be occluded, otherwise the current image is determined to be occluded.
[0070] Understandably, since the template image is obtained by capturing the target scene with a camera, and the same camera and target scene are used to obtain the current image, the result of determining whether there is occlusion in the current image will be more accurate.
[0071] In this embodiment, since the target image refers to an image without occlusion, the camera's accurate real-time focusing direction can be obtained, thereby enabling fast and accurate focusing of the camera.
[0072] In one embodiment, determining whether the current image is occluded based on the template image includes:
[0073] Edges are cropped from both the template image and the current image to obtain cropped images corresponding to the template image and the current image, respectively. The cropped image corresponding to the template image is used as the template edge image, and the cropped image corresponding to the current image is used as the current edge image. The position of the template edge image in the template image corresponds to the position of the current edge image in the current image.
[0074] It should be noted that during focusing, the camera lens may slightly shake, causing a slight change in the shooting angle when capturing the target area. Therefore, the cropped area must meet the following condition: even with slight camera lens shaking during focusing, the similarity value between the template edge image and the current edge image can determine whether there is occlusion in the current image. It is understandable that edge cropping of both the template image and the current image is necessary because, during actual focusing, if a finger enters the field of view and obstructs the shooting scene, the image captured by the camera may still be obstructed. Figure 2 As shown, Figure 2 In this context, the occlusion area of an image is usually at the edge. Therefore, to reduce the computational load, while ensuring that we can determine whether each frame in the image group is occluded, we only need to determine the similarity value between the template edge image and the current edge image to determine whether the current image is occluded.
[0075] Specifically, edge cropping is performed on the template image and the current image respectively to obtain the cropped image corresponding to the template image and the cropped image corresponding to the current image, including but not limited to: for any image in the template image and the current image, a non-cropped image of a specified size and shape is determined within any image, and the area in any image other than the non-cropped image is taken as the cropped image corresponding to any image, and the non-cropped image does not contain the boundary pixels of any image.
[0076] Determine the similarity value between the template edge image and the current edge image.
[0077] Specifically, this application does not limit the process of determining the similarity value between the template edge image and the current edge image, including but not limited to: obtaining feature points of the template edge image and the current edge image respectively; wherein, the feature points can be Harris corner points or Sift feature points; comparing the feature points of the template edge image and the feature points of the current edge image respectively; and determining the similarity value between the template edge image and the current edge image based on the comparison results. It should be noted that the more similar feature points exist between the template edge image and the current edge image, the greater the similarity value between the template edge image and the current edge image. It may also include: performing matrix decomposition on the template edge image and the current edge image respectively to obtain the matrix element values and robustness feature values of the template edge image, and obtaining the matrix element values and robustness feature values of the current edge image; determining the similarity value between the template edge image and the current edge image based on the matrix element values and robustness feature values of the template edge image and the matrix element values and robustness feature values of the current edge image. Wherein, the matrix decomposition can be at least one of SVD decomposition or NMF decomposition, and this application embodiment does not specifically limit it.
[0078] It may also include: obtaining a first brightness histogram of the template edge image and converting the first brightness histogram into a first vector; obtaining a second brightness histogram of the current edge image and converting the second brightness histogram into a second vector; and determining the similarity value between the template edge image and the current edge image based on the first vector and the second vector.
[0079] The first brightness histogram counts the number of pixels in the template edge image at each brightness level. The horizontal axis of the first brightness histogram represents brightness, and the vertical axis represents the number of pixels. The physical meaning of the second brightness histogram is the same as that of the first brightness histogram, and will not be repeated here. Because the first brightness histogram effectively normalizes the template edge image, and the second brightness histogram effectively normalizes the current edge image, the computational load is reduced, thus enabling a faster and simpler similarity result.
[0080] If the similarity value between the template edge image and the current edge image is greater than the third preset threshold, it is determined that the current image does not have occlusion; otherwise, it is determined that the current image has occlusion.
[0081] It should be noted that, in actual implementation, the third preset threshold can be 0.5.
[0082] It is understandable that both the template image and the current image are typically rectangular and include four boundary lines. The four boundary lines of the template image are used as the first boundary lines, and the four boundary lines of the current image are used as the second boundary lines. Therefore, determining whether the current image has occlusion based on the template image can also include:
[0083] For any first boundary line of the template image, determine the portion of the template image extracted from the template image by the first boundary line and the line parallel to the first boundary line; wherein, the distance between the boundary line and the line parallel to the boundary line is a seventh preset threshold.
[0084] For any second boundary line in the current image, determine the portion of the current image that is extracted from the current image by the second boundary line and its parallel line; wherein, the distance between the second boundary line and its parallel line is a seventh preset threshold.
[0085] The part of the current image corresponding to the position of each part of the template image is compared with each part of the template image to obtain the similarity value between the part of the current image corresponding to the position of each part of the template image and each part of the template image.
[0086] If the similarity value between a portion of the current image and a portion of the template image corresponding to a certain position is not greater than the eighth preset threshold, then the current image is determined to be occluded; otherwise, the current image is determined not to be occluded.
[0087] It should be noted that the process of obtaining the similarity value between the current image corresponding to the position of each part of the template image and each part of the template image can be referred to the process of determining the similarity value between the template edge image and the current edge image, which will not be repeated here.
[0088] In this embodiment, edge cropping is performed on both the template image and the current image to obtain cropped images corresponding to the template image and the current image, respectively. The cropped image corresponding to the template image is used as the template edge image, and the cropped image corresponding to the current image is used as the current edge image. The positions of the template edge image and the current edge image in the template image correspond to each other. A similarity value is determined between the template edge image and the current edge image. If the similarity value is greater than a third preset threshold, it is determined that the current image is not occluded; otherwise, it is determined that the current image is occluded. Since edge cropping is performed on both the template image and the current image, subsequent determination of whether the current image is occluded only requires determining the similarity value between the template edge image and the current edge image, eliminating the need to determine the similarity value between the entire region of the template image and the entire region of the current image, thus reducing computational load.
[0089] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0090] Based on the same inventive concept, this application also provides a camera focusing device for implementing the camera focusing method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations of the one or more camera focusing device embodiments provided below can be found in the limitations of the camera focusing method described above, and will not be repeated here.
[0091] In one embodiment, such as Figure 3 As shown, a camera focusing device is provided, including: an acquisition module 302, a first determination module 304, and a focusing module 306, wherein:
[0092] The acquisition module 302 is used to acquire images of the target scene captured by the camera in real time during the process of focusing the camera according to the initial focusing direction;
[0093] The first determining module 304 is used to determine the real-time focusing direction corresponding to the target image acquired in real time, based on the initial focusing direction, when the image acquired in real time is the target image.
[0094] The focusing module 306 is used to focus the camera in real time according to the real-time focusing direction until the first preset condition is met.
[0095] In one embodiment, the target image refers to an image that is not occluded.
[0096] In one embodiment, the first determining module 304 includes:
[0097] The judgment unit is used to determine whether the current target image obtained in real time meets the second preset condition. The second preset condition includes that the image group composed of the current target image and the target images previously obtained in real time meet the third preset condition.
[0098] The first determining unit is configured to, if the current target image meets the second preset condition, redetermine the focusing direction based on the image group composed of the current target image and the initial focusing direction, and use the redetermined focusing direction as the real-time focusing direction corresponding to the current target image; if the current target image does not meet the second preset condition, use the initial focusing direction as the real-time focusing direction corresponding to the current target image.
[0099] In one embodiment, the third preset condition includes all target images in the image group composed of the current target image showing an increasing or decreasing gradient according to the shooting time sequence, and the third preset condition also includes the gradient difference between any two adjacent target images in the image group composed of the current target image being greater than the first preset threshold.
[0100] In one embodiment, the determining unit includes: a determining subunit, configured to, if all target images in the image group composed of the current target image show an increasing gradient according to the shooting time sequence, use the initial focusing direction as the redefined focusing direction; and if all target images in the image group composed of the current target image show a decreasing gradient according to the shooting time sequence, use the opposite focusing direction of the initial focusing direction as the redefined focusing direction.
[0101] In one embodiment, for the current target image captured in real time, the first preset condition includes that in the image group composed of the current target image and the target images previously acquired in real time, all target images show a gradient decrease according to the shooting time sequence and the gradient difference between each two adjacent target images is greater than a second preset threshold.
[0102] In one embodiment, the device further includes: a second determining module, configured to determine whether there is occlusion in the current image obtained by real-time capture based on a template image; if there is no occlusion, the current image is used as the target image; if there is occlusion, the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0103] In one embodiment, the second determining module includes:
[0104] The cropping unit is used to crop the edges of the template image and the current image respectively, to obtain the cropped image corresponding to the template image and the cropped image corresponding to the current image; wherein, the cropped image corresponding to the template image is used as the template edge image, and the cropped image corresponding to the current image is used as the current edge image, and the position of the template edge image in the template image corresponds to the position of the current edge image in the current image.
[0105] The second determining unit is used to determine the similarity value between the template edge image and the current edge image;
[0106] The third determining unit is used to determine that the current image does not have occlusion if the similarity value between the template edge image and the current edge image is greater than a third preset threshold, and otherwise determine that the current image has occlusion.
[0107] Each module in the aforementioned camera focusing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0108] In one embodiment, a robot is provided, including a memory and a processor, the memory for storing a computer program, the processor executing the computer program to perform the following steps:
[0109] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0110] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0111] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0112] It should be noted that the camera can be a camera used on a robot.
[0113] In one embodiment, when the processor executes a computer program, the target image refers to an image that is not occluded.
[0114] In one embodiment, when the processor executes the computer program, it further implements the following steps: for the current target image captured in real time, it determines whether the current target image meets a second preset condition, the second preset condition including that the image group composed of the current target image and the target images previously acquired in real time meet a third preset condition;
[0115] If the current target image meets the second preset condition, the focusing direction is redefined based on the image group composed of the current target image and the initial focusing direction, and the redefined focusing direction is used as the real-time focusing direction corresponding to the current target image; if the current target image does not meet the second preset condition, the initial focusing direction is used as the real-time focusing direction corresponding to the current target image.
[0116] In one embodiment, when the processor executes a computer program, the third preset condition includes all target images in the image group consisting of the current target image showing an increasing or decreasing gradient according to the shooting time sequence, and the third preset condition also includes the gradient difference between any two adjacent target images in the image group consisting of the current target image being greater than the first preset threshold.
[0117] In one embodiment, when the processor executes the computer program, it further implements the following steps: if all target images in the image group composed of the current target image show an increasing gradient according to the shooting time sequence, then the initial focusing direction is taken as the redefined focusing direction; if all target images in the image group composed of the current target image show a decreasing gradient according to the shooting time sequence, then the opposite focusing direction of the initial focusing direction is taken as the redefined focusing direction.
[0118] In one embodiment, when the processor executes a computer program, for the current target image captured in real time, the first preset condition includes that in the image group composed of the current target image and the target images previously acquired in real time, all target images show a gradient decrease according to the shooting time sequence and the gradient difference between each two adjacent target images is greater than a second preset threshold.
[0119] In one embodiment, when the processor executes the computer program, it further implements the following steps: for the current image captured in real time, determine whether there is occlusion in the current image based on the template image; if there is no occlusion, then the current image is used as the target image; if there is occlusion, then the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0120] In one embodiment, when the processor executes the computer program, it further performs the following steps: performing edge cropping on the template image and the current image respectively to obtain a cropped image corresponding to the template image and a cropped image corresponding to the current image; wherein, the cropped image corresponding to the template image is used as the template edge image, the cropped image corresponding to the current image is used as the current edge image, and the position of the template edge image in the template image corresponds to the position of the current edge image in the current image.
[0121] Determine the similarity value between the template edge image and the current edge image;
[0122] If the similarity value between the template edge image and the current edge image is greater than the third preset threshold, it is determined that the current image does not have occlusion; otherwise, it is determined that the current image has occlusion.
[0123] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores relevant data needed to determine the camera's focus value. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a camera focusing method.
[0124] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0125] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0126] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0127] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0128] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0129] In one embodiment, when the processor executes a computer program, the target image refers to an image that is not occluded.
[0130] In one embodiment, when the processor executes the computer program, it further implements the following steps: for the current target image captured in real time, it determines whether the current target image meets a second preset condition, the second preset condition including that the image group composed of the current target image and the target images previously acquired in real time meet a third preset condition;
[0131] If the current target image meets the second preset condition, the focusing direction is redefined based on the image group composed of the current target image and the initial focusing direction, and the redefined focusing direction is used as the real-time focusing direction corresponding to the current target image; if the current target image does not meet the second preset condition, the initial focusing direction is used as the real-time focusing direction corresponding to the current target image.
[0132] In one embodiment, when the processor executes a computer program, the third preset condition includes all target images in the image group consisting of the current target image showing an increasing or decreasing gradient according to the shooting time sequence, and the third preset condition also includes the gradient difference between any two adjacent target images in the image group consisting of the current target image being greater than the first preset threshold.
[0133] In one embodiment, when the processor executes the computer program, it further implements the following steps: if all target images in the image group composed of the current target image show an increasing gradient according to the shooting time sequence, then the initial focusing direction is taken as the redefined focusing direction; if all target images in the image group composed of the current target image show a decreasing gradient according to the shooting time sequence, then the opposite focusing direction of the initial focusing direction is taken as the redefined focusing direction.
[0134] In one embodiment, when the processor executes a computer program, for the current target image captured in real time, the first preset condition includes that in the image group composed of the current target image and the target images previously acquired in real time, all target images show a gradient decrease according to the shooting time sequence and the gradient difference between each two adjacent target images is greater than a second preset threshold.
[0135] In one embodiment, when the processor executes the computer program, it further implements the following steps: for the current image captured in real time, determine whether there is occlusion in the current image based on the template image; if there is no occlusion, then the current image is used as the target image; if there is occlusion, then the current image is not used as the target image. The template image is obtained by the camera capturing the target scene, and there is no occlusion in the template image.
[0136] In one embodiment, when the processor executes the computer program, it further performs the following steps: performing edge cropping on the template image and the current image respectively to obtain a cropped image corresponding to the template image and a cropped image corresponding to the current image; wherein, the cropped image corresponding to the template image is used as the template edge image, the cropped image corresponding to the current image is used as the current edge image, and the position of the template edge image in the template image corresponds to the position of the current edge image in the current image.
[0137] Determine the similarity value between the template edge image and the current edge image;
[0138] If the similarity value between the template edge image and the current edge image is greater than the third preset threshold, it is determined that the current image does not have occlusion; otherwise, it is determined that the current image has occlusion.
[0139] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0140] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0141] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0142] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0143] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0144] During the process of focusing the camera according to the initial focusing direction, images of the target scene captured by the camera are acquired in real time;
[0145] If the image acquired in real time is the target image, then the real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction.
[0146] The camera is focused in real time according to the real-time focus direction until the first preset condition is met.
[0147] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0148] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0149] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A camera focusing method, characterized by, The method comprises: During focusing on the camera according to an initial focusing direction, an image obtained by the camera shooting a target scene is acquired in real time; For a current image obtained by real-time shooting, it is determined whether the current image has an occlusion according to a template image, wherein the template image is obtained by the camera shooting the target scene and does not have an occlusion, and if the current image does not have an occlusion, the current image is taken as a target image, and if the current image has an occlusion, the current image is not taken as the target image; In a case where the image acquired in real time is the target image, a real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction; The camera is focused in real time according to the real-time focusing direction until a first preset condition is reached.
2. The method of claim 1, wherein, The real-time focusing direction corresponding to the target image acquired in real time is determined according to the initial focusing direction of the camera, comprising: For a current target image obtained by real-time shooting, it is determined whether the current target image satisfies a second preset condition, wherein the second preset condition comprises that an image group composed of the current target image and a target image acquired in real time before the current target image satisfies a third preset condition; If the current target image satisfies the second preset condition, a focusing direction is re-determined based on the image group composed of the current target image and the initial focusing direction, and the re-determined focusing direction is taken as the real-time focusing direction corresponding to the current target image; if the current target image does not satisfy the second preset condition, the initial focusing direction is taken as the real-time focusing direction corresponding to the current target image.
3. The method of claim 2, wherein, The third preset condition comprises that all target images in the image group composed of the current target image present gradient increment or gradient decrement according to shooting time sequence, and the third preset condition further comprises that a gradient difference between every two adjacent target images in the image group composed of the current target image is greater than a first preset threshold.
4. The method of claim 3, wherein, The focusing direction is re-determined based on the image group composed of the current target image and the initial focusing direction, comprising: If all target images in the image group composed of the current target image present gradient increment according to shooting time sequence, the initial focusing direction is taken as the re-determined focusing direction, and if all target images in the image group composed of the current target image present gradient decrement according to shooting time sequence, an opposite focusing direction of the initial focusing direction is taken as the re-determined focusing direction.
5. The method of claim 1, wherein, For a current target image obtained by real-time shooting, the first preset condition comprises that all target images in an image group composed of the current target image and a target image acquired in real time before the current target image present gradient decrement according to shooting time sequence and a gradient difference between every two adjacent target images is greater than a second preset threshold.
6. The method of claim 1, wherein, The determination of whether the current image has an occlusion according to the template image comprises: respectively, to obtain a template image corresponding to the template image and a current image corresponding to the current image; wherein the template image corresponding to the template image is taken as a template edge image, and the current image corresponding to the current image is taken as a current edge image, the position of the template edge image in the template image and the position of the current edge image in the current image correspond to each other; determining a similarity value between the template edge image and the current edge image; if the similarity value between the template edge image and the current edge image is greater than a third preset threshold, it is determined that the current image does not exist occlusion, otherwise, it is determined that the current image exists occlusion.
7. A camera focusing device, characterized by, The device comprises: an acquisition module, configured to acquire an image of a target scene obtained by the camera in real time during focusing of the camera in an initial focusing direction; a second determination module, configured to determine whether a current image obtained in real time by photographing exists occlusion according to a template image, if not, the current image is taken as a target image, if yes, the current image is not taken as a target image, the template image is obtained by photographing the target scene by the camera, and the template image does not exist occlusion; a first determination module, configured to determine a real-time focusing direction corresponding to the target image obtained in real time according to the initial focusing direction if the image obtained in real time is the target image; a focusing module, configured to focus the camera in real time according to the real-time focusing direction until a first preset condition is reached.
8. A robot comprising a memory and a processor, the memory for storing a computer program, characterized in that, The processor is configured to implement the steps of the method in any one of claims 1 to 6 when executing the computer program. The processor is configured to implement the steps of the method in any one of claims 1 to 6 when executing the computer program.
Citation Information
Patent Citations
Non-contact automatic focus method and device
WO2017000576A1