[go: up one dir, main page]

CN114422687B - Preview image switching method and device, electronic equipment and storage medium - Google Patents

Preview image switching method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114422687B
CN114422687B CN202011176686.1A CN202011176686A CN114422687B CN 114422687 B CN114422687 B CN 114422687B CN 202011176686 A CN202011176686 A CN 202011176686A CN 114422687 B CN114422687 B CN 114422687B
Authority
CN
China
Prior art keywords
image
camera
preview image
target area
initial preview
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011176686.1A
Other languages
Chinese (zh)
Other versions
CN114422687A (en
Inventor
姚海强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Xiaomi Mobile Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Xiaomi Mobile Software Co Ltd
Priority to CN202011176686.1A priority Critical patent/CN114422687B/en
Publication of CN114422687A publication Critical patent/CN114422687A/en
Application granted granted Critical
Publication of CN114422687B publication Critical patent/CN114422687B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/63Control of cameras or camera modules by using electronic viewfinders
    • H04N23/631Graphical user interfaces [GUI] specially adapted for controlling image capture or setting capture parameters
    • H04N23/632Graphical user interfaces [GUI] specially adapted for controlling image capture or setting capture parameters for displaying or modifying preview images prior to image capturing, e.g. variety of image resolutions or capturing parameters
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/64Computer-aided capture of images, e.g. transfer from script file into camera, check of taken image quality, advice or proposal for image composition or decision on when to take image
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/66Remote control of cameras or camera parts, e.g. by remote control devices
    • H04N23/663Remote control of cameras or camera parts, e.g. by remote control devices for controlling interchangeable camera parts based on electronic image sensor signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N5/00Details of television systems
    • H04N5/222Studio circuitry; Studio devices; Studio equipment
    • H04N5/262Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
    • H04N5/268Signal distribution or switching

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Studio Devices (AREA)

Abstract

本公开是关于一种预览图像切换方法及装置、电子设备、存储介质。其中,该方法应用于电子设备,包括:通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。

The present disclosure relates to a preview image switching method and device, electronic equipment, and storage media. Wherein, the method is applied to electronic equipment, including: collecting a first image through a first camera and displaying an initial preview image generated based on the first image; determining that the object distance between the first camera and the subject is less than a preset distance In the case of , switch the currently used camera from the first camera to the second camera; wherein, the focal length of the first camera is greater than the focal length of the second camera, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera. ; Collect the second image through the second camera, and determine the target area consistent with the image content presented in the initial preview image from the second image; determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image.

Description

预览图像切换方法及装置、电子设备及存储介质Preview image switching method and device, electronic equipment and storage medium

技术领域Technical field

本公开涉及图像处理领域,尤其涉及一种预览图像切换方法及装置、电子设备及存储介质。The present disclosure relates to the field of image processing, and in particular, to a preview image switching method and device, electronic equipment and storage media.

背景技术Background technique

随着成像技术的不断发展,越来越多的用户加入到摄影摄像的行列中,甚至造就了全民摄影的热潮。With the continuous development of imaging technology, more and more users have joined the ranks of photography, and even created a nationwide photography craze.

时下的电子设备,例如手机、平板等,为了在不同拍摄场景下均能够采集到视觉效果较好的图像,大多装配有多个摄像头。Today's electronic devices, such as mobile phones, tablets, etc., are mostly equipped with multiple cameras in order to capture images with good visual effects in different shooting scenarios.

在相关技术中,当被摄对象距离电子设备较近时,需要将焦距较大的摄像头切换至焦距较小的摄像头,以获得清晰的图像。然而,在该切换过程中,由于焦距急剧变小,以及与摄像头搭配使用的图像传感器的尺寸增大,很可能造成获得的图像仅中间区域清晰,而边缘区域模糊不清的问题。In related technologies, when a subject is close to an electronic device, a camera with a larger focal length needs to be switched to a camera with a smaller focal length to obtain a clear image. However, during this switching process, due to the sharp reduction in focal length and the increase in the size of the image sensor used with the camera, it is likely to cause the problem that only the middle area of the image obtained is clear, while the edge areas are blurred.

发明内容Contents of the invention

本公开提供一种预览图像切换方法及装置、电子设备、存储介质,能够在由焦距较大的摄像头切换至焦距较小的摄像头的过程中,避免最终得到的预览画面产生边缘模糊的问题。The present disclosure provides a preview image switching method and device, electronic equipment, and storage medium, which can avoid the problem of edge blur in the final preview image during the process of switching from a camera with a larger focal length to a camera with a smaller focal length.

根据本公开的第一方面,提供一种预览图像切换方法,应用于电子设备,包括:According to a first aspect of the present disclosure, a preview image switching method is provided, applied to electronic devices, including:

通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;Collect the first image through the first camera, and display the initial preview image generated based on the first image;

在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;When it is determined that the object distance between the first camera and the subject is less than the preset distance, the currently used camera is switched from the first camera to the second camera; wherein the focal length of the first camera is greater than the focal length of the second camera, And the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera;

通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;Collect a second image through a second camera, and determine a target area from the second image that is consistent with the image content presented in the initial preview image;

将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。The image content belonging to the target area in the second image is determined as the current preview image, and the displayed initial preview image is switched to the current preview image.

根据本公开的第二方面,提供一种预览图像切换装置,应用于电子设备,包括:According to a second aspect of the present disclosure, a preview image switching device is provided, applied to electronic equipment, including:

生成单元,通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;A generating unit that collects the first image through the first camera and displays an initial preview image generated based on the first image;

第一切换单元,在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;The first switching unit switches the currently used camera from the first camera to the second camera when it is determined that the object distance between the first camera and the subject is less than the preset distance; wherein the focal length of the first camera is greater than the second camera. The focal length of the two cameras, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera;

确定单元,通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;A determining unit that collects a second image through a second camera and determines a target area from the second image that is consistent with the image content presented in the initial preview image;

第二切换单元,将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。The second switching unit determines the image content belonging to the target area in the second image as the current preview image, and switches the displayed initial preview image to the current preview image.

根据本公开的第三方面,提供一种电子设备,包括:According to a third aspect of the present disclosure, an electronic device is provided, including:

处理器;processor;

用于存储处理器可执行指令的存储器;Memory used to store instructions executable by the processor;

其中,所述处理器通过运行所述可执行指令以实现如第一方面所述的方法。Wherein, the processor implements the method described in the first aspect by running the executable instructions.

根据本公开的第四方面,提供一种计算机可读存储介质,其上存储有计算机指令,该指令被处理器执行时实现如第一方面所述方法的步骤。According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, computer instructions are stored thereon, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

在本公开的技术方案中,在采用焦距较大的摄像头采集图像的情况下,基于该摄像头采集到的图像展示初始预览图像。当确定摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用的摄像头切换为焦距较小的摄像头。在切换摄像头之后,本公开并未直接将采集到的图像作为预览图像,而是从切换摄像头后采集到的图像中,确定出了与初始预览图像呈现的图像内容一致的目标区域,并将该目标区域中的图像内容确定为当前预览图像。In the technical solution of the present disclosure, when a camera with a larger focal length is used to collect images, an initial preview image is displayed based on the image collected by the camera. When it is determined that the object distance between the camera and the subject is less than the preset distance, the currently used camera is switched to a camera with a smaller focal length. After switching the camera, the present disclosure does not directly use the collected image as a preview image. Instead, from the image collected after switching the camera, the target area consistent with the image content presented in the initial preview image is determined, and the target area is determined. The image content in the target area is determined to be the current preview image.

应当理解的是,由焦距较大的摄像头切换至焦距较小的摄像头,视场角变大,拍摄得到的图像中的图像内容会增多,且由于被摄对象与电子设备之间的相对位置未发生变化,增加的图像内容通常显示于拍摄得到的图像的周围。因此,本公开仅将确定的目标区域确定为当前预览图像,相当于将周围的画面(或说图像的边缘区域)进行了裁剪。可见,相较于相关技术,本公开不会显示切换摄像头后采集到的图片的边缘区域,进而避免了由焦距较大的摄像头切换至焦距较小的摄像头之后,显示的预览图像边缘模糊的问题。It should be understood that when switching from a camera with a larger focal length to a camera with a smaller focal length, the field of view becomes larger, and the image content in the captured image will increase, and because the relative position between the subject and the electronic device is not Changes occur and the added image content is usually displayed around the captured image. Therefore, the present disclosure only determines the determined target area as the current preview image, which is equivalent to cropping the surrounding picture (or the edge area of the image). It can be seen that compared with related technologies, the present disclosure will not display the edge area of the image collected after switching the camera, thereby avoiding the problem of blurred edges of the displayed preview image after switching from a camera with a larger focal length to a camera with a smaller focal length. .

除此之外,由于在上述过程中,是以摄像头切换前的初始预览图像为标准确定第二图像中的目标区域。可见,当前预览图像与初始预览图像的显示画面一致,避免了摄像头切换过程中预览画面的跳变。In addition, in the above process, the target area in the second image is determined based on the initial preview image before camera switching. It can be seen that the display screen of the current preview image is consistent with the initial preview image, which avoids the jump of the preview screen during the camera switching process.

附图说明Description of the drawings

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.

图1是本公开一示例性实施例示出的一种预览图像切换方法的流程图;Figure 1 is a flow chart of a preview image switching method according to an exemplary embodiment of the present disclosure;

图2是本公开一示例性实施例示出的另一种预览图像切换方法的流程图;Figure 2 is a flow chart of another preview image switching method according to an exemplary embodiment of the present disclosure;

图3是本公开一示例性实施例示出的一种图像传感器上检测区域的分布示意图;Figure 3 is a schematic diagram showing the distribution of detection areas on an image sensor according to an exemplary embodiment of the present disclosure;

图4是本公开一示例性实施例示出的一种第二图像与目标区域之间的相对位置示意图;Figure 4 is a schematic diagram of the relative position between a second image and a target area according to an exemplary embodiment of the present disclosure;

图5是本公开一示例性实施例示出的一种预览图像切换装置的框图;Figure 5 is a block diagram of a preview image switching device according to an exemplary embodiment of the present disclosure;

图6是本公开一示例性实施例示出的另一种预览图像切换装置的框图;Figure 6 is a block diagram of another preview image switching device according to an exemplary embodiment of the present disclosure;

图7是本公开一示例性实施例中一种电子设备的结构示意图。FIG. 7 is a schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure.

具体实施方式Detailed ways

这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with aspects of the disclosure as detailed in the appended claims.

在本公开使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本公开。在本公开和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "the" and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

应当理解,尽管在本公开可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本公开范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of the present disclosure, the first information may also be called second information, and similarly, the second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "when" or "in response to determining."

时下的电子设备,例如手机、平板等,为了在不同拍摄场景下均能够采集到视觉效果较好的图像,大多装配有多个摄像头。例如,在一台智能手机中,可以包括:主摄像头、广角摄像头、超广角摄像头、微距摄像头等。Today's electronic devices, such as mobile phones, tablets, etc., are mostly equipped with multiple cameras in order to capture images with good visual effects in different shooting scenarios. For example, in a smartphone, it can include: main camera, wide-angle camera, ultra-wide-angle camera, macro camera, etc.

在相关技术中,当被摄对象距离电子设备较近时,需要将焦距较大的摄像头切换至焦距较小的摄像头,以获得清晰的图像。其中,当切换后的摄像头(例如,微距摄像头、超广角摄像头等焦距很小的摄像头)用于拍摄近景时,切换后的拍摄模式也被称为近距模式。In related technologies, when a subject is close to an electronic device, a camera with a larger focal length needs to be switched to a camera with a smaller focal length to obtain a clear image. Wherein, when the switched camera (for example, a camera with a very small focal length such as a macro camera or an ultra-wide-angle camera) is used to shoot a close-up view, the switched shooting mode is also called a close-up mode.

然而,在该切换过程中,由于焦距变小,很可能造成获得的图像仅中间区域清晰,而边缘区域模糊不清的问题。需要强调的是,在实际应用中,摄像头的焦距越大,搭配使用的图像传感器的尺寸通常越小。换言之,在由焦距较大的摄像头切换至焦距较小的摄像头的过程中,用于采集图像的图像传感器的尺寸变大。因此,上述边缘区域模糊不清的问题,也被称作是图像传感器增大造成的图像边缘模糊不清的问题。However, during this switching process, due to the smaller focal length, it is likely to cause the problem that only the middle area of the image obtained is clear, while the edge areas are blurred. It should be emphasized that in practical applications, the larger the focal length of the camera, the smaller the size of the image sensor used. In other words, in the process of switching from a camera with a larger focal length to a camera with a smaller focal length, the size of the image sensor used to capture images becomes larger. Therefore, the above-mentioned problem of blurred edge areas is also known as the problem of blurred image edges caused by the increase in image sensors.

为了解决上述问题,本公开提出了一种预览图像切换方法,以解决上述摄像头切换后预览图像边缘模糊不清的技术问题。In order to solve the above problem, the present disclosure proposes a preview image switching method to solve the above technical problem of blurring the edges of the preview image after camera switching.

图1为本公开一示例性实施例示出的一种预览图像切换方法的流程图。该方法应用于电子设备,如图1所示,该方法可以包括以下步骤:FIG. 1 is a flow chart of a preview image switching method according to an exemplary embodiment of the present disclosure. The method is applied to electronic equipment, as shown in Figure 1. The method may include the following steps:

步骤102,通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像。Step 102: Collect the first image through the first camera and display the initial preview image generated based on the first image.

本公开中的电子设备可以为任一类型的电子设备,例如,该电子设备可以为智能手机、平板电脑等移动终端,也可以为智能电视、PC(个人计算机,Personal Computer)等固定终端。应当理解的是,只需装配有多个摄像头,且多个摄像头的焦距不一致的电子设备均可作为本公开中的电子设备,具体应用于哪一种类型的电子设备可以由本领域技术人员根据实际需求确定,本公开对此不作限制。The electronic device in this disclosure may be any type of electronic device. For example, the electronic device may be a mobile terminal such as a smartphone or a tablet computer, or a fixed terminal such as a smart TV or a PC (Personal Computer). It should be understood that any electronic device that only needs to be equipped with multiple cameras and whose focal lengths are inconsistent can be used as the electronic device in the present disclosure. Which type of electronic device it is specifically applied to can be determined by those skilled in the art according to the actual situation. The requirements are determined, and this disclosure does not limit this.

在相关技术中,电子设备中通过安装具备拍摄功能的应用程序,以对装配的多个摄像头进行操控,进而实现拍摄的目的。这种类型的应用程序通常被称为相机应用。在实际应用中,用户在打开电子设备中的相机应用后,相机会自动展示摄像头所采集到的图像,该画面被称为预览图像,以供用户根据预览图像调整拍摄参数。In related technologies, an application with a shooting function is installed in an electronic device to control multiple cameras assembled, thereby achieving the purpose of shooting. This type of application is often called a camera application. In practical applications, after the user opens the camera application in the electronic device, the camera will automatically display the image collected by the camera. This screen is called a preview image, allowing the user to adjust the shooting parameters based on the preview image.

在本公开中也是类似,在电子设备中的相机应用被启动的情况下,即可通过当前所采用的第一摄像头采集图像,进而基于采集的第一图像生成初始预览图像,以供用户预览采集到的图像。应当理解的是,本公开中的第一摄像头可以为任一类型的摄像头,例如该第一摄像头可以为电子设备的主摄像头、广角摄像头、超广角摄像头等中的任一摄像头。Similarly in the present disclosure, when the camera application in the electronic device is started, images can be collected through the currently used first camera, and then an initial preview image is generated based on the collected first image for the user to preview the collection. to the image. It should be understood that the first camera in the present disclosure can be any type of camera, for example, the first camera can be any of the main camera, wide-angle camera, ultra-wide-angle camera, etc. of the electronic device.

步骤104,在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸。Step 104: When it is determined that the object distance between the first camera and the subject is less than the preset distance, switch the currently used camera from the first camera to the second camera; wherein the focal length of the first camera is greater than that of the second camera. focal length, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera.

在本公开中,可以预设一预设距离,以用于判断当前使用的第一摄像头是否已经无法清晰拍摄被摄对象。在实际操作中,可以优先检测被摄对象与第一摄像头之间的距离,即物距,再将该物距与预设距离进行比较,以在确定第一摄像头与被摄对象之间的距离小于预设距离的情况下,将当前使用摄像头切换至焦距更小的第二摄像头。In the present disclosure, a preset distance may be preset for determining whether the currently used first camera is unable to clearly capture the subject. In actual operation, the distance between the subject and the first camera, that is, the object distance, can be detected first, and then the object distance is compared with the preset distance to determine the distance between the first camera and the subject. When the distance is less than the preset distance, the currently used camera is switched to a second camera with a smaller focal length.

在本公开中,既可以采用传统的双向测距技术或单向测距技术,也可以采用ToF(Time of flight,飞行时间法)测距方法,以测得被摄对象与第一摄像头之间的距离。需要声明的是,任一种能够测得被摄对象与第一摄像头之间的距离的方式均可用于本公开,本公开对此不作限制。In the present disclosure, either traditional two-way ranging technology or one-way ranging technology can be used, or ToF (Time of flight, time of flight) ranging method can be used to measure the distance between the subject and the first camera. distance. It should be noted that any method that can measure the distance between the subject and the first camera can be used in the present disclosure, and the disclosure is not limited thereto.

正如上文所述,由于第一摄像头的焦距大于第二摄像头的焦距,因此,通常情况下与第一摄像头搭配使用的图像传感器的尺寸小于与第二摄像头搭配使用的图像传感器。这也正是相关技术中出现预览图像边缘出现图像模糊现象的原因之一。As mentioned above, since the focal length of the first camera is greater than the focal length of the second camera, the image sensor used with the first camera is usually smaller in size than the image sensor used with the second camera. This is also one of the reasons why image blur occurs at the edge of the preview image in related technologies.

步骤106,通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域。Step 106: Collect a second image through the second camera, and determine a target area consistent with the image content presented in the initial preview image from the second image.

在相关技术中,在切换摄像头后采集到的图像被直接作为预览图像。不难理解的是,上述摄像头的切换使得用于采集图像的摄像头的焦距,以及图像传感器尺寸都发生了变化,进而导致了采集到的图像的边缘模糊现象,若直接将采集到的图像作为预览图像,必然导致预览图像中也出现边缘模糊现象。同时,由于摄像头焦距和传感器尺寸的变化,必将改变获得的图像的视场角,使得由原本预览图像切换至当前预览图像的过程必然出现明显的图像跳变现象。从用户视角看来,预览图像的边缘不仅模糊,且预览图像中包含的内容也瞬间变多。In related technologies, images collected after switching cameras are directly used as preview images. It is not difficult to understand that the above-mentioned camera switching causes the focal length of the camera used to collect images and the size of the image sensor to change, which in turn leads to blurring of the edges of the collected images. If the collected images are directly used as previews image, which will inevitably lead to blurred edges in the preview image. At the same time, due to changes in the focal length of the camera and the size of the sensor, the field of view of the obtained image will inevitably change, causing an obvious image jump phenomenon when switching from the original preview image to the current preview image. From the user's perspective, the edges of the preview image are not only blurred, but the content contained in the preview image also instantly increases.

在本公开中,不再如相关技术直接将切换摄像头后采集的图像作为预览图像,而是对采集到的图像进行了一定的预处理。具体的,可以优先确定切换摄像头之前展示的初始预览图像中所呈现的图像内容,并在通过第二摄像头采集第二图像之后,从采集到的第二图像中确定出与初始预览图像呈现的图像内容一致的目标区域。在此基础上,即可将第二图像中属于目标区域的图像内容确定为当前预览图像。In the present disclosure, the image collected after switching the camera is no longer directly used as a preview image as in the related art, but a certain preprocessing is performed on the collected image. Specifically, the image content presented in the initial preview image displayed before switching the camera can be determined first, and after collecting the second image through the second camera, the image presented in the initial preview image can be determined from the collected second image. Target areas with consistent content. On this basis, the image content belonging to the target area in the second image can be determined as the current preview image.

应当理解的是,由于本公开在获得第二图像后,是基于初始预览图像的图像内容从第二图像中确定出当前预览图像,且两者的图像内容一致,显然是不会出现相关技术中预览图像的跳变现象。除此之外,上述摄像头的切换操作在电子设备确定被摄对象与第一摄像头之间的距离小于预设距离的情况下执行,换言之,是由电子设备自动执行切换操作。显然,第二摄像头与第一摄像头的相对位置在切换的瞬间并未发生变化。可见,在摄像头切换导致视场角变大的情况下,采集到的第二图像呈现的图像内容包含第一图像的图像内容,且第一图像的图像内容居于第二图像中趋于中心的位置。换言之,确定的目标区域居于第二图像中趋于中心的位置,相当于第二图像相对于第一图像多出的图像内容位于第二图像的四周(或说边缘区域)。可见,将目标区域确定为当前预览图像,相当于将第二图像中的边缘区域裁剪后将剩余部分作为当前预览图像,即将相关技术中模糊的区域进行裁剪后进行展示。It should be understood that since the present disclosure determines the current preview image from the second image based on the image content of the initial preview image after obtaining the second image, and the image contents of the two are consistent, obviously there will be no problem in the related art. Preview image jump phenomenon. In addition, the above-mentioned camera switching operation is performed when the electronic device determines that the distance between the subject and the first camera is less than the preset distance. In other words, the electronic device automatically performs the switching operation. Obviously, the relative position of the second camera and the first camera does not change at the moment of switching. It can be seen that when the camera switching causes the field of view to become larger, the image content presented in the collected second image contains the image content of the first image, and the image content of the first image is located in the center of the second image. . In other words, the determined target area is located in the center of the second image, which is equivalent to the extra image content of the second image relative to the first image being located around the second image (or in the edge area). It can be seen that determining the target area as the current preview image is equivalent to cropping the edge area in the second image and using the remaining portion as the current preview image, that is, cropping the blurred area in the related technology and displaying it.

在本公开中,可以通过多种方式从第二图像中确定出目标区域。In the present disclosure, the target area may be determined from the second image in various ways.

在一实施例中,可以从初始预览图像呈现的图像内容中确定出多个参照物,并将确定出的多个参照物作为依据,从第二图像中确定出与初始预览图像呈现的图像内容一致的目标区域。例如,在确定出多个参照物后,可以进一步确定多个参照物之间的相对位置关系,以基于确定的多个参照物和相对位置关系从第二图像中确定出目标区域。In one embodiment, multiple reference objects may be determined from the image content presented in the initial preview image, and based on the determined multiple reference objects, the image content presented in the initial preview image may be determined from the second image. Consistent target area. For example, after multiple reference objects are determined, the relative positional relationship between the multiple reference objects may be further determined to determine the target area from the second image based on the determined multiple reference objects and the relative positional relationship.

在另一实施例中,可以优先确定初始预览图像的中心点和视场角,然后在第二图像中确定出与该中心点对应的目标点,以基于确定的目标点和视场角从第二图像中确定出目标区域。应当理解的是,视场角决定了图像中包含的内容多少。可见,在确定第一图像的中心点的基础上,只需在第二图像中确定出相应的目标点,即可基于视场角从第二图像中确定出与初始预览图像所呈现图像内容一致的区域,即目标区域。In another embodiment, the center point and field of view angle of the initial preview image may be determined first, and then the target point corresponding to the center point is determined in the second image, so as to start from the first preview image based on the determined target point and field of view angle. Determine the target area in the two images. It should be understood that the field of view determines how much content is included in the image. It can be seen that on the basis of determining the center point of the first image, only the corresponding target point is determined in the second image, and the image content consistent with the image presented in the initial preview image can be determined from the second image based on the field of view. area, that is, the target area.

在实际应用中,出现边缘模糊现象,意味着图像中心部分图像内容保持清晰,该情况仅在被摄对象为垂直于摄像头的光轴的平面对象时产生。试想,若被摄对象并非垂直于摄像头光轴的平面对象,假设以图像中心为对焦点,而中心附近的图像内容与中心点不在一个平面上,显然在非边缘区域就会出现模糊现象,而在边缘区域则可能存在与中心点处于同一平面的区域,反而是清晰的。可见,在本公开中,还需判断被摄对象是否为垂直于第一摄像头的光轴的平面对象。其中,仅在确定被摄对象为垂直于第一摄像头的光轴的平面对象的情况下,执行将当前使用摄像头由第一摄像头切换至第二摄像头的操作;否则,不执行切换操作。In practical applications, the edge blurring phenomenon means that the image content in the center of the image remains clear. This situation only occurs when the subject is a planar object perpendicular to the optical axis of the camera. Just imagine, if the subject is not a plane object perpendicular to the optical axis of the camera, assuming that the center of the image is the focus point, and the image content near the center is not on the same plane as the center point, it is obvious that blur will appear in the non-edge area, and In the edge area, there may be an area on the same plane as the center point, but it is clear. It can be seen that in the present disclosure, it is also necessary to determine whether the object is a plane object perpendicular to the optical axis of the first camera. Only when the object is determined to be a plane object perpendicular to the optical axis of the first camera, the operation of switching the currently used camera from the first camera to the second camera is performed; otherwise, the switching operation is not performed.

在理想状况下,当被摄对象与图像传感器上各个检测区域的距离均相等时,即可认为被摄对象为垂直于摄像头光轴的平面对象(为了方便表述,在后文中将“垂直于摄像头光轴的平面对象”简称为“平面对象”)。然而,在实际情况中,难免存在误差,难以做到完全相等,为此本公开预设一物距差,以用于判断被摄对象是否为平面对象。应当理解的是,由于图像传感器实际面积较小,通常与被摄对象的面积差较大,若直接检测图像传感器与被摄对象之间的实际距离,仅能够判断被摄对象中与图像传感器面积等大的区域是否为平面,而不能真正确定采集到的图像中包含的图像内容均处于同一平面中。为此,在本公开中,采用了相位对焦的方式,以确定图像传感器各个检测区域采集到的图像内容与相应实物之间的等价物距,并通过比较该等价物距的方式,判断被摄对象是否为平面对象。Under ideal conditions, when the distance between the subject and each detection area on the image sensor is equal, the subject can be considered to be a plane object perpendicular to the optical axis of the camera (for convenience of expression, in the following text, "perpendicular to the camera" will be used) Plane object with optical axis" is referred to as "planar object"). However, in actual situations, errors are inevitable and it is difficult to achieve complete equality. For this reason, the present disclosure presets an object distance difference to determine whether the subject is a planar object. It should be understood that since the actual area of the image sensor is small, the area difference between the image sensor and the subject is usually large. If the actual distance between the image sensor and the subject is directly detected, only the area between the subject and the image sensor can be determined. Whether equal-sized areas are planes, it cannot be truly determined that the image contents contained in the collected images are all in the same plane. To this end, in this disclosure, a phase focusing method is adopted to determine the equivalent object distance between the image content collected in each detection area of the image sensor and the corresponding object, and by comparing the equivalent object distance, it is determined whether the subject is photographed. is a flat object.

在实际操作中,可以优先在第一摄像头对应的图像传感器中确定出至少两个检测区域,并分别以确定出的至少两个检测区域为基准进行相位对焦,以得到各个检测区域的对焦数据;在此基础上,即可根据得到的对焦数据,计算各个检测区域分别对应的等价物距,并进一步确定出至少两个等价物距中的任意两者之间的物距差;若上述任意两者之间的物距差均小于预设的物距差,则可确定被摄对象为平面对象;否则,确定被摄对象不为平面对象。In actual operation, at least two detection areas can be determined first in the image sensor corresponding to the first camera, and phase focusing is performed based on the determined at least two detection areas respectively to obtain focus data of each detection area; On this basis, the equivalent object distance corresponding to each detection area can be calculated based on the obtained focus data, and the object distance difference between any two of at least two equivalent object distances can be further determined; if any of the above two If the object distance difference between the two objects is less than the preset object distance difference, it can be determined that the object being photographed is a plane object; otherwise, it is determined that the object being photographed is not a plane object.

需要声明的是,上述等价物距并非指的传统意义上的摄像头与被摄物体之间的距离,而是指图像传感器上某一检测区域采集到的图像内容与其实物之间的等价物距。换言之,该等价物距是通过计算得到的一个专用于确定被摄对象是否为平面对象的虚拟距离,而非实际距离。可以理解为:将图像传感器进行模拟放大至与被摄对象等大的面积后,测得的各个检测区域与被摄对象中相应位置的距离。It should be noted that the above equivalent object distance does not refer to the distance between the camera and the subject in the traditional sense, but refers to the equivalent object distance between the image content collected in a certain detection area on the image sensor and its object. In other words, the equivalent object distance is a calculated virtual distance specifically used to determine whether the subject is a planar object, rather than an actual distance. It can be understood as: after the image sensor is simulated and enlarged to an area as large as the subject, the measured distance between each detection area and the corresponding position in the subject is measured.

为了进一步提高判断被摄对象是否为平面对象的准确率。确定的至少两个检测区域可以包括:位于第一摄像头的图像传感器中心的第一区域,以及以该第一区域为基准对称设置的至少一对检测区域。例如,在正方形的图像传感器中,除了位于正方形中心的第一区域以外,还可以包括位于四角的4个等大的检测区域。当然,该举例仅是示意性的,检测区域的设置可以由本领域技术人员根据实际需求确定,本公开对此不作限制。In order to further improve the accuracy of determining whether the subject is a flat object. The determined at least two detection areas may include: a first area located at the center of the image sensor of the first camera, and at least a pair of detection areas symmetrically arranged with the first area as a reference. For example, in a square image sensor, in addition to the first area located at the center of the square, it may also include four equally large detection areas located at the four corners. Of course, this example is only illustrative, and the setting of the detection area can be determined by those skilled in the art according to actual needs, and the present disclosure does not limit this.

步骤108,将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。Step 108: Determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image.

在本公开中,从第二图像中确定出目标区域之后,即可将第二图像中属于目标区域的图像内容确定为当前预览图像,并将展示的初始预览图像切换为当前预览图像。In the present disclosure, after the target area is determined from the second image, the image content belonging to the target area in the second image can be determined as the current preview image, and the displayed initial preview image can be switched to the current preview image.

在切换过程中,由于当前预览图像与初始预览图像的图像内容一致,因此,不会出现相关技术中预览图像画面发生跳变的情况。同时,由于本公开在确定被摄对象与摄像头之间的物距小于预设距离时,将焦距较大的第一摄像头切换为了焦距较小的第二摄像头,显然能够提高画面的清晰度。可见,本公开在避免预览图像跳变的同时,提升了预览图像的清晰度。During the switching process, since the image content of the current preview image is consistent with that of the initial preview image, there will be no jump in the preview image screen in the related technology. At the same time, since the present disclosure switches the first camera with a larger focal length to a second camera with a smaller focal length when it is determined that the object distance between the subject and the camera is less than the preset distance, it can obviously improve the clarity of the picture. It can be seen that the present disclosure improves the clarity of the preview image while avoiding jumps in the preview image.

在相关技术中,当被摄对象与摄像头之间的距离低于某一阈值时,会将相机应用切换至微距模式。在该切换过程中,相机应用需要重启,且需要电子设备预先就装配有相应的微距摄像头,以便在相机模式切换为微距模式时将当前使用摄像头切换至微距摄像头。该过程较为复杂,且由于摄像头焦距变化导致预览图像也出现了跳变。In related technology, when the distance between the subject and the camera is lower than a certain threshold, the camera application is switched to macro mode. During this switching process, the camera application needs to be restarted, and the electronic device needs to be equipped with a corresponding macro camera in advance so that the currently used camera can be switched to the macro camera when the camera mode is switched to macro mode. The process is complicated, and the preview image also jumps due to changes in camera focus.

而在本公开的一种情况下,上述第一摄像头可以为广角摄像头,而第二摄像头可以为超广角摄像头。在该情况下,当被摄对象与第一摄像头之间的物距小于预设距离时,可以将广角摄像头切换至超广角摄像头。在该过程中包括上述确定目标对象的操作,以及预览图像之间的切换。应当理解的是,由于对图像进行了剪切,消除了传统超广角摄像头视场角大的优势,同时利用了超广角摄像头焦距较小的优势,实现了近距离拍摄。简而言之,本公开的技术方案可以利用超广角摄像头实现微距摄影,避免了相关技术中需要切换相机模式才能够进行微距摄影的限制,以及必须装配微距摄像头的限制。In one case of the present disclosure, the first camera may be a wide-angle camera, and the second camera may be an ultra-wide-angle camera. In this case, when the object distance between the subject and the first camera is less than the preset distance, the wide-angle camera can be switched to the ultra-wide-angle camera. This process includes the above-mentioned operation of determining the target object and switching between preview images. It should be understood that due to the cropping of the image, the advantage of the traditional ultra-wide-angle camera's large field of view is eliminated, and at the same time, the advantage of the ultra-wide-angle camera's smaller focal length is used to achieve close-range shooting. In short, the technical solution of the present disclosure can use an ultra-wide-angle camera to achieve macro photography, avoiding the limitations of the related technology of needing to switch camera modes to perform macro photography, and the limitation of having to install a macro camera.

当然,在确定被摄对象不为垂直于第一摄像头的光轴的平面对象的情况下,无法通过上述超广角摄像头实现微距摄影。在该情况下,本公开也可以如相关技术中,将电子设备的拍摄模式切换至微距模式,以通过微距摄像头进行图像采集。具体的,可以重启相机应用,以切换至微距模式,并将当前使用摄像头切换为微距摄像头。Of course, if it is determined that the subject is not a planar object perpendicular to the optical axis of the first camera, macro photography cannot be achieved through the above-mentioned ultra-wide-angle camera. In this case, the present disclosure may also switch the shooting mode of the electronic device to the macro mode to collect images through the macro camera as in the related art. Specifically, you can restart the camera application to switch to macro mode, and switch the currently used camera to the macro camera.

由上述技术方案可知,本公开在确定摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由焦距较大的摄像头切换为了焦距较小的摄像头。且在切换摄像头后,本公开并未直接将采集到的图像作为预览图像,而是从切换摄像头后采集到的图像中,确定出了与初始预览图像呈现的图像内容一致的目标区域,并将该目标区域中的图像内容确定为当前预览图像。It can be seen from the above technical solution that when the object distance between the camera and the subject is determined to be less than the preset distance, the present disclosure switches the currently used camera from a camera with a larger focal length to a camera with a smaller focal length. And after switching the camera, the present disclosure does not directly use the collected image as the preview image. Instead, from the image collected after switching the camera, the target area consistent with the image content presented in the initial preview image is determined, and The image content in the target area is determined to be the current preview image.

应当理解的是,由焦距较大的摄像头切换至焦距较小的摄像头,视场角变大,拍摄得到的图像中的图像内容增多,且由于被摄对象与电子设备之间的相对位置未发生变化,增加的图像内容通常显示于拍摄得到的图像的周围。因此,本公开仅将确定的目标区域确定为当前预览图像,相当于将周围的画面(或说边缘区域)进行了裁剪。可见,相较于相关技术,本公开不会显示切换摄像头后采集到的图片的边缘区域,进而避免了由焦距较大的摄像头切换至焦距较小的摄像头的情况下,预览图像边缘模糊的问题。It should be understood that when switching from a camera with a larger focal length to a camera with a smaller focal length, the field of view becomes larger, the image content in the captured image increases, and the relative position between the subject and the electronic device does not change. Variation, increased image content is usually displayed around the captured image. Therefore, the present disclosure only determines the determined target area as the current preview image, which is equivalent to cropping the surrounding picture (or edge area). It can be seen that compared with related technologies, the present disclosure does not display the edge area of the image collected after switching the camera, thereby avoiding the problem of blurring the edges of the preview image when switching from a camera with a larger focal length to a camera with a smaller focal length. .

除此之外,由于在上述过程中,是以摄像头切换前的初始预览图像为标准确定第二图像中的目标区域。可见,当前预览图像与初始预览图像的显示画面一致,避免了摄像头切换过程中预览画面的跳变。In addition, in the above process, the target area in the second image is determined based on the initial preview image before camera switching. It can be seen that the display screen of the current preview image is consistent with the initial preview image, which avoids the jump of the preview screen during the camera switching process.

需要声明的是,本公开检测物距是否小于预设距离,以及切换摄像头的操作均为电子设备自动执行。从用户视角看来,仅是电子设备中的预览画面变得清晰而已。该过程中并不存在画面跳变和边缘模糊的问题,提升了用户的拍摄体验。It should be stated that in this disclosure, the operations of detecting whether the object distance is smaller than the preset distance and switching cameras are automatically performed by electronic devices. From the user's perspective, only the preview screen in the electronic device becomes clear. There is no problem of picture jump and edge blur in this process, which improves the user's shooting experience.

下面,以装配有多个摄像头的智能手机为例介绍本公开的技术方案。Below, the technical solution of the present disclosure will be introduced by taking a smartphone equipped with multiple cameras as an example.

图2为本公开一示例性实施例示出的另一种预览图像切换方法,该方法应用于装配有多个摄像头的智能手机,如图2所示,该方法可以包括以下步骤:Figure 2 shows another preview image switching method according to an exemplary embodiment of the present disclosure. The method is applied to a smartphone equipped with multiple cameras. As shown in Figure 2, the method may include the following steps:

步骤201,通过广角摄像头采集第一图像。Step 201: Collect a first image through a wide-angle camera.

智能手机可以包括:主摄像头、广角摄像头、超广角摄像头等多个摄像头。本实施例以由广角摄像头切换至超广角摄像头为例进行介绍。Smartphones can include multiple cameras such as main camera, wide-angle camera, ultra-wide-angle camera, etc. This embodiment takes switching from a wide-angle camera to an ultra-wide-angle camera as an example.

智能手机可以在多个场景下,使用到广角摄像头。举例而言,在用户需要拍摄室内陈设时,为了使拍摄得到的图像中包含更多的物品,可以通过广角摄像头进行拍摄。Smartphones can use wide-angle cameras in multiple scenarios. For example, when the user needs to take pictures of indoor furnishings, in order to include more items in the captured images, the wide-angle camera can be used to take pictures.

步骤202,基于采集到的第一图像展示初始预览图像。Step 202: Display an initial preview image based on the collected first image.

承接上述举例,在用户使用广角摄像头拍摄室内陈设的过程中,可能突然想要拍摄某一处的陈设,进而靠近该陈设。此时,仍然可以通过广角摄像头以及与其搭配使用的图像传感器采集图像,并将采集到的图像作为本步骤中的第一图像。进一步的,即可基于该第一图像在智能手机的屏幕中展示初始预览图像。Following the above example, when the user is using the wide-angle camera to take pictures of indoor furnishings, he may suddenly want to take a picture of a certain furnishing and then get closer to the furnishing. At this time, images can still be collected through the wide-angle camera and the image sensor used with it, and the collected image can be used as the first image in this step. Further, an initial preview image can be displayed on the screen of the smartphone based on the first image.

步骤203,判断被摄对象与广角摄像头之间的距离是否小于预设距离;若是,则跳转至步骤204;否则,跳转至步骤211。Step 203: Determine whether the distance between the subject and the wide-angle camera is less than the preset distance; if so, jump to step 204; otherwise, jump to step 211.

在本实施例中,可以根据广角摄像头和超广角摄像头的焦距设置一预设距离,该预设距离小于根据广角摄像头的焦距以及成像公式计算得到的物距,该预设距离具体为何值可以由本领域技术人员根据实际需求确定。In this embodiment, a preset distance can be set based on the focal length of the wide-angle camera and the ultra-wide-angle camera. The preset distance is smaller than the object distance calculated based on the focal length of the wide-angle camera and the imaging formula. The specific value of the preset distance can be determined by this method. Field technicians determine based on actual needs.

承接上述举例,在用户靠近上述陈设的过程中,即可通过ToF测距方法检测被测对象与广角摄像头之间的物距,当检测到的物距小于预设距离时,即可进一步检测被摄对象是否为平面对象。Following the above example, when the user approaches the above furnishings, the ToF distance measurement method can be used to detect the object distance between the object being measured and the wide-angle camera. When the detected object distance is smaller than the preset distance, the object distance can be further detected. Whether the photographed object is a flat object.

需要声明的是,本实施例中的平面对象并非是绝对的平面。应当理解的是,对于任一物体而言,当靠近到一定程度时,该任一物体的各个部分与摄像头之间的距离差值较小,也可以将该任一物体确定为平面对象。It should be noted that the plane object in this embodiment is not an absolute plane. It should be understood that for any object, when it is close to a certain extent, the distance difference between each part of the object and the camera is small, and the object can also be determined as a planar object.

步骤204,判断被摄对象是否为平面对象;若是,则跳转至步骤205,否则,跳转至步骤211。Step 204: Determine whether the object is a planar object; if so, jump to step 205; otherwise, jump to step 211.

在本实施例中,可以优先在广角摄像头对应的图像传感器上确定5个检测区域,并分别确定这5个检测区域与相应实物之间的等价物距。并基于确定的5个等价物距中任意两者之间的距离差,以及预设的距离差判断被摄对象是否为平面对象。In this embodiment, five detection areas can be determined first on the image sensor corresponding to the wide-angle camera, and the equivalent object distances between these five detection areas and the corresponding physical objects can be determined respectively. And based on the distance difference between any two of the five determined equivalent object distances and the preset distance difference, it is judged whether the subject is a planar object.

举例而言,图像传感器上的检测区域可以如图3所示。假设图像传感器的形状为边长为1的正方形,那么可以在该图像传感器的中心取一边长为0.3的正方形检测区域,在图像传感器的四个角分别取一边长为0.2的正方形检测区域。并可以如图3所示将其标注为检测区域A和检测区域B1~B4。在此基础上,假设,测得的对应于检测区域A的等价物距为X1,测得的对应于检测区域B1~B4的等价物距为X2~X5。在本步骤中,可以分别计算其中任意两者之间的物距差,即分别计算X1-X2、X1-X3、X1-X4、X1-X5、X2-X3、X2-X4、X2-X5、X3-X4、X3-X5、X4-X5,在得到这些物距差后,可以分别比较这些物距差与预设物距差,当这些物距差均小于预设物距差时,即可确定被摄对象为平面对象。For example, the detection area on the image sensor can be as shown in Figure 3. Assuming that the shape of the image sensor is a square with a side length of 1, then a square detection area with a side length of 0.3 can be taken at the center of the image sensor, and a square detection area with a side length of 0.2 can be taken at the four corners of the image sensor. And it can be marked as detection area A and detection areas B1 to B4 as shown in Figure 3 . On this basis, it is assumed that the measured equivalent object distance corresponding to the detection area A is X1, and the measured equivalent object distance corresponding to the detection areas B1 to B4 is X2 to X5. In this step, the object distance difference between any two of them can be calculated separately, that is, calculate X1-X2, X1-X3, X1-X4, X1-X5, X2-X3, X2-X4, X2-X5, X3-X4, X3-X5, and Make sure the subject is a flat object.

步骤205,将广角摄像头切换至超广角摄像头。Step 205: Switch the wide-angle camera to the ultra-wide-angle camera.

步骤206,通过广角摄像头采集第二图像。Step 206: Collect the second image through the wide-angle camera.

步骤207,从初始预览图像中确定出多个参照物。Step 207: Determine multiple reference objects from the initial preview image.

步骤208,根据多个参照物从第二图像中确定出与初始预览图像呈现的图像内容一致的目标区域。Step 208: Determine a target area from the second image that is consistent with the image content presented in the initial preview image based on multiple reference objects.

在将广角摄像头切换至超广角摄像头后,摄像头的焦距变小,所搭配的图像传感器则变大,相应的,使得采集得到的第二图像的视场角也变大,图像内容也增多。若直接将第二图像作为预览图像,将很可能出现边缘区域模糊,以及预览图像跳变的现象。After switching from the wide-angle camera to the ultra-wide-angle camera, the focal length of the camera becomes smaller and the image sensor it is paired with becomes larger. Correspondingly, the field of view of the second image collected also becomes larger and the image content also increases. If the second image is directly used as the preview image, the edge area is likely to be blurred and the preview image will jump.

为此,本实施例优先从初始预览图像中确定出多个参照物,并将这多个参照物作为标准从第二图像中确定出与初始预览图像所呈现图像内容一致的目标区域,并将目标区域中包含的图像内容作为当前预览图像。To this end, this embodiment prioritizes determining multiple reference objects from the initial preview image, and uses these multiple reference objects as standards to determine the target area from the second image that is consistent with the image content presented in the initial preview image, and The image content contained in the target area serves as the current preview image.

在该过程中,第二图像与目标区域之间的关系可以如图4所示,该目标区域所包含的图像内容与初始预览图像所呈现的图像内容一致。In this process, the relationship between the second image and the target area can be as shown in FIG. 4 , and the image content contained in the target area is consistent with the image content presented in the initial preview image.

由图4可以明确知晓,第二图像中的边缘区域(阴影区域)将不会被作为当前预览图像进行展示,显然可以避免相关技术中图像边缘区域模糊的情况。It can be clearly known from Figure 4 that the edge area (shaded area) in the second image will not be displayed as the current preview image, which can obviously avoid the blurring of the image edge area in the related art.

步骤209,将确定的目标区域中包含的图像内容确定为当前预览图像。Step 209: Determine the image content contained in the determined target area as the current preview image.

步骤210,将初始预览图像切换为当前预览图像。Step 210: Switch the initial preview image to the current preview image.

步骤211,不执行摄像头切换的操作。Step 211: No camera switching operation is performed.

在本实施例中,若摄像头与被摄对象之间的距离并未小于预设距离,或者被摄对象并非平面对象,则不执行摄像头切换的操作。当然,在摄像头与被摄对象之间的距离小于预设距离,但被摄对象并非平面对象时,可以将智能手机切换至微距模式,以通过微距摄像头完成对非平面对象的微距摄影。In this embodiment, if the distance between the camera and the subject is not less than the preset distance, or the subject is not a plane object, the camera switching operation is not performed. Of course, when the distance between the camera and the subject is less than the preset distance, but the subject is not a flat object, you can switch the smartphone to macro mode to complete macro photography of non-planar objects through the macro camera. .

由上述技术方案可知,本公开中的第一摄像头可以为广角摄像头、而第二摄像头可以为超广角摄像头。当检测到广角摄像头与被摄对象之间的距离小于预设距离时,即可由广角摄像头切换至超广角摄像头。不难理解的是,本公开利用了超广角摄像头焦距较小的优势,实现了对近景的拍摄,相当于通过超广角摄像头实现了微距摄影。同时,基于初始预览图像从第二图像中确定出了目标区域,以作为当前预览图像,既避免了边缘区域模糊的现象,也防止了预览图像的跳变情况。It can be seen from the above technical solutions that the first camera in the present disclosure may be a wide-angle camera, and the second camera may be an ultra-wide-angle camera. When it is detected that the distance between the wide-angle camera and the subject is less than the preset distance, the wide-angle camera can be switched to the ultra-wide-angle camera. It is not difficult to understand that the present disclosure takes advantage of the smaller focal length of the ultra-wide-angle camera to achieve close-up shooting, which is equivalent to realizing macro photography through the ultra-wide-angle camera. At the same time, the target area is determined from the second image based on the initial preview image as the current preview image, which not only avoids the blurring of the edge area but also prevents the preview image from jumping.

图5是本公开一示例性实施例示出的一种预览图像切换装置的框图。参照图5,该装置包括生成单元501、第一切换单元502、确定单元503和第二切换单元504。FIG. 5 is a block diagram of a preview image switching device according to an exemplary embodiment of the present disclosure. Referring to FIG. 5 , the device includes a generating unit 501 , a first switching unit 502 , a determining unit 503 and a second switching unit 504 .

生成单元501,被装配为通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;The generation unit 501 is configured to collect a first image through a first camera and display an initial preview image generated based on the first image;

第一切换单元502,被装配为在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;The first switching unit 502 is configured to switch the currently used camera from the first camera to the second camera when it is determined that the object distance between the first camera and the subject is less than the preset distance; wherein, the first camera The focal length is greater than the focal length of the second camera, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera;

确定单元503,被装配为通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;The determination unit 503 is configured to collect a second image through a second camera, and determine a target area from the second image that is consistent with the image content presented by the initial preview image;

第二切换单元504,被装配为将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。The second switching unit 504 is configured to determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image.

可选的,确定单元503被进一步装配为:Optionally, the determination unit 503 is further assembled as:

在所述初始预览图像所呈现的图像内容中确定多个参照物;Determine multiple reference objects in the image content presented in the initial preview image;

根据所述多个参照物,从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域。According to the plurality of reference objects, a target area consistent with the image content presented in the initial preview image is determined from the second image.

可选的,确定单元503被进一步装配为:Optionally, the determination unit 503 is further assembled as:

确定所述初始预览图像的中心点和视场角;Determine the center point and field of view angle of the initial preview image;

在第二图像中确定出与所述中心点对应的目标点,并基于所述目标点和视场角从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域。A target point corresponding to the center point is determined in the second image, and a target area consistent with the image content presented in the initial preview image is determined from the second image based on the target point and the field of view angle.

如图6所示,图6是本公开一示例性实施例示出的另一种预览图像切换装置的框图,该实施例在前述图5所示实施例的基础上,还包括:判断单元505、执行单元506和第三切换单元507。As shown in Figure 6, Figure 6 is a block diagram of another preview image switching device according to an exemplary embodiment of the present disclosure. Based on the aforementioned embodiment shown in Figure 5, this embodiment also includes: a judgment unit 505, Execution unit 506 and third switching unit 507.

可选的,optional,

判断单元505,被装配为判断所述被摄对象是否为垂直于第一摄像头的光轴的平面对象;The judging unit 505 is equipped to judge whether the photographed object is a planar object perpendicular to the optical axis of the first camera;

执行单元506,被装配为在确定所述被摄对象为垂直于第一摄像头的光轴的平面对象的情况下,执行将当前使用摄像头由第一摄像头切换至第二摄像头的操作。The execution unit 506 is configured to perform an operation of switching the currently used camera from the first camera to the second camera when the subject is determined to be a planar object perpendicular to the optical axis of the first camera.

可选的,判断单元505被进一步装配为:Optionally, the judgment unit 505 is further configured as:

在第一摄像头的图像传感器中确定至少两个检测区域,并分别以所述至少两个检测区域为基准进行相位对焦,以得到各个检测区域的对焦数据;Determine at least two detection areas in the image sensor of the first camera, and perform phase focusing based on the at least two detection areas respectively to obtain focus data of each detection area;

根据得到的对焦数据,计算各个检测区域分别对应的等价物距,并确定出至少两个等价物距中的任意两者之间的物距差;Based on the obtained focus data, calculate the equivalent object distance corresponding to each detection area, and determine the object distance difference between any two of at least two equivalent object distances;

在确定所述任意两者之间的物距差均小于预设物距差的情况下,确定所述被摄对象为垂直于第一摄像头的光轴的平面对象;否则,所述被摄对象不为垂直于第一摄像头的光轴的平面对象。When it is determined that the object distance difference between any two objects is less than the preset object distance difference, it is determined that the photographed object is a plane object perpendicular to the optical axis of the first camera; otherwise, the photographed object Not a planar object perpendicular to the optical axis of the first camera.

可选的,所述至少两个检测区域包括:Optionally, the at least two detection areas include:

位于第一摄像头的图像传感器中心的第一区域,以及以第一区域为基准对称设置的至少一对检测区域。A first area located at the center of the image sensor of the first camera, and at least a pair of detection areas symmetrically arranged with the first area as a reference.

可选的,optional,

第三切换单元507,被装配为在确定被摄对象不为垂直于第一摄像头的光轴的平面对象的情况下,将所述电子设备的拍摄模式切换至微距模式,以通过微距摄像头进行图像采集。The third switching unit 507 is configured to switch the shooting mode of the electronic device to the macro mode to use the macro camera when it is determined that the subject is not a planar object perpendicular to the optical axis of the first camera. Perform image acquisition.

对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本公开方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。As for the device embodiment, since it basically corresponds to the method embodiment, please refer to the partial description of the method embodiment for relevant details. The device embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in One location, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. Persons of ordinary skill in the art can understand and implement the method without any creative effort.

相应的,本公开还提供一种预览图像切换装置,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为实现如上述实施例中任一所述的预览图像切换方法,比如该方法可以包括:通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。Correspondingly, the present disclosure also provides a preview image switching device, including: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to implement the method described in any one of the above embodiments. Preview image switching method, for example, the method may include: collecting a first image through a first camera and displaying an initial preview image generated based on the first image; determining that the object distance between the first camera and the subject is less than a preset distance In the case of , switch the currently used camera from the first camera to the second camera; wherein, the focal length of the first camera is greater than the focal length of the second camera, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera. ; Collect the second image through the second camera, and determine the target area consistent with the image content presented in the initial preview image from the second image; determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image.

相应的,本公开还提供一种电子设备,所述电子设备包括有存储器,以及一个或者一个以上的程序,其中一个或者一个以上程序存储于存储器中,且经配置以由一个或者一个以上处理器执行所述一个或者一个以上程序包含用于实现如上述实施例中任一所述的预览图像切换方法的指令,比如该方法可以包括:通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;Correspondingly, the present disclosure also provides an electronic device. The electronic device includes a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be processed by one or more processors. Executing the one or more programs includes instructions for implementing the preview image switching method as described in any of the above embodiments. For example, the method may include: collecting a first image through a first camera and displaying a preview image based on the first image. The initial preview image generated;

在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像。When it is determined that the object distance between the first camera and the subject is less than the preset distance, the currently used camera is switched from the first camera to the second camera; wherein the focal length of the first camera is greater than the focal length of the second camera, And the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera; the second image is collected through the second camera, and a target area consistent with the image content presented in the initial preview image is determined from the second image ; Determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image.

图7是根据一示例性实施例示出的一种用于实现预览图像切换的装置700的框图。例如,装置700可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。FIG. 7 is a block diagram of a device 700 for implementing preview image switching according to an exemplary embodiment. For example, the device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like.

参照图7,装置700可以包括以下一个或多个组件:处理组件702,存储器704,电源组件706,多媒体组件708,音频组件710,输入/输出(I/O)的接口712,传感器组件714,以及通信组件716。Referring to Figure 7, the device 700 may include one or more of the following components: a processing component 702, a memory 704, a power supply component 706, a multimedia component 708, an audio component 710, an input/output (I/O) interface 712, a sensor component 714, and communications component 716.

处理组件702通常控制装置700的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件702可以包括一个或多个处理器720来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件702可以包括一个或多个模块,便于处理组件702和其他组件之间的交互。例如,处理组件702可以包括多媒体模块,以方便多媒体组件708和处理组件702之间的交互。Processing component 702 generally controls the overall operations of device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above method. Additionally, processing component 702 may include one or more modules that facilitate interaction between processing component 702 and other components. For example, processing component 702 may include a multimedia module to facilitate interaction between multimedia component 708 and processing component 702.

存储器704被配置为存储各种类型的数据以支持在装置700的操作。这些数据的示例包括用于在装置700上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器704可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。Memory 704 is configured to store various types of data to support operations at device 700 . Examples of such data include instructions for any application or method operating on device 700, contact data, phonebook data, messages, pictures, videos, etc. Memory 704 may be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EEPROM), Programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.

电源组件706为装置700的各种组件提供电力。电源组件706可以包括电源管理系统,一个或多个电源,及其他与为装置700生成、管理和分配电力相关联的组件。Power supply component 706 provides power to the various components of device 700 . Power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to device 700 .

多媒体组件708包括在所述装置700和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件708包括一个前置摄像头和/或后置摄像头。当装置700处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。Multimedia component 708 includes a screen that provides an output interface between the device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide action. In some embodiments, multimedia component 708 includes a front-facing camera and/or a rear-facing camera. When the device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front-facing camera and rear-facing camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.

音频组件710被配置为输出和/或输入音频信号。例如,音频组件710包括一个麦克风(MIC),当装置700处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器704或经由通信组件716发送。在一些实施例中,音频组件710还包括一个扬声器,用于输出音频信号。Audio component 710 is configured to output and/or input audio signals. For example, audio component 710 includes a microphone (MIC) configured to receive external audio signals when device 700 is in operating modes, such as call mode, recording mode, and speech recognition mode. The received audio signal may be further stored in memory 704 or sent via communication component 716 . In some embodiments, audio component 710 also includes a speaker for outputting audio signals.

I/O接口712为处理组件702和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/O interface 712 provides an interface between the processing component 702 and a peripheral interface module, which may be a keyboard, a click wheel, a button, etc. These buttons may include, but are not limited to: Home button, Volume buttons, Start button, and Lock button.

传感器组件714包括一个或多个传感器,用于为装置700提供各个方面的状态评估。例如,传感器组件714可以检测到装置700的打开/关闭状态,组件的相对定位,例如所述组件为装置700的显示器和小键盘,传感器组件714还可以检测装置700或装置700一个组件的位置改变,用户与装置700接触的存在或不存在,装置700方位或加速/减速和装置700的温度变化。传感器组件714可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件714还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件714还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。Sensor component 714 includes one or more sensors that provide various aspects of status assessment for device 700 . For example, sensor component 714 can detect the open/closed state of device 700, the relative positioning of components, such as the display and keypad of device 700, and sensor component 714 can also detect a change in position of device 700 or a component of device 700. , the presence or absence of user contact with device 700 , device 700 orientation or acceleration/deceleration and temperature changes of device 700 . Sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

通信组件716被配置为便于装置700和其他设备之间有线或无线方式的通信。装置700可以接入基于通信标准的无线网络,如WiFi,2G或3G,4G LTE、7G NR(New Radio)或它们的组合。在一个示例性实施例中,通信组件716经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件716还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。Communication component 716 is configured to facilitate wired or wireless communication between apparatus 700 and other devices. The device 700 can access a wireless network based on communication standards, such as WiFi, 2G or 3G, 4G LTE, 7G NR (New Radio) or a combination thereof. In one exemplary embodiment, communication component 716 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communications component 716 also includes a near field communications (NFC) module to facilitate short-range communications. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

在示例性实施例中,装置700可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。In an exemplary embodiment, apparatus 700 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable Gate array (FPGA), controller, microcontroller, microprocessor or other electronic components are implemented for executing the above method.

在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器704,上述指令可由装置700的处理器720执行以完成上述方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as a memory 704 including instructions, which are executable by the processor 720 of the device 700 to complete the above method is also provided. For example, the non-transitory computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.

本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the disclosure will be readily apparent to those skilled in the art from consideration of the specification and practice of the disclosure herein. The present disclosure is intended to cover any variations, uses, or adaptations of the disclosure that follow the general principles of the disclosure and include common common sense or customary technical means in the technical field that are not disclosed in the disclosure. . It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It is to be understood that the present disclosure is not limited to the precise structures described above and illustrated in the accompanying drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the disclosure is limited only by the appended claims.

以上所述仅为本公开的较佳实施例而已,并不用以限制本公开,凡在本公开的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本公开保护的范围之内。The above are only preferred embodiments of the present disclosure and are not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included in this disclosure. within the scope of protection.

Claims (8)

1.一种预览图像切换方法,其特征在于,应用于电子设备,包括:1. A preview image switching method, characterized in that it is applied to electronic devices, including: 通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;Collect the first image through the first camera, and display the initial preview image generated based on the first image; 在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;When it is determined that the object distance between the first camera and the subject is less than the preset distance, the currently used camera is switched from the first camera to the second camera; wherein the focal length of the first camera is greater than the focal length of the second camera, And the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera; 通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;Collect a second image through a second camera, and determine a target area from the second image that is consistent with the image content presented in the initial preview image; 将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像;Determine the image content belonging to the target area in the second image as the current preview image, and switch the displayed initial preview image to the current preview image; 其中,所述从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域,包括:在所述初始预览图像所呈现的图像内容中确定多个参照物;根据所述多个参照物,从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;或者,Wherein, determining a target area from the second image that is consistent with the image content presented in the initial preview image includes: determining a plurality of reference objects in the image content presented in the initial preview image; A reference object is used to determine a target area consistent with the image content presented in the initial preview image from the second image; or, 所述从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域,包括:确定所述初始预览图像的中心点和视场角;在第二图像中确定出与所述中心点对应的目标点,并基于所述目标点和视场角从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域。Determining a target area consistent with the image content presented in the initial preview image from the second image includes: determining the center point and field of view angle of the initial preview image; determining in the second image the target area that is consistent with the image content presented in the initial preview image. A target point corresponding to the center point, and based on the target point and the field of view angle, a target area consistent with the image content presented in the initial preview image is determined from the second image. 2.根据权利要求1所述的方法,其特征在于,还包括:2. The method of claim 1, further comprising: 判断所述被摄对象是否为垂直于第一摄像头的光轴的平面对象;Determine whether the photographed object is a plane object perpendicular to the optical axis of the first camera; 在确定所述被摄对象为垂直于第一摄像头的光轴的平面对象的情况下,执行将当前使用摄像头由第一摄像头切换至第二摄像头的操作。When it is determined that the photographed object is a planar object perpendicular to the optical axis of the first camera, an operation of switching the currently used camera from the first camera to the second camera is performed. 3.根据权利要求2所述的方法,其特征在于,所述判断所述被摄对象是否为垂直于第一摄像头的光轴的平面对象,包括:3. The method of claim 2, wherein determining whether the photographed object is a plane object perpendicular to the optical axis of the first camera includes: 在第一摄像头的图像传感器中确定至少两个检测区域,并分别以所述至少两个检测区域为基准进行相位对焦,以得到各个检测区域的对焦数据;Determine at least two detection areas in the image sensor of the first camera, and perform phase focusing based on the at least two detection areas respectively to obtain focus data for each detection area; 根据得到的对焦数据,计算各个检测区域分别对应的等价物距,并确定出至少两个等价物距中的任意两者之间的物距差;Based on the obtained focus data, calculate the equivalent object distance corresponding to each detection area, and determine the object distance difference between any two of at least two equivalent object distances; 在确定所述任意两者之间的物距差均小于预设物距差的情况下,确定所述被摄对象为垂直于第一摄像头的光轴的平面对象;否则,所述被摄对象不为垂直于第一摄像头的光轴的平面对象。When it is determined that the object distance difference between any two objects is less than the preset object distance difference, it is determined that the photographed object is a plane object perpendicular to the optical axis of the first camera; otherwise, the photographed object Not a planar object perpendicular to the optical axis of the first camera. 4.根据权利要求3所述的方法,其特征在于,所述至少两个检测区域包括:4. The method according to claim 3, characterized in that the at least two detection areas include: 位于第一摄像头的图像传感器中心的第一区域,以及以第一区域为基准对称设置的至少一对检测区域。A first area located at the center of the image sensor of the first camera, and at least a pair of detection areas symmetrically arranged with the first area as a reference. 5.根据权利要求3所述的方法,其特征在于,还包括:5. The method of claim 3, further comprising: 在确定被摄对象不为垂直于第一摄像头的光轴的平面对象的情况下,将所述电子设备的拍摄模式切换至微距模式,以通过微距摄像头进行图像采集。If it is determined that the object being photographed is not a plane object perpendicular to the optical axis of the first camera, the shooting mode of the electronic device is switched to a macro mode to collect images through the macro camera. 6.一种预览图像切换装置,其特征在于,应用于电子设备,包括:6. A preview image switching device, characterized in that it is applied to electronic equipment and includes: 生成单元,通过第一摄像头采集第一图像,并展示基于第一图像生成的初始预览图像;A generating unit that collects the first image through the first camera and displays an initial preview image generated based on the first image; 第一切换单元,在确定第一摄像头与被摄对象之间的物距小于预设距离的情况下,将当前使用摄像头由第一摄像头切换至第二摄像头;其中,第一摄像头的焦距大于第二摄像头的焦距,且第一摄像头的图像传感器的尺寸小于第二摄像头的图像传感器的尺寸;The first switching unit switches the currently used camera from the first camera to the second camera when it is determined that the object distance between the first camera and the subject is less than the preset distance; wherein the focal length of the first camera is greater than the second camera. The focal length of the two cameras, and the size of the image sensor of the first camera is smaller than the size of the image sensor of the second camera; 确定单元,通过第二摄像头采集第二图像,并从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;A determining unit that collects a second image through a second camera and determines a target area from the second image that is consistent with the image content presented in the initial preview image; 第二切换单元,将第二图像中属于所述目标区域的图像内容确定为当前预览图像,并将展示的所述初始预览图像切换为所述当前预览图像;A second switching unit determines the image content belonging to the target area in the second image as the current preview image, and switches the displayed initial preview image to the current preview image; 其中,所述从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域,包括:在所述初始预览图像所呈现的图像内容中确定多个参照物;根据所述多个参照物,从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域;或者,Wherein, determining a target area from the second image that is consistent with the image content presented in the initial preview image includes: determining a plurality of reference objects in the image content presented in the initial preview image; A reference object is used to determine a target area consistent with the image content presented in the initial preview image from the second image; or, 所述从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域,包括:确定所述初始预览图像的中心点和视场角;在第二图像中确定出与所述中心点对应的目标点,并基于所述目标点和视场角从第二图像中确定出与所述初始预览图像呈现的图像内容一致的目标区域。Determining a target area consistent with the image content presented in the initial preview image from the second image includes: determining the center point and field of view angle of the initial preview image; determining in the second image the target area that is consistent with the image content presented in the initial preview image. A target point corresponding to the center point, and based on the target point and the field of view angle, a target area consistent with the image content presented in the initial preview image is determined from the second image. 7.一种电子设备,其特征在于,包括:7. An electronic device, characterized in that it includes: 处理器;processor; 用于存储处理器可执行指令的存储器;Memory used to store instructions executable by the processor; 其中,所述处理器通过运行所述可执行指令以实现如权利要求1-5中任一项所述的方法。Wherein, the processor implements the method according to any one of claims 1-5 by running the executable instructions. 8.一种计算机可读存储介质,其上存储有计算机指令,其特征在于,该指令被处理器执行时实现如权利要求1-5中任一项所述方法的步骤。8. A computer-readable storage medium having computer instructions stored thereon, characterized in that when the instructions are executed by a processor, the steps of the method according to any one of claims 1-5 are implemented.
CN202011176686.1A 2020-10-28 2020-10-28 Preview image switching method and device, electronic equipment and storage medium Active CN114422687B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011176686.1A CN114422687B (en) 2020-10-28 2020-10-28 Preview image switching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011176686.1A CN114422687B (en) 2020-10-28 2020-10-28 Preview image switching method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114422687A CN114422687A (en) 2022-04-29
CN114422687B true CN114422687B (en) 2024-01-19

Family

ID=81260639

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011176686.1A Active CN114422687B (en) 2020-10-28 2020-10-28 Preview image switching method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114422687B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114125399B (en) * 2021-12-16 2024-10-15 成都西物信安智能系统有限公司 Quick anti-theft modularized monitoring device
CN115802158B (en) * 2022-10-24 2023-09-01 荣耀终端有限公司 Method for switching cameras and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107277371A (en) * 2017-07-27 2017-10-20 青岛海信移动通信技术股份有限公司 A kind of method and device in mobile terminal amplification picture region
CN110505389A (en) * 2019-09-03 2019-11-26 RealMe重庆移动通信有限公司 Camera control method, device, storage medium and electronic device
CN110602409A (en) * 2019-10-23 2019-12-20 Oppo广东移动通信有限公司 Photographing method and device, electronic equipment and storage medium
CN110691193A (en) * 2019-09-03 2020-01-14 RealMe重庆移动通信有限公司 Camera switching method and device, storage medium and electronic equipment
CN111541845A (en) * 2020-04-30 2020-08-14 维沃移动通信(杭州)有限公司 Image processing method and device and electronic equipment
CN111654629A (en) * 2020-06-11 2020-09-11 展讯通信(上海)有限公司 Camera switching method and device, electronic equipment and readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107277371A (en) * 2017-07-27 2017-10-20 青岛海信移动通信技术股份有限公司 A kind of method and device in mobile terminal amplification picture region
CN110505389A (en) * 2019-09-03 2019-11-26 RealMe重庆移动通信有限公司 Camera control method, device, storage medium and electronic device
CN110691193A (en) * 2019-09-03 2020-01-14 RealMe重庆移动通信有限公司 Camera switching method and device, storage medium and electronic equipment
CN110602409A (en) * 2019-10-23 2019-12-20 Oppo广东移动通信有限公司 Photographing method and device, electronic equipment and storage medium
CN111541845A (en) * 2020-04-30 2020-08-14 维沃移动通信(杭州)有限公司 Image processing method and device and electronic equipment
CN111654629A (en) * 2020-06-11 2020-09-11 展讯通信(上海)有限公司 Camera switching method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN114422687A (en) 2022-04-29

Similar Documents

Publication Publication Date Title
US11108953B2 (en) Panoramic photo shooting method and apparatus
EP3640732B1 (en) Method and terminal for acquire panoramic image
CN106254682A (en) A kind of photographic method and mobile terminal
WO2016101481A1 (en) Automatic focusing method and device
WO2017124899A1 (en) Information processing method, apparatus and electronic device
WO2022161340A1 (en) Image display method and apparatus, and electronic device
CN106657951A (en) Projection control method, device, mobile device and projector
CN115033121A (en) Anti-mistouch method, device, equipment and storage medium
KR20170029404A (en) Method and apparatus for controlling video image and terminal
US11555696B2 (en) Electronic terminal, photographing method and device, and storage medium
CN114422687B (en) Preview image switching method and device, electronic equipment and storage medium
CN114339022B (en) Method for determining camera shooting parameters and training method for neural network model
CN108629814B (en) Camera adjusting method and device
CN111835941A (en) Image generation method and apparatus, electronic device, computer-readable storage medium
CN111343386A (en) Image signal processing method and device, electronic device and storage medium
CN107918514B (en) Display method and apparatus, electronic device, computer-readable storage medium
CN114666490B (en) Focusing methods, devices, electronic equipment and storage media
CN114339019B (en) Focusing method, focusing device and storage medium
CN117522942A (en) Depth distance measurement method, device, electronic equipment and readable storage medium
KR102081659B1 (en) Method and apparatus for taking images for applying visual effect
CN109803085A (en) Control the method and device of camera camera shooting
CN108933858A (en) Image shows method and device, electronic equipment, computer readable storage medium
CN115134517A (en) Shooting control method and device and storage medium
CN106483740A (en) projector focusing method and device
CN106131403B (en) Touch focusing method and device

Legal Events

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