Method and mobile terminal for taking high-definition photos based on OpenGL simulating depth of field effect
By processing and fusion of camera preview data during the photo callback period, the problem of the existing technology being unable to take large-size high-definition photos is solved, achieving an efficient depth of field effect and a smooth preview experience.
Patent Information
- Application Number
- CN202211599192.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-12
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-12-12
AI Technical Summary
The existing photography solution based on OpenGL technology that simulates depth of field effects cannot take large-size high-definition photos. Due to high hardware requirements, previews may be lagging and unsmooth, which seriously affects the user experience.
After capturing the camera preview data during the photo callback period, it is magnified to the corresponding size with the photo texture data, and then simulated depth of field fusion through OpenGL to obtain the final high-definition large-size photo.
It realizes that without affecting the camera's original real-time preview fluency, it makes full use of the photo callback time period to process blurred textures and obtains high-definition large-size photos that simulate the depth of field.
Smart Images

Figure CN115996314B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image processing technology, and in particular to a method and a mobile terminal for shooting high-definition photos based on OpenGL simulating depth of field effect. Background Art
[0002] As mobile phone performance continues to improve, mobile phone camera technology is getting better and better. Users do not need to buy professional cameras to take satisfactory photos. Now many users like to take selfies with their mobile phones, making mobile phones more entertaining in addition to communication functions.
[0003] At present, most mobile terminals such as mobile phones and tablets are equipped with front and rear cameras, allowing mobile terminal users to easily take photos or selfies. However, a realistic problem is that most existing mid-to-low-end mobile phones or tablets usually do not have telephoto lenses on their rear cameras due to cost issues, and there are even fewer front cameras equipped with telephoto lenses.
[0004] Therefore, when taking photos, such mid- and low-end mobile devices cannot achieve the depth of field blur shooting effect of a telephoto lens through their own lens performance, resulting in a large gap in user experience between their own photo taking experience and that of mobile devices with a telephoto lens.
[0005] In order to solve this problem, the prior art has proposed "A method for achieving depth of field effect based on OpenGL" (patent publication number CN102750726B) to achieve depth of field by combining the Mipmap principle based on OpenGL with Poisson distribution, calculating image scene information at different levels, thereby improving the efficiency and effect of achieving depth of field.
[0006] However, the defect of such prior art is that the existing photographing solutions based on OpenGL technology to simulate the depth of field effect all use the preview data of the camera to perform Gaussian blur, and then merge it with the original preview data to obtain the final photo. Since the resolution size of the camera preview data is usually 720x1280 or 1080x1920, if the preview size is increased, for example, to 1440x2560, higher requirements are required for the hardware device, otherwise the preview will be obviously stuck and not smooth, which will seriously affect the user experience.
[0007] Therefore, based on such problems, existing photographing solutions based on OpenGL technology to simulate depth of field effects are still unable to take large-size high-definition photos. Summary of the invention
[0008] To this end, the main purpose of the present invention is to provide a method and a mobile terminal for shooting high-definition photos based on OpenGL simulated depth of field effect, so as to solve the problem mentioned in the background technology that large-size high-definition depth of field simulated photos cannot be shot.
[0009] In order to achieve the above object, according to one aspect of the present invention, a method for taking high-definition photos based on OpenGL simulating depth of field effect is provided, and the steps include:
[0010] Step S100: When it is detected that a photographing event is triggered, within the photographing callback period, the camera preview data is captured as the preview texture data A1 to be blurred;
[0011] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0012] In step S300, after the blurred preview texture data B is enlarged to a size corresponding to the photographed texture data D, the preview texture data B is fused with the photographed texture data D through OpenGL to simulate the depth of field and obtain the final photo.
[0013] In a possible preferred implementation, the simulated depth of field fusion step in step S300 includes: calculating the gradual blur coefficient S based on the distance from the pixel point to the center of the focus area, and mixing the photographed texture data D and the blurred preview texture data B according to the formula F=B*(1-S) + D*S, so that the focus area displays the area corresponding to the photographed texture data D, the gradient area displays the corresponding area of the photographed texture data D after gradual blurring, and the peripheral area displays the corresponding area of the blurred preview texture data B.
[0014] In a possible preferred implementation, step S300 further includes: adding a time watermark to the blurred preview texture data B after the magnification processing.
[0015] In order to achieve the above purpose and allow the depth of field effect of the photo to be previewed before the photo event is triggered, according to a second aspect of the present invention, a method for taking high-definition photos based on OpenGL simulating depth of field effect is provided, the steps of which include:
[0016] Step S100: capturing camera preview data as preview texture data A1 to be blurred and original preview texture data A;
[0017] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0018] Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C;
[0019] Step S400: When it is detected that a photographing event is triggered, within the photographing callback period, the blurred preview texture data B is called back, and after it is enlarged to a size corresponding to the photographing texture data D, it is merged with the photographing texture data D through OpenGL simulated depth of field to obtain the final photo.
[0020] In a possible preferred implementation, the simulated depth of field fusion step in step S400 includes: calculating the gradual blur coefficient S based on the distance from the pixel point to the center of the focus area, and mixing the photographed texture data D and the blurred preview texture data B according to the formula F=B*(1-S) + D*S, so that the focus area displays the area corresponding to the photographed texture data D, the gradient area displays the corresponding area of the photographed texture data D after gradual blurring, and the peripheral area displays the corresponding area of the blurred preview texture data B.
[0021] In a possible preferred implementation, step S400 further includes: adding a time watermark to the blurred preview texture data B after the magnification processing.
[0022] In order to achieve the above purpose and allow the depth of field effect of the photo to be previewed before the photo event is triggered, according to a third aspect of the present invention, a method for taking high-definition photos based on OpenGL simulating depth of field effect is provided, the steps of which include:
[0023] Step S100: capturing camera preview data as preview texture data A1 to be blurred and original preview texture data A;
[0024] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0025] Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C;
[0026] Step S400: When it is detected that a photo event is triggered, within the photo callback period, the preview depth of field texture data C is called back, and after it is enlarged to a size corresponding to the photo texture data D, the pixels in the focus area of the photo texture data D are replaced with the pixels in the focus area of the preview depth of field texture data C to merge them into the final photo.
[0027] In a possible preferred implementation, step S400 further includes: adding a time watermark to the preview depth of field texture data C after the magnification processing.
[0028] In order to achieve the above purpose and make full use of the photo callback time to process the preview data, according to a fourth aspect of the present invention, a method for taking high-definition photos based on OpenGL simulating depth of field effect is also provided, the steps of which include:
[0029] Step S100: When it is detected that a photographing event is triggered, within the photographing callback period, the camera preview data is captured as the preview texture data A1 to be blurred and the original preview texture data A;
[0030] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0031] Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C;
[0032] In step S400, after the preview depth of field texture data C is enlarged to a size corresponding to the photographed texture data D, the pixels in the focus area of the photographed texture data D are replaced with the pixels in the focus area of the preview depth of field texture data C to merge them into a final photo.
[0033] In a possible preferred implementation, step S400 further includes: adding a time watermark to the preview depth of field texture data C after the magnification processing.
[0034] In order to achieve the above-mentioned purpose, according to the fifth aspect of the present invention, there is further provided a mobile terminal, which includes: a storage unit, a processing unit, and a camera unit, wherein the storage unit is used to store a program including the method steps for taking high-definition photos based on OpenGL simulating depth of field effect as described above, so that the processing unit and the camera unit can call up and execute it in time to obtain the final photo.
[0035] The method and mobile terminal for taking high-definition photos based on OpenGL simulating depth of field effect provided by the present invention have the following advantages compared with the prior art:
[0036] 1. Maintain smooth preview: Do not affect the smoothness of the original real-time preview of the camera.
[0037] 2. Quick filming: Make full use of the time gap between the photo callback and process the blurred texture, which uses the previewed real-time texture data.
[0038] 3. High-definition output: The high-definition photo texture data after the photo callback is merged with the blurred preview texture data, so as to make full use of the maximum photo size supported by the camera and obtain high-definition large-size photos with simulated depth of field. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0040] Figure 1 A schematic diagram of the method steps of the first embodiment of the present invention;
[0041] Figure 2 A schematic diagram of the timeline of steps before optimization of the method of the present invention;
[0042] Figure 3 A schematic diagram of the timeline of the steps after optimization of the method of the present invention;
[0043] Figure 4 A schematic diagram of the method steps of the second embodiment of the present invention;
[0044] Figure 5 A schematic diagram of the method steps of the third embodiment of the present invention;
[0045] Figure 6 Schematic diagram of method steps of the fourth embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to enable those skilled in the art to better understand the technical solution of the present invention, the specific technical solution of the present invention will be clearly and completely described in conjunction with the embodiments below to help those skilled in the art further understand the present invention. Obviously, the embodiments described in this case are only embodiments of a part of the present invention, not all of the embodiments. It should be pointed out that for those of ordinary skill in the art, the embodiments in this application and the features in the embodiments can be combined with each other without departing from the concept of the present invention and without conflicting with each other. Based on the embodiments in the present invention, all other embodiments obtained without creative work by those of ordinary skill in the art should belong to the disclosure and protection scope of the present invention.
[0047] In addition, the terms "first", "second", "S1", "S2", etc. in the specification, claims and drawings of the present invention are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those described herein. At the same time, the terms "including" and "having" and any variations thereof in the present invention are intended to cover non-exclusive inclusions. Unless otherwise clearly specified and limited, the terms "set", "layout", "install", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in this case can be understood based on the specific circumstances and in combination with the prior art.
[0048] See also Figures 1 to 3 As shown, the method for taking high-definition photos based on OpenGL simulating depth of field effect provided by the present invention comprises the following steps:
[0049] Step S100: When a photo event is detected to be triggered, the camera preview data is captured as preview texture data A1 to be blurred during the photo callback period, wherein the length, width, focus coordinates, foreground depth of field radius, back depth of field radius and gradual blur coefficient of the preview data texture can be preset. The gradual blur area and focus area can be calculated by the above parameters.
[0050] Step S200: Perform Gaussian blur processing on the preview texture data A1 to be blurred, and obtain the preview texture data B.
[0051] In step S300, after the blurred preview texture data B is enlarged to a size corresponding to the photographed texture data D, the preview texture data B is fused with the photographed texture data D through OpenGL to simulate the depth of field and obtain the final photo.
[0052] The simulated depth of field fusion step includes: calculating the gradual blur coefficient S according to the distance from the pixel point to the center of the focus area, and mixing the photographed texture data D and the blurred preview texture data B according to the formula F=B*(1-S) + D*S, so that the focus area displays the area corresponding to the photographed texture data D, the gradient area displays the corresponding area after the photographed texture data D is gradually blurred, and the peripheral area displays the corresponding area of the blurred preview texture data B.
[0053] Furthermore, in order to make full use of the photo callback time period, step S300 further includes: adding a time watermark to the blurred preview texture data B after the magnification process. Thus, the high-definition photo after fusion can have a time watermark without increasing the overall processing time.
[0054] Specifically, the camera data stream is divided into preview stream and photo stream. The preview stream data is relatively small, usually less than two million pixels. Due to the small amount of data, special effects such as depth of field and beauty can be applied without any lag. The photo stream data is very large, basically more than 10 million pixels, and large-size high-definition photos can be obtained.
[0055] However, although the method of using OpenGL to realize the depth of field effect is a prior art, the photos taken by the prior art are all small-sized. Because preview data is usually used, the preview size is small and generally does not exceed two million pixels.
[0056] Therefore, in order to obtain large-size, high-definition simulated depth-of-field photos, the main idea of the present invention is to consider the selection and use of data, so as to reduce the photo synthesis time and obtain high-definition photos. For this reason, the present invention is designed to use the preview data after real-time Gaussian blur during the photo callback time period, enlarge it to the photo size, and merge it with the photo callback data to finally obtain a large-size photo with depth of field, thereby saving photo processing time.
[0057] See also Figure 4 As shown, in order to allow the depth of field effect of a photo to be previewed before a photo event is triggered, the present invention also provides a method for taking high-definition photos based on OpenGL simulating depth of field effect, the steps of which include:
[0058] Step S100: capturing camera preview data as preview texture data A1 to be blurred and original preview texture data A;
[0059] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0060] Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C;
[0061] Step S400: When it is detected that a photographing event is triggered, within the photographing callback period, the blurred preview texture data B is called back, and after it is enlarged to a size corresponding to the photographing texture data D, it is merged with the photographing texture data D through OpenGL simulated depth of field to obtain the final photo.
[0062] The simulated depth of field fusion step includes: calculating the gradual blur coefficient S according to the distance from the pixel point to the center of the focus area, and mixing the photographed texture data D and the blurred preview texture data B according to the formula F=B*(1-S) + D*S, so that the focus area displays the area corresponding to the photographed texture data D, the gradient area displays the corresponding area after the photographed texture data D is gradually blurred, and the peripheral area displays the corresponding area of the blurred preview texture data B.
[0063] Furthermore, in order to make full use of the photo callback time period, step S400 further includes: adding a time watermark to the blurred preview texture data B after the magnification process. Thus, the high-definition photo after fusion can have a time watermark without increasing the overall processing time.
[0064] Specifically, the process of obtaining large-size high-definition photos in this example is divided into two stages:
[0065] 1. Implement Opengl depth of field preview and obtain preview data after real-time Gaussian blur
[0066] First, preset the length, width, focus coordinates, foreground depth of field radius, background depth of field radius and gradient blur coefficient of the preview texture data. The gradient blur area and focus area can be calculated using the above parameters.
[0067] Secondly, when the simulated depth of field event is detected to be triggered, the camera preview frame is captured as the preview texture data A1 to be blurred and the original preview texture data A. At this time, the GPU is called to use the blur coefficient to perform Gaussian blur processing calculation on the preview texture data A1 to be blurred to obtain the blurred preview texture data B.
[0068] After that, the pixels in the focus area of the original preview texture data A are used to replace the pixels in the focus area of the blurred texture data, and the gradient blur coefficient S is calculated based on the distance from the pixel point to the center of the focus area. The GPU is called to perform gradient Gaussian blur processing on the pixels in the gradient blur area of the original preview texture data A. The blurred preview texture data B obtained in the above steps and the original preview texture data A are used to obtain the gradient blurred pixels according to the formula F=B*(1-S) + A*S to replace the pixels in the gradient blur area of the blurred texture data. At this point, the preview simulated depth of field picture can be viewed.
[0069] The following example illustrates the preview data, Gaussian processing, and data amplification process:
[0070] The depth of field preview uses GlSurfaceView.
[0071] The GlSurfaceView preview steps include:
[0072] (1) Add GlSurfaceView in xml
[0073] (2) Create a renderer class to implement GlSurfaceView.Renderer
[0074] (3) Clear the canvas, create a texture and bind it to the Opengl context. All subsequent operations are for this texture (for example, blurring). This texture is the preview texture.
[0075] (4) Create a SurfaceTexture for final display to display the processed data.
[0076] (5) Create an OpenGL ES program and add a shader to the program, create an executable file for the OpenGL program, and release the shader resources.
[0077] (6) Open the camera and configure related properties, such as preview size: parameter.setPreviewSize(width, height) to set the preview size, which is usually no more than 5M, and photo size: parameters.setPictureSize(width, height) to set the photo size. The following example sets it to 25M. Set the preview view and start the preview.
[0078] (7) Add the program to the ES environment and set and enable various handles. For example:
[0079] Vertex coordinate handle:
[0080] 1. Get the vertex coordinate handle
[0081] maPositionLoc = GLES20.glGetAttribLocation(mProgramHandle, "aPosition");
[0082] 2. Enable vertex coordinate handles
[0083] GLES20.glEnableVertexAttribArray(maPositionLoc);
[0084] 3. Set the vertex coordinate handle
[0085] GLES20.glVertexAttribPointer(maPositionLoc, Drawable2d.COORDS_PER_VERTEX,GLES20.GL_FLOAT, false, Drawable2d.VERTEXTURE_STRIDE,mDrawable2d.getVertexArray());
[0086] The purpose is to pass vertex coordinates to the shader.
[0087] Texture coordinate handle:
[0088] 1. Get the texture coordinate handle
[0089] maTextureCoordLoc = GLES20.glGetAttribLocation(mProgramHandle, "aTextureCoord");
[0090] 2. Enable texture coordinate handles
[0091] GLES20.glEnableVertexAttribArray(maTextureCoordLoc);
[0092] 3. Set the texture coordinate handle
[0093] GLES20.glVertexAttribPointer(maTextureCoordLoc, 2,GLES20.GL_FLOAT,false, Drawable2d.TEXTURE_COORD_STRIDE, mDrawable2d.getTexCoorArrayFB()); is used to pass texture coordinates to the shader.
[0094] (8) In onDrawFrame, the canvas is cleaned and the latest data is drawn into the texture graphics. For example, onDrawFrame() is called when drawing the current frame data. The Gaussian processing and data enlargement process are performed in this method. The OpenGL image processing open source library includes some filter implementations. The corresponding Gaussian blur filter is the GPUImageGaussianBlurFilter function. The corresponding texture scaling is the glviewport function.
[0095] (9) Set a SurfaceTexture.OnFrameAvailableListener callback to notify GlSurfaceview to render new frame data.
[0096] 2. Obtain the photo data and fuse it with the preview data after enlargement and Gaussian blur.
[0097] First, the length, width, focus coordinates, foreground depth of field radius, back depth of field radius and gradual blur coefficient of the photographed texture data D are preset. The gradual blur area and focus area can be calculated by the above parameters.
[0098] When it is detected that a photo event is triggered, part of the program in the first stage can be executed again within the photo callback time period to obtain the blurred preview texture data B, or the adjacent blurred preview texture data B in the first stage can be directly called back; and the blurred preview texture data B can be enlarged to the length and width of the photo texture data through opengl.
[0099] The process example of obtaining the photo callback data includes:
[0100] (1) Create a Builder object for a photo request through createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).
[0101] (2) The result of taking a photo is obtained in the OnImageAvailableListener object. First, an Image object is obtained through the CacquireNextImage() method, and then the byteBuffer is obtained through image.planes[0].buffer, and the byteBuffer is converted into a byteArray. This byteArray is the image data obtained by taking a photo.
[0102] Then, the gradient blur coefficient S is calculated based on the distance from the pixel point to the center of the focus area. According to the formula F=B*(1-S) +D*S, the photographed texture data D and the blurred preview texture data B are mixed, so that the focus area displays the area corresponding to the photographed texture data D, the gradient area displays the corresponding area of the photographed texture data D after gradual blurring, and the peripheral area displays the corresponding area of the blurred preview texture data B, so as to be fused into the final photo.
[0103] like Figure 3 As shown in FIG. 1 , the idle time of the photo callback is about 800 ms. The method of the present invention makes full use of this idle time period, making the total photo processing time shorter than that of the Figure 2 The solution reduces 50+70+4 = 124ms.
[0104] In addition, in other possible embodiments, step S400 may further include: adding a time watermark to the blurred preview texture data B after the magnification process, so that the high-definition photo after fusion can have a time watermark without increasing the overall processing time.
[0105] In another possible implementation, Figure 5 As shown, the first stage can be called back or executed again to obtain the preview depth of field texture data C, and after it is enlarged to a size corresponding to the photographed texture data D, the pixels in the focus area of the photographed texture data D are directly replaced with the pixels in the focus area of the preview depth of field texture data C to merge them into a final photo, thereby obtaining a high-definition photo with a simulated scenery effect.
[0106] In response to the solution of directly replacing the pixel, in a preferred embodiment, step S400 further includes: adding a time watermark to the preview depth of field texture data C after the enlargement process. Thus, the high-definition photo after fusion can have a time watermark without increasing the overall processing time.
[0107] See also Figure 6 As shown, in order to make full use of the photo callback time and process the preview data, the present invention also provides a method for taking high-definition photos based on OpenGL simulating depth of field effect, the steps of which include:
[0108] Step S100: When it is detected that a photographing event is triggered, within the photographing callback period, the camera preview data is captured as the preview texture data A1 to be blurred and the original preview texture data A;
[0109] Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B;
[0110] Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C;
[0111] In step S400, after the preview depth of field texture data C is enlarged to a size corresponding to the photographed texture data D, the pixels in the focus area of the photographed texture data D are replaced with the pixels in the focus area of the preview depth of field texture data C to merge them into a final photo.
[0112] In a possible preferred implementation, step S400 further includes: adding a time watermark to the preview depth of field texture data C after the magnification processing.
[0113] Corresponding to the methods of the above embodiments, the present invention also provides a mobile terminal, which includes: a storage unit, a processing unit, and a camera unit, wherein the storage unit is used to store a program including the method steps for taking high-definition photos based on OpenGL simulating depth of field effects as described above, so that the processing unit and the camera unit can call up and execute it in time to obtain the final photo.
[0114] To sum up, the method and mobile terminal for shooting high-definition photos based on OpenGL simulating depth of field effect provided by the present invention can make full use of the time gap of the photo callback to process the blurred texture without affecting the smoothness of the original real-time preview of the camera. The blurred texture uses the previewed real-time texture data, and the high-definition photo texture data after the photo callback is merged with the blurred preview texture data. In this way, the maximum photo size supported by the camera can be fully utilized to obtain high-definition large-size photos with simulated depth of field.
[0115] The preferred embodiments of the present invention disclosed above are only used to help explain the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is only limited by the claims and their full scope and equivalents. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
[0116] Those skilled in the art can understand that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be regarded as structures within the hardware component; the modules for implementing various functions can also be regarded as both software programs for implementing the method and structures within the hardware component.
[0117] In addition, all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a single-chip microcomputer, a chip or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program codes.
[0118] In addition, various implementation modes of the embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the embodiments of the present invention, they should also be regarded as the contents disclosed by the embodiments of the present invention.
Claims
1. A method for taking high-definition photos based on OpenGL simulating depth of field effect, characterized by the steps of include: Step S100: When it is detected that a photographing event is triggered, within the photographing callback period, the camera preview data is captured as the preview texture data A1 to be blurred; Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B; In step S300, after the blurred preview texture data B is enlarged to a size corresponding to the photographed texture data D, the preview texture data B is fused with the photographed texture data D through OpenGL to simulate the depth of field and obtain the final photo.
2. The method for taking high-definition photos based on OpenGL simulating depth of field effect according to claim 1, characterized in that The simulated depth of field fusion step in step S300 includes: The gradient blur coefficient S is calculated based on the distance from the pixel point to the center of the focus area. According to the formula F=B*(1-S) + D*S, the photographed texture data D and the blurred preview texture data B are mixed to display the area corresponding to the photographed texture data D in the focus area, the gradient area displays the corresponding area of the photographed texture data D after gradual blurring, and the peripheral area displays the corresponding area of the blurred preview texture data B.
3. The method for taking high-definition photos based on OpenGL simulating depth of field effect according to claim 1, characterized in that: Step S300 also includes: adding a time watermark to the blurred preview texture data B after the magnification processing.
4. A method for taking high-definition photos based on OpenGL simulating depth of field effect, characterized by the steps of include: Step S100: capturing camera preview data as preview texture data A1 to be blurred and original preview texture data A; Step S200: Gaussian blur processing is performed on the preview texture data A1 to be blurred to obtain the preview texture data B; Step S300: The blurred preview texture data B and the original preview texture data A are fused by simulating depth of field through OpenGL to obtain preview depth of field texture data C; Step S400: When it is detected that a photographing event is triggered, within the photographing callback period, the blurred preview texture data B is called back, and after it is enlarged to a size corresponding to the photographing texture data D, it is merged with the photographing texture data D through OpenGL simulated depth of field to obtain the final photo.
5. The method for taking high-definition photos based on OpenGL simulating depth of field effect according to claim 4, characterized in that The simulated depth of field fusion step in step S400 includes: The gradient blur coefficient S is calculated based on the distance from the pixel point to the center of the focus area. According to the formula F=B*(1-S) + D*S, the photographed texture data D and the blurred preview texture data B are mixed to display the area corresponding to the photographed texture data D in the focus area, the gradient area displays the corresponding area of the photographed texture data D after gradual blurring, and the peripheral area displays the corresponding area of the blurred preview texture data B.
6. The method for taking high-definition photos based on OpenGL simulating depth of field effect according to claim 4, characterized in that: Step S400 also includes: adding a time watermark to the blurred preview texture data B after the magnification processing.
7. A mobile terminal, comprising: A storage unit, a processing unit, and a camera unit, wherein the storage unit is used to store a program including the method steps for taking high-definition photos based on OpenGL simulating depth of field effects as described in any one of claims 1 to 6, so that the processing unit and the camera unit can call up and execute the program in a timely manner to obtain the final photo.
Citation Information
Patent Citations
A method of realizing depth of field effect based on opengl
CN102750726B
Photographing method for simulating depth-of-field effect and mobile terminal thereof
CN113766135A
Image processing method and device, electronic equipment and computer readable storage medium
CN113781358A