Image processing method and device, computer device and storage medium
By utilizing the cropping position information of the target image during image processing for precise cropping, the problems of missing target objects and low efficiency in existing technologies are solved, achieving efficient cropping and display effects.
Patent Information
- Application Number
- CN202110627369.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-04
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-06-04
AI Technical Summary
Existing technologies often result in incomplete cropping of the target object and low efficiency when cropping images, leading to poor cropping results and an inability to effectively convey key information from the image.
By selecting the target image through the album entry, the cropping position information in the target image's attribute information is used to accurately crop the image and generate a cropped image that matches the target image area.
It improves the efficiency of cropped image generation and display, and avoids latency issues caused by missing target objects and manual selection or real-time detection.
Smart Images

Figure CN113822899B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to an image processing method and device, computer equipment and a storage medium. BACKGROUND
[0002] With the development of computer technology, as an information carrier, the information that images can carry is becoming more and more rich, and the information displayed through images is intuitive and easy to understand, so that it becomes more and more popular to convey information through images, and thus in various scenes, information can be transmitted and emotions can be expressed by displaying images. For example, users can share pictures of daily life through social applications, users can also set the avatars of social accounts by using images, and can also verify identities by using certificate images, etc.
[0003] Since the original size of the generated picture is different, in order to highlight the target object in the picture when displaying the picture, the picture needs to be cropped before being displayed.
[0004] However, when cropping a picture, the center area of the picture is usually cropped, some are manually selected by the user, and some need to detect the target object in the picture in real time, which all have the problems of poor cropping effect and slow cropping efficiency due to the missing of the target object, so that the cropped image cannot effectively convey the key information in the picture. SUMMARY
[0005] Therefore, it is necessary to provide an image processing method, device, computer equipment and storage medium capable of improving the cropping effect and efficiency of the target object in the picture.
[0006] An image processing method, the method comprising:
[0007] displaying a photo album entry, and in response to a triggering operation on the photo album entry, displaying at least one candidate picture;
[0008] in response to a picture selection operation, selecting a target picture from the displayed candidate pictures; the attribute information of the target picture includes cropping position information, and the cropping position information marks an image region including a target object in the target picture;
[0009] displaying a cropped image cropped from the target picture; the cropped image matches the image region including the target object.
[0010] An image processing device, the device comprising:
[0011] a display module configured to display a photo album entry, and in response to a triggering operation on the photo album entry, display at least one candidate picture;
[0012] a picture selection module, configured to select a target picture from the displayed candidate pictures in response to a picture selection operation; attribute information of the target picture comprises cropping position information, the cropping position information marking an image region including a target object in the target picture;
[0013] the display module is further configured to display a cropped image cropped from the target picture; the cropped image matches the image region including the target object.
[0014] In one embodiment, the display module is further configured to display an image display interface, the image display interface comprising the album entry.
[0015] In response to a triggering operation on the album entry, enter a picture browsing interface.
[0016] In the picture browsing interface, display at least one candidate picture.
[0017] In the above embodiment, the display module is further configured to, in response to a picture selection operation in the picture browsing interface, select a target picture from the displayed candidate pictures, and return from the picture browsing interface to the image display interface after the selection; display a cropped image cropped from the target picture in a preview region of the image display interface.
[0018] In one embodiment, the display module is further configured to display, in a preview region of an image display interface, a cropped image cropped from the target picture and adapted to the size of the preview region.
[0019] In the above embodiment, the image processing apparatus further comprises a preview region adaptation module, configured to crop an image region including a target object from the target picture according to the cropping position information; when the size of the preview region is smaller than the size of the image region, redraw the image region in the preview region according to the size of the preview region to obtain the cropped image; when the size of the preview region is larger than the size of the image region, perform scaling processing on the image region according to a scaling ratio determined according to the size of the preview region and the size of the image region to obtain the cropped image.
[0020] In the above embodiment, the image processing apparatus further comprises:
[0021] a direction correction module, configured to read attribute information of the target picture; when the attribute information comprises the cropping position information, crop the target picture to obtain a corrected image, and then crop an image region from the corrected image according to the cropping position information.
[0022] The preview area adaptation module is further configured to, when the attribute information does not include the cropping position information, directly crop the target picture according to the size of the preview area to obtain the cropped image.
[0023] In one embodiment, the picture acquisition portal comprises a camera portal, and the image processing apparatus further comprises a picture acquisition module.
[0024] The display module is further configured to, in response to a triggering operation on the camera portal, display a real-time shooting picture, and display a prompt mark of a target object in the real-time shooting picture.
[0025] The picture acquisition module is configured to, in response to a picture acquisition operation, acquire a target picture comprising the target object.
[0026] The display module is further configured to display a cropped image cropped from the target picture, and the cropped image matches an image region comprising the target object in the target picture indicated by the prompt mark of the target object.
[0027] In the above embodiment, the display module is further configured to display an image display interface, the image display interface comprising a camera portal, and in response to a triggering operation on the camera portal, enter a picture acquisition interface, and display a real-time shooting picture in the picture acquisition interface.
[0028] In the above embodiment, the picture acquisition module is configured to, in response to a picture acquisition operation in the picture acquisition interface, acquire a target picture comprising the target object, and return to the image display interface from the picture acquisition interface.
[0029] The display module is further configured to display a cropped image cropped from the target picture in a preview area of the image display interface.
[0030] In one embodiment, the image processing apparatus further comprises a position optimization module configured to determine a camera type when acquiring a target picture comprising the target object, and perform fault-tolerant optimization processing on a target object position indicated by the prompt mark when the target picture is acquired according to a preset size corresponding to the camera type to obtain cropping position information.
[0031] In the previous embodiment, the position optimization module is further configured to: when the camera type is a front camera, take a target object region marked by the prompt mark when the target picture is captured as a center region, expand the center region according to a first preset size, and then obtain the cropping position information according to a first region obtained by the expansion; when the camera type is a rear camera, take the target object region marked by the prompt mark when the target picture is captured as a center region, expand the center region according to a second preset size, and then obtain the cropping position information according to a second region obtained by the expansion; and the first preset size is greater than the second preset size.
[0032] In one embodiment, the image processing apparatus further includes a picture storage module configured to: determine, based on the prompt mark of the target object, cropping position information of the target picture; write the cropping position information into attribute information of the target picture; and store the target picture carrying the cropping position information.
[0033] In one embodiment, the display module is further configured to display a content sharing interface of a social application.
[0034] In a content editing region of the content sharing interface, a thumbnail picture cropped from the target picture and adapted to the size of the content editing region is displayed.
[0035] In the previous embodiment, the display module is further configured to: when a viewing operation on the thumbnail picture is triggered, display the target picture corresponding to the thumbnail picture; and when a sharing operation on the content to be shared in the content editing region is triggered, share the target picture corresponding to the thumbnail picture in the manner in which the thumbnail picture is displayed in the content sharing interface.
[0036] In one embodiment, the target picture is a certificate picture, and the display module is further configured to display a certificate image uploading interface; and in a preview region of the certificate image uploading interface, a cropped picture cropped from the certificate picture and adapted to the size of the preview region is displayed.
[0037] In one embodiment, the display module is further configured to display a head portrait setting interface; and in a preview region of the head portrait setting interface, a cropped picture cropped from the target picture and adapted to the size of the preview region is displayed.
[0038] A computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0039] A photo album entry is displayed, and at least one candidate picture is displayed in response to a triggering operation on the photo album entry.
[0040] In response to a picture selection operation, a target picture is selected from the displayed candidate pictures; attribute information of the target picture includes cropping position information, the cropping position information marking an image region including a target object in the target picture;
[0041] A cropped image cropped from the target picture is displayed; the cropped image matches the image region including the target object.
[0042] A computer readable storage medium having stored thereon a computer program, the computer program being executed by a processor to implement the following steps:
[0043] A photo album entry is displayed, and in response to a triggering operation on the photo album entry, at least one candidate picture is displayed;
[0044] In response to a picture selection operation, a target picture is selected from the displayed candidate pictures; attribute information of the target picture includes cropping position information, the cropping position information marking an image region including a target object in the target picture;
[0045] A cropped image cropped from the target picture is displayed; the cropped image matches the image region including the target object.
[0046] A computer program, the computer program comprising computer instructions stored in a computer readable storage medium, a processor of a computer device reading the computer instructions from the computer readable storage medium, the processor executing the computer instructions to cause the computer device to perform the steps of the image processing method.
[0047] The image processing method, device, computer device, and storage medium display a photo album entry, and in response to a triggering operation on the photo album entry, at least one candidate picture is displayed. When a picture selection operation is triggered, a target picture is selected from the candidate pictures. Attribute information of the selected target picture includes accurate cropping position information, which marks an image region including a target object in the target picture. Thus, after the target picture is selected, the target picture can be directly cropped according to the accurate cropping position information. After a cropped image matching the image region marked by the cropping position information is obtained, the cropped image is directly displayed. On the one hand, compared with directly cropping a central region from the target picture, the cropping position information can accurately locate the image region where the target object is located in the target picture, avoiding missing of the target object in the cropped image. On the other hand, compared with manually selecting a cropping region or locating a cropping region after real-time detection, only the cropping position information in the attribute information of the target picture is needed to perform cropping, avoiding time delay caused by manual selection of a cropping region or real-time detection each time the target picture is displayed, and improving generation efficiency and display effect of the cropped image. BRIEF DESCRIPTION OF DRAWINGS
[0048] Figure 1 An application environment diagram of the image processing method in one embodiment;
[0049] Figure 2 A flowchart of the image processing method in one embodiment;
[0050] Figure 3 A schematic diagram of a target picture in one embodiment;
[0051] Figure 4 A flowchart of displaying a candidate picture in one embodiment;
[0052] Figure 5 An interface diagram of an image display interface in one embodiment;
[0053] Figure 6 A flowchart of the image processing method in another embodiment;
[0054] Figure 7 An interface diagram of a content sharing interface in one embodiment;
[0055] Figure 8 An interface diagram of a certificate image uploading interface in one embodiment;
[0056] Figure 9 A flowchart of the image processing method in another embodiment;
[0057] Figure 10 An interface diagram of an image display interface in yet another embodiment;
[0058] Figure 11 A flowchart of the image processing method in still another embodiment;
[0059] Figure 12 A flowchart of the image processing method in one specific embodiment;
[0060] Figure 13 A structural block diagram of an image processing apparatus in one embodiment;
[0061] Figure 14 A structural block diagram of an image processing apparatus in another embodiment;
[0062] Figure 15 An internal structure diagram of a computer device in one embodiment. DETAILED DESCRIPTION
[0063] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not to limit the present application.
[0064] The image processing method provided by the present application realizes image display including a target object by using computer vision technology in artificial intelligence (AI).
[0065] Computer vision (CV) Computer vision is a science that studies how to make machines "see". More specifically, it refers to using cameras and computers to replace human eyes to identify, track and measure targets, and further process graphics so that computer processing becomes images more suitable for human observation or transmission to instruments for detection. As a scientific discipline, computer vision researches related theories and technologies, and attempts to establish artificial intelligence systems that can obtain information from images or multidimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and other technologies. It also includes common face recognition, fingerprint recognition and other biometric identification technologies. It can be understood that when collecting a target picture, the present application detects the target object in the target picture, which belongs to the use of image recognition technology in computer vision technology.
[0066] Machine learning (ML) Machine learning is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. This subject is dedicated to studying how computers can simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structure to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental approach to making computers intelligent. It is applied in various fields of artificial intelligence. Artificial neural networks are an important machine learning technology with wide application prospects in system identification, pattern recognition, intelligent control and other fields.
[0067] It can be understood that the present application can train and use an image recognition model by using machine learning technology to detect the position of the target object in the target picture, so that the cropping position information of the target picture can be determined according to the position, and when the picture needs to be displayed, the cropped image can be obtained directly using the cropping position information and the cropped image can be displayed. In some embodiments, the target picture and the cropping position information of the target picture can be stored in the data block of the blockchain to ensure the security of the picture data.
[0068] The image processing method provided in the present application can be applied to the application environment as shown in Figure 1 The terminal 102 communicates with the server 104 through a network. The terminal 102 can display a photo album entry, display at least one candidate picture in response to a triggering operation on the photo album entry, select a target picture from the displayed candidate pictures in response to a picture selection operation, the attribute information of the target picture includes cropping position information, the cropping position information marks an image region of the target picture that includes a target object, and then display a cropped image cropped from the target picture, the cropped image matches the image region in the target picture marked by the cropping position information.
[0069] In one embodiment, the picture acquisition entry includes a camera entry. The terminal 102 can display a real-time shooting picture in response to a triggering operation on the camera entry, display a prompt mark of a target object in the real-time shooting picture, collect a target picture including the target object in response to a picture collection operation, and then display a cropped image cropped from the target picture, the cropped image matches the image region in the target picture marked by the cropping position information determined by the prompt mark of the target object. The terminal 102 can also write the cropping position information into the attribute information of the collected original target picture. The terminal can also upload the original picture with the written cropping position information to the server 104 for cloud storage.
[0070] The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.
[0071] In one embodiment, as shown in Figure 2 An image processing method is provided. The method is applied to the terminal 102 in Figure 1 for example, and includes the following steps:
[0072] Step 202, display a picture acquisition entry, the picture acquisition entry includes a photo album entry, display at least one candidate picture in response to a triggering operation on the photo album entry.
[0073] The picture acquisition portal is an entrance for acquiring and exporting pictures, and includes a photo album portal and a camera portal. The photo album portal is an entrance provided by a user interface for selecting pictures. The photo album portal can be in the form of a touch control and arranged at any position in the user interface. The triggering operation on the photo album portal can be any one of a click operation, a sliding operation or a double-click operation. The candidate pictures are a set of pictures for user selection, and the number of the candidate pictures can be one or more than two. The candidate pictures can be pictures stored locally on the terminal or pictures existing on a cloud server.
[0074] Specifically, the terminal can display the photo album portal in the user interface, and display at least one candidate picture in response to the triggering operation on the photo album portal. In some embodiments, the user interface where the photo album portal is located and the user interface where the candidate pictures are located can be the same interface or different interfaces.
[0075] Step 204: In response to the picture selection operation, a target picture is selected from the displayed candidate pictures; the attribute information of the target picture includes cropping position information, and the cropping position information marks an image region including the target object in the target picture.
[0076] The picture selection operation is an operation of selecting one or more target pictures from the displayed at least one candidate picture. The picture selection operation can be any one of a click operation, a sliding operation or a double-click operation on the candidate picture. The picture selection operation can be a confirmation operation after selecting multiple candidate pictures. The terminal selects the pictures selected from the candidate pictures as the target pictures to be displayed in response to the picture selection operation.
[0077] The attribute information of the target picture is information for recording the attributes of the target picture. In some embodiments, the attributes of the target picture can be divided into picture attributes and shooting attributes, the picture attributes include at least one of image direction, image resolution, resolution unit, image shooting time, last editing time and image color gamut space, and the shooting attributes include at least one of camera model, exposure time, aperture value, shooting mode, camera type, light sensitivity, lens focal length and image size. The cropping position information can be divided into picture attributes or shooting attributes. Of course, the attribute information of the target picture can not be divided into picture attributes and shooting attributes. The attribute information of the target picture can be, for example, EXIF (Exchangeable image file format) information.
[0078] Cropping location information specifies the position of a region within the target image, including the target object. This region can include the width and height of the area to be cropped, as well as the pixel coordinates (posX, posY) of the top-left corner. Alternatively, it can include the pixel coordinates of the top-right corner or the center of the region. This cropping location information can be written into the target image's attribute information during image acquisition.
[0079] A target object in a target image is an object within the image that prominently represents the intended message of the target image. For example, a target object can be a human face, everyday items such as a water cup, car, clothing, food, or bag, or natural scenery such as trees, flowers, blue sky, or white clouds. In some embodiments, target objects in a target image can be prioritized. For instance, when a target image includes a human face, the target object is considered a face; when a target image does not include a human face, the target object is considered a prominent object. Alternatively, when a target image includes a human face, the target object is determined to be a face; when a target image does not include a face, the target object is determined to be absent. The terminal can detect target objects in the target image during image acquisition.
[0080] The image region marked in the target image by the cropping position information is an image region that includes the target object. In some embodiments, the target object may be located at the center of this image region. In some embodiments, in order to fully display the target object and improve its display effect, the range of this image region is larger than the area where the target object is located; that is, the image region may also include other content in the target image as background content to highlight the target object.
[0081] like Figure 3 The image shown is a schematic diagram of a target image in one embodiment. (Refer to...) Figure 3 The target image 30 includes a target object 302, which is a human face. The attribute information of the target image 30 includes cropping position information, which marks the image region 304 in the target image 30, which includes the target object 302.
[0082] Specifically, the terminal can respond to the image selection operation on the candidate images and use the selected candidate image as the target image.
[0083] Step 206: Display the cropped image extracted from the target image; this cropped image matches the image region that includes the target object.
[0084] The cropped image is an image cropped from the target picture, and the cropped image matches the image region including the target object in the target picture marked by the cropping position information.
[0085] In one embodiment, the cropped image can be an image region in the target picture marked by the cropping position information. Specifically, after selecting the target picture, the terminal can read the attribute information of the target picture, obtain the cropping position information, and then directly locate the image region in the target picture according to the cropping position information in the attribute information of the target picture, and then crop the image region from the target picture as the cropped image to be displayed.
[0086] In one embodiment, the cropped image can be an image obtained by scaling the image region in the target picture marked by the cropping position information. Specifically, after selecting the target picture, the terminal can read the attribute information of the target picture, obtain the cropping position information, and then directly locate the image region in the target picture according to the cropping position information in the attribute information of the target picture, and then crop the image region from the target picture, and obtain the image by scaling the image region as the cropped image to be displayed.
[0087] The image processing method described above displays a photo album entry, in response to a triggering operation on the photo album entry, displays at least one candidate picture, selects a target picture from the candidate pictures when a picture selection operation is triggered, and the attribute information of the selected target picture includes accurate cropping position information marking an image region including a target object in the target picture. In this way, after selecting the target picture, the target picture can be directly cropped according to the accurate cropping position information, and a cropped image matching the image region marked by the cropping position information is obtained, and the cropped image is directly displayed. On the one hand, compared with directly cropping the central region from the target picture, the cropping position information can accurately locate the image region where the target object is located in the target picture, avoiding missing the target object part in the cropped image. On the other hand, compared with manually selecting a cropping region or locating a cropping region after real-time detection, only the cropping position information in the attribute information of the target picture is needed for cropping, avoiding the time delay problem caused by manually selecting a cropping region or real-time detection each time of display, improving the generation efficiency and display effect of the cropped image.
[0088] In one embodiment, as shown in FIG. 2, step 202 includes: Figure 4
[0089] Step 402, display an image display interface, and the image display interface includes a photo album entry.
[0090] The image display interface is a user interactive interface for displaying the cropped image. The album entry is provided in the image display interface. When the user needs to display a target picture in the image display interface, the target picture can be selected through the album entry, and the cropped image obtained by cropping the target picture can be displayed in the image display interface.
[0091] At step 404, in response to the triggering operation on the album entry, the picture browsing interface is entered.
[0092] The triggering operation on the album entry can be any one of a click operation, a sliding operation, or a double-click operation. The picture browsing interface is a user interactive interface for displaying candidate pictures for browsing by the user. The picture browsing interface can be a local album browsing interface or a cloud picture browsing interface. The picture browsing interface can be displayed in the form of a pop-up window above the image display interface or can be switched from the image display interface to the picture browsing interface.
[0093] Specifically, when the operation on the album entry is triggered, the picture browsing interface is entered from the displayed image display interface.
[0094] At step 406, at least one candidate picture is displayed in the picture browsing interface.
[0095] In this embodiment, when the target picture needs to be displayed in the image display interface, the picture browsing interface is entered through the provided album entry, and the user selects one or more target pictures from the picture browsing interface.
[0096] In one embodiment, step 204 includes returning to the image display interface from the picture browsing interface after the target picture is selected from the displayed candidate pictures in response to the picture selection operation in the picture browsing interface; and step 206 includes displaying the cropped image cropped from the target picture in the preview area of the image display interface.
[0097] The preview area of the image display interface is an area for previewing the target picture. The preview area is provided in the image display interface in addition to the album entry. Since the cropped image matches the image area including the target object in the target picture, the cropped image displayed in the preview area can directly highlight the target object in the target picture, perfectly conveying the key content of the target picture, thereby realizing accurate and effective preview of the target picture. Moreover, the cropped image is cropped according to the cropping position information in the attribute information of the target picture, avoiding the time delay caused by manual selection of the cropping area or real-time detection each time the target picture is displayed, and improving the generation efficiency and display effect of the cropped image.
[0098] In some embodiments, a cropped image, extracted from the target image, is displayed in the preview area of the image display interface. After viewing the key content of the target image through the cropped image displayed in the preview area, the user can choose to further process the target image. For example, in some scenarios, if the user feels the target image is not perfect, they can re-enter the image browsing interface through the album entry to select a new target image. In other scenarios, if the user thinks the target image is perfect, they can share the target image with other users.
[0099] like Figure 5 The image shown is a schematic diagram of an image display interface in one embodiment. (Refer to...) Figure 5 In the image display interface 502, an album entry 504 and a preview area 506 are set. Users can enter the image browsing interface 508 by triggering the operation of the album entry 504. In the image browsing interface 508, multiple candidate images 510 are displayed. Users can return to the image display interface 502 by triggering the operation of the candidate images 510. In the preview area 506 of the image display interface 502, a cropped image 512 is displayed, which is cropped from the target image according to the cropping position information in the target image's attribute information.
[0100] In this embodiment, by setting a preview area in the image display interface and displaying a cropped image including the target object from the target image in the preview area, a precise and effective preview of the target image can be achieved.
[0101] In one embodiment, step 206 includes: displaying a cropped image, which is cropped from the target image and adapted to the size of the preview area, in the preview area of the image display interface.
[0102] The preview area of the image display interface is used to preview the target image. The preview area is usually fixed within the image display interface, and its size is also fixed. When the terminal displays a cropped image through the preview area, the displayed cropped image is adapted to the size of the preview area.
[0103] In one embodiment, the above method further includes:
[0104] Cropping region containing the target object is cropped from the target image based on the cropping location information;
[0105] When the size of the preview area is smaller than the size of the image area, the image area is redrawn in the preview area according to the size of the preview area to obtain the cropped image.
[0106] In one embodiment, when the size of the preview area is larger than the size of the image area, the image area is scaled according to a scaling ratio determined according to the size of the preview area and the size of the image area, to obtain the cropped image.
[0107] Specifically, the terminal selects the target picture according to the user's operation, reads the cropping position information in the attribute information of the target picture, and crops the image area including the target object from the target picture according to the cropping position information. In order to improve the display effect, the terminal can also perform size adaptation processing on the image area before finally displaying it in the preview area.
[0108] The terminal can obtain the size of the preview area and determine the size of the image area according to the cropping position information. When the size of the image area is relatively large compared to the size of the preview area, the terminal can redraw the image area according to the size of the preview area to obtain the cropped image and display it in the preview area. When the size of the image area is relatively small compared to the size of the preview area, in order to avoid distortion of the image area due to stretching, the terminal performs equal scaling processing on the image area to obtain the cropped image and displays it in the preview area.
[0109] In one embodiment, cropping the image area including the target object from the target picture includes: reading the attribute information of the target picture; when the attribute information includes the cropping position information, then performing direction correction on the target picture, and cropping the image area from the corrected image according to the cropping position information.
[0110] Specifically, when the attribute information includes complete cropping position information, it is determined that the read cropping position information is valid. The target picture is an original photographed picture, and the target picture usually carries image direction information. In order to avoid the loss of image direction information after cropping, which would cause the correction direction to fail, the terminal can first correct the direction according to the image direction information, and then perform cropping to obtain the image area.
[0111] In one embodiment, the terminal performs direction correction on the target picture, including mirror processing for the target picture photographed by the front camera. The terminal reads the camera type in the attribute information of the target picture, and when the target picture is a picture photographed by the front camera, the terminal performs mirror processing on the target picture, and then crops the image area from the mirror-processed picture according to the cropping position information.
[0112] In one embodiment, the terminal performs orientation correction on the target image, including rotating the target image captured by the rear camera. Specifically, the terminal can read the orientation angle information from the attribute information of the target image. For example, a rotation angle of 1 indicates that no rotation is needed, 2 indicates that the target image needs to be rotated 90 degrees clockwise, 3 indicates that the target image needs to be rotated 90 degrees counterclockwise, and 4 indicates that the target image needs to be rotated 180 degrees. After rotating the target image captured by the rear camera, the terminal then crops the image area from the rotated image according to the cropping position information.
[0113] In one embodiment, the method further includes: when the attribute information does not include cropping location information, the target image is directly cropped according to the size of the preview area to obtain the cropped image.
[0114] Specifically, when the terminal does not read the cropping position information from the attribute information of the target image, it directly crops the target image according to the size of the preview area, obtains the cropped image, and displays it in the preview area.
[0115] like Figure 6 The diagram shown is a flowchart of an image processing method in one embodiment. (Refer to...) Figure 6 The process begins with step 602: the user opens the terminal's photo album and selects the target image. Next, step 604: the user reads the attribute information of the selected target image. Step 606: the user determines whether the attribute information includes cropping position information. If so, step 608 is executed: the orientation of the target image is corrected. After step 608, step 610 is executed: the image after orientation correction is cropped according to the read cropping position information. Step 612: the cropped image is obtained and adapted to the size of the preview area for preview display. If the attribute information of the target image does not include cropping position information, step 614 is executed: the target image is directly adapted to the size of the preview area for preview display.
[0116] In the above embodiments, by adapting the cropped image area to the preview area before displaying it, the display effect of the target object in the target image can be improved.
[0117] In one embodiment, step 206 includes: displaying the content sharing interface of the social application; and displaying a thumbnail cropped from the target image and adapted to the size of the content editing area in the content editing area of the content sharing interface.
[0118] In this embodiment, the interface to be used to display the cropped image is a content sharing interface of a social application. The content sharing interface of the social application is provided with a content editing area, which is an area for editing content to be shared. The target picture is taken as the content to be shared, and a thumbnail of the target picture is displayed in the content editing area for user preview.
[0119] Specifically, after the terminal selects the target picture, the image region including the target object is cropped from the target picture according to the cropping position information in the attribute information of the target picture, and then the image region is scaled according to the size of the preview area to obtain a thumbnail, which is displayed in the content editing area of the content sharing interface.
[0120] Since the thumbnail matches the image region including the target object in the target picture, the thumbnail displayed in the content editing area can directly highlight the target object in the target picture, and completely convey the key content of the target picture, thereby realizing accurate and effective preview of the target picture. The user can clearly understand the main content of the target picture through the thumbnail, and does not need to further confirm the target picture by clicking the thumbnail, thereby simplifying the picture analysis operation to a certain extent and improving the picture sharing efficiency. Moreover, the cropping according to the cropping position information in the attribute information of the target picture avoids the time delay caused by manual selection of the cropping region or real-time detection each time the target picture is shared, thereby improving the picture sharing efficiency.
[0121] In one embodiment, the above method further includes: when a viewing operation on the thumbnail is triggered, displaying the target picture corresponding to the thumbnail; and when a sharing operation on the content to be shared in the content editing area is triggered, sharing the target picture corresponding to the thumbnail in the manner of displaying the thumbnail in the content sharing interface.
[0122] Since the original target picture is shared in the content sharing interface, and the thumbnail displayed in the content editing area is only used to help the user preview the target object that needs to be highlighted in the target picture, in this embodiment, the user can still trigger a viewing operation on the thumbnail in the content editing area to display the original target picture, so as to further confirm the target picture.
[0123] In addition, the content sharing interface can also be provided with a control for one-key sharing of the content to be shared in the content editing area. When the user confirms that the target picture can be shared through the thumbnail displayed in the content editing area, the target picture corresponding to the thumbnail can be shared in the manner of displaying the thumbnail in the content sharing interface by triggering a sharing operation on the control, thereby realizing sharing of the target picture to a shared object.
[0124] Specifically, the terminal can display a thumbnail of the shared target image through the content sharing interface. This thumbnail can directly highlight the target object in the target image, and both the user and the recipient can learn about the content of the shared target image through the thumbnail, thereby gaining the recipient's attention to the target image. Moreover, it can also make it convenient for the user and the recipient to decide whether to click on the thumbnail to view the original target image, avoiding the resource consumption caused by clicking on some invalid images.
[0125] In one embodiment, the content sharing interface of the social application also includes a photo album entry. The terminal can respond to the trigger operation of the photo album entry in the content sharing interface to enter the image browsing interface. After selecting the target image with cropping position information from the image browsing interface, it returns to the content sharing interface. In the content editing area of the content sharing interface, a thumbnail cropped from the target image and adapted to the size of the content editing area is displayed.
[0126] like Figure 7 The image shown is a schematic diagram of a content sharing interface in one embodiment. (Refer to...) Figure 7 In part (a), an album entry 704 is set in the content sharing interface 702. Users can enter the image browsing interface 706 by triggering the operation of the album entry 704, such as... Figure 7 As shown in part (b). In the image browsing interface 706, after selecting the target image 708, the user returns to the content sharing interface 702. At this time, the content sharing interface 702 displays the content editing area 710, as shown in the image sharing interface 706. Figure 7 As shown in section (c). In this content editing area 710, a thumbnail 712 corresponding to the target image 708, obtained based on the cropping position information in the attribute information of the target image 708, is displayed. Further, as... Figure 7 As shown in section (d), the terminal can also share the target image 708 to the recipient in the manner of displaying a thumbnail 712 in the content sharing interface 702.
[0127] In this embodiment, by displaying a thumbnail of the target object cropped from the target image in the content editing area of the content sharing interface of the social application, a precise and effective preview of the target image can be achieved, thereby improving the editing efficiency of the image to be shared.
[0128] In one embodiment, the target image is an ID card image, and step 206 includes: displaying an ID card image upload interface; and displaying a cropped image that is cut from the ID card image and adapted to the size of the preview area in the preview area of the ID card image upload interface.
[0129] In this embodiment, the interface for displaying the cropped image is a document image upload interface, such as an ID card, passport, or travel permit. The document image upload interface includes a preview area for previewing the document image. The target object in the document image can be a face, document number, or document validity period, or it can be the entire document in the image.
[0130] Specifically, after the terminal selects the ID image, it crops out the image area including the target object from the ID image according to the cropping position information in the ID image's attribute information. Then, it scales the image area according to the size of the preview area to obtain the cropped image, which is then displayed in the preview area of the ID image upload interface.
[0131] Because the cropped image matches the image area containing the target object in the ID card image, the cropped image displayed in the preview area can directly highlight the target object in the ID card image, perfectly conveying the key content of the ID card image. This achieves accurate and effective previewing of the ID card image, improving the efficiency of ID card image uploads. Furthermore, cropping based on the cropping position information in the ID card image's attribute information avoids the latency issues caused by manually selecting the cropping area or real-time detection each time, further improving the efficiency of ID card image uploads.
[0132] In one embodiment, the document image upload interface also includes an album entry. The terminal can respond to the triggering operation of the album entry in the document image upload interface to enter the image browsing interface. After selecting the document image with cropping position information from the image browsing interface, the terminal returns to the document image upload interface. In the preview area of the document image upload interface, a cropped image that is cropped from the document image and adapted to the size of the preview area is displayed.
[0133] like Figure 8 The image shown is a schematic diagram of the document image upload interface in one embodiment. (Refer to...) Figure 8 In part (a), the document image upload interface 802 includes an album entry 804 and a preview area 806. Users can access the image browsing interface 808 by triggering an operation on the album entry 804, such as... Figure 7 As shown in part (b). In the image browsing interface 808, after selecting the ID card image 810, the user returns to the ID card image upload interface 802. In the preview area 806, the cropped image 812 corresponding to the ID card image 810, obtained according to the cropping position information in the attribute information of the ID card image 810, is displayed.
[0134] In the embodiment, by displaying the cropped image cropped from the certificate picture according to the cropping position information in the preview area in the certificate image upload interface, accurate and effective preview of the certificate picture can be realized, thereby improving the efficiency of the certificate image upload.
[0135] In one embodiment, the step 206 comprises: displaying a portrait setting interface; and displaying, in a preview area of the portrait setting interface, a cropped image cropped from the target picture and adapted to the size of the preview area.
[0136] In the embodiment, the interface in which the cropped image is to be displayed is a portrait setting interface used for setting a user portrait. The portrait setting interface is provided with a preview area for previewing a picture to be used as a portrait. Specifically, after the terminal selects the target picture, the image region including the target object is cropped from the target picture according to the cropping position information in the attribute information of the target picture, and then the image region is scaled according to the size of the preview area to obtain the cropped image, which is displayed in the preview area of the portrait setting interface.
[0137] Since the cropped image matches the image region including the target object in the target picture, the cropped image displayed in the preview area can directly highlight the display of the target object in the target picture, perfectly convey the key content of the target picture, thereby realizing accurate and effective preview of the target picture and improving the efficiency of portrait setting. Moreover, cropping according to the cropping position information in the attribute information of the target picture avoids the time delay caused by manual selection of a cropping region or real-time detection each time a portrait is set, thereby improving the efficiency of portrait setting.
[0138] In one specific application scenario, for a large number of pictures of different sizes in a webpage, the cropping position information can be generated according to the position of a key target object when the pictures are generated, and written into the attribute information of the pictures. When a large number of pictures are displayed to a user, the pictures of different sizes can be cropped to obtain image regions in which the target objects are located according to the size of the same preview area, and then the cropped images are displayed after the cropped images are adapted to the preview area. When the user triggers a viewing operation on the cropped image, the original picture can be displayed, and when the user triggers a downloading operation on the cropped image, the original picture can be downloaded.
[0139] In one specific application scenario, when a poster in news information is generated, the cropping position information can be generated according to the position of a key target object in the poster, and written into the attribute information of the poster image. When the poster is displayed through a news client, the cropped image highlighting the key target object can be displayed in a news browsing page according to the cropping position information, and when the user views the cropped image, the original poster image is displayed.
[0140] In the following embodiments, the picture acquisition portal includes a camera portal, and the target picture is obtained by starting the camera through the camera portal and taking a picture immediately.
[0141] As shown in FIG. 1, it is a flowchart of an image processing method in an embodiment. Figure 9
[0142] Step 902, display the camera portal, and display a real-time shooting picture in response to a triggering operation on the camera portal.
[0143] The camera portal is an entry provided by the user interactive interface for taking pictures. The camera portal can be in the form of a touch control and arranged at any position in the user interactive interface. The triggering operation on the camera portal can be any one of a click operation, a sliding operation or a double-click operation. The real-time shooting picture is a real-time viewfinder picture captured by the camera after starting shooting.
[0144] Specifically, the terminal can display the camera portal in the user interactive interface, start the camera to collect images in real time in response to a triggering operation on the camera portal, and display a real-time shooting picture. The user interactive interface can also be provided with an album portal. In some scenarios, when the user needs to select a target picture through the album, the target picture can be selected through the album portal, and when the user needs to collect a target picture immediately, the target picture can be collected through the camera portal.
[0145] In an embodiment, to collect pictures in real time, the terminal can create a media management session and use the media management session to manage data objects related to collecting pictures in real time by the camera. Specifically, the terminal creates an initialized media management session AVCaptureSession by using AVFoundation (a framework for processing audio and video files), creates a device object AVCaptureDevice for representing a camera that can be switched forward and backward, creates an input object AVCaptureDeviceInput representing input data through the device object, an output object AVCapturePhotoOutput representing output picture data and an output object AVCaptureMetadataOutput representing output target object position data, and adds these input objects and output objects to the media management session AVCaptureSession, which is used to manage data streams obtained from physical devices and output to one or more destinations. In addition, the terminal also needs to create a real-time preview layer object AVCaptureVideoPreviewLayer for displaying a real-time shooting picture.
[0146] Step 904, display a prompt mark for a target object in the real-time shooting picture in the real-time shooting picture.
[0147] Specifically, for the captured real-time shooting picture, the terminal tracks the target object therein. The terminal detects whether the target object exists in the current real-time shooting picture, and if so, displays a prompt mark for the target object in the real-time shooting picture according to the target object position of the target object in the real-time shooting picture. If not, the terminal can also prompt the user to change the shooting angle in real time.
[0148] In one embodiment, step 904 includes: detecting the target object in the real-time shooting picture to obtain a detection result of the target object; and displaying a prompt mark in the real-time shooting picture according to the detection result of the target object.
[0149] The prompt mark of the target object can be a rectangular frame enclosing the target object, or four vertices locating the target object.
[0150] Optionally, the terminal can first detect a face in the real-time shooting picture, and when a face is detected, the detected face is taken as the target object, and a face prompt mark is displayed in the real-time shooting picture according to the position of the detected face. When no face is detected, the terminal can perform salient object detection on the real-time shooting picture, and when a salient object is detected, the salient object is taken as the target object, and a corresponding prompt mark is displayed. Of course, the terminal can also determine that no target object exists in the current shooting picture when no face is detected, and no prompt mark is displayed.
[0151] Optionally, the target object is a face, and when the terminal detects the face, the terminal extracts metadata related to the face and extracts face position information according to the metadata. For example, the terminal can obtain an array of metadata related to the face by using the AVFoundation library, and the array of metadata includes a plurality of AVMetadataObject objects, each of which includes faceID for identifying each detected face, erollAngle for identifying the roll angle of the face, i.e., the lateral inclination angle of the head to the shoulder, yawAngle for identifying the yaw angle, i.e., the angle of rotation of the face around the y axis, and bounds for identifying the position of the detected face region. The terminal can determine the face position information according to the metadata related to the face, and draw a prompt mark for tracking the face in the real-time shooting picture based on the face position information to assist the user in shooting the picture. In addition, the terminal can also use OpenCV, Face++, and other frameworks to obtain the position information of the target object in the real-time shooting picture.
[0152] In this way, by marking the target object in the real-time shooting picture, the user is guided to take a picture more reasonably, and the problem of inaccurate or failed target object detection on the taken picture can be avoided, so that the preview effect and the cropping effect of the target picture after cropping are improved to a certain extent.
[0153] At step 906, in response to the picture collection operation, a target picture including a target object is collected.
[0154] In some embodiments, the terminal collects the target picture in response to the picture collection operation.
[0155] In one embodiment, after the terminal collects the target picture, since the position of the target object is based on the device coordinate system, for example, the resolution of the camera is 1280*720 when the target picture is collected, and the size of the collected target picture is 1280*720 px, in order to avoid errors in the cropping position, the resolution needs to be converted to the physical size. The ratio of the resolution to the physical size can be 2:1, or 3:1, which can be set according to design requirements. In this way, after conversion to the physical size, the target object can be accurately cropped from the target picture.
[0156] At step 908, a cropped image cropped from the target picture is displayed; the cropped image matches the image region including the target object in the target picture indicated by the prompt mark of the target object.
[0157] In some embodiments, after the terminal collects the target picture, the direction of the target picture can be corrected, and the target object region determined by the prompt mark in the picture after the direction is corrected can be optimized to obtain an image region. The position information of the image region is used as the cropping position information, and the image region is cropped from the target picture.
[0158] In one embodiment, the cropped image can be an image region in the target picture marked by the cropping position information. Specifically, after the target picture is collected, the terminal can determine an image region including the target object according to the prompt mark of the target object in the target picture, and then generate cropping position information for marking the image region. After the image region including the target object is cropped from the target picture according to the cropping position information, the image region is used as the cropped image.
[0159] In one embodiment, the cropped image can be an image obtained by scaling the image region in the target picture marked by the cropping position information. Specifically, after the target picture is collected, the terminal can determine the image region including the target object according to the prompt mark of the target object in the target picture, and then generate the cropping position information for marking the image region. After the image region including the target object is cropped from the target picture according to the cropping position information, the image obtained by scaling the image region is taken as the cropped image to be displayed.
[0160] In one embodiment, step 902 includes: displaying an image display interface, the image display interface including a camera entry; in response to a triggering operation on the camera entry, entering a picture collection interface; in the picture collection interface, displaying a real-time shooting picture.
[0161] The image display interface is a user interaction interface for displaying a cropped image. The image display interface is provided with a camera entry and an album entry. When a user needs to display a target picture in the image display interface, the target picture can be collected through the camera entry, and the cropped image obtained by cropping the target picture can be displayed in the image display interface. The target picture can also be selected through the album entry, and the cropped image obtained by cropping the target picture can be displayed in the image display interface.
[0162] The triggering operation on the camera entry can be any one of a click operation, a sliding operation or a double-click operation. The picture collection interface is a user interaction interface for displaying a real-time shooting picture. The picture collection interface can be displayed in the form of a pop-up window above the image display interface, or can be in the form of jumping from the image display interface to the picture collection interface.
[0163] Specifically, when the operation on the picture collection entry is triggered, the picture collection interface is entered from the displayed image display interface.
[0164] In one embodiment, step 906 includes: in response to a picture collection operation in the picture collection interface, collecting a target picture including a target object, and returning from the picture collection interface to the image display interface; and step 908 includes: displaying a cropped image cropped from the target picture in a preview area of the image display interface.
[0165] The preview area of the image display interface is an area for previewing a target picture. The image display interface is provided with a preview area in addition to a picture collection entry and an album entry. Since the cropped image matches the image region including the target object in the target picture, the cropped image displayed in the preview area can directly highlight the target object in the target picture, perfectly conveying the key content of the target picture, thereby realizing accurate and effective preview of the target picture.
[0166] In some embodiments, the cropped image cropped from the target picture is displayed in the preview area of the image display interface. When the user views the key content in the target picture through the cropped image displayed in the preview area, the user can choose to further process the target picture. For example, in some scenarios, the user considers that the target picture is not perfect enough, and can re-enter the picture collection interface through the picture collection entrance to collect a new target picture. In other scenarios, the user considers that the target picture is perfect enough, and can share the target picture to other users.
[0167] In one embodiment, step 908 comprises: displaying, in the preview area of the image display interface, a cropped image cropped from the target picture and adapted to the size of the preview area.
[0168] The preview area of the image display interface is an area for previewing the target picture. The preview area is usually fixedly arranged in the image display interface, and the size of the preview area is also fixed. When the terminal displays the cropped image through the preview area, the displayed cropped image is adapted to the size of the preview area.
[0169] In one embodiment, the above method further comprises: cropping, according to the cropping position information, an image area including the target object from the target picture; when the size of the preview area is smaller than the size of the image area, redrawing the image area in the preview area according to the size of the preview area to obtain the cropped image.
[0170] In one embodiment, when the size of the preview area is larger than the size of the image area, performing scaling processing on the image area according to a scaling ratio determined according to the size of the preview area and the size of the image area to obtain the cropped image.
[0171] Specifically, after collecting the target picture, the terminal crops, according to the cropping position information determined based on the prompt mark of the target object, an image area including the target object from the target picture. In order to improve the display effect, the terminal can also perform size adaptation processing on the image area before finally displaying it in the preview area.
[0172] The terminal can obtain the size of the preview area, and determine the size of the image area according to the cropping position information. When the size of the image area is relatively large compared with the size of the preview area, the terminal can redraw the image area according to the size of the preview area to obtain the cropped image, which is displayed in the preview area. When the size of the image area is relatively small compared with the size of the preview area, in order to avoid distortion of the image area due to stretching, the terminal performs equal-proportion scaling processing on the image area to obtain the cropped image, which is displayed in the preview area.
[0173] As Figure 10Fig. 1 shows an interface diagram of an image display interface according to an embodiment. Referring to Fig. 1, the image display interface 1002 is shown, which includes a picture collection entry 1004, a photo album entry 1006, and a preview area 1008. A user can trigger an operation on the picture collection entry 1004 to enter a picture collection interface 1010, in which a real-time shooting picture is displayed, and a prompt mark 1012 of a target object is displayed in the real-time shooting picture. After confirming that the target picture is collected, the user returns to the image display interface 1002, and a cropped image 1012 of the target picture is displayed in the preview area 1008 of the image display interface 1002. The user can trigger an operation on the photo album entry 1006 to enter a picture browsing interface 1014, in which a plurality of candidate pictures are displayed. The user can trigger a selection operation on one or more candidate pictures to select a target picture, and then returns to the image display interface 1002, and a cropped image 1012 cropped from the target picture according to the cropping position information in the attribute information of the target picture is displayed in the preview area 1008 of the image display interface 1002. Figure 10 In the image display interface 1002, the picture collection entry 1004, the photo album entry 1006, and the preview area 1008 are provided. The user can trigger an operation on the picture collection entry 1004 to enter the picture collection interface 1010, in which a real-time shooting picture is displayed, and a prompt mark 1012 of a target object is displayed in the real-time shooting picture. After confirming that the target picture is collected, the user returns to the image display interface 1002, and a cropped image 1012 of the target picture is displayed in the preview area 1008 of the image display interface 1002. The user can trigger an operation on the photo album entry 1006 to enter the picture browsing interface 1014, in which a plurality of candidate pictures are displayed. The user can trigger a selection operation on one or more candidate pictures to select a target picture, and then returns to the image display interface 1002, and a cropped image 1012 cropped from the target picture according to the cropping position information in the attribute information of the target picture is displayed in the preview area 1008 of the image display interface 1002.
[0174] In an embodiment, after the target picture is collected, the target picture is an original shooting picture. Generally, the target picture carries image direction information. In order to avoid the loss of image direction information after cropping, which leads to the failure of the correction direction, the terminal can correct the direction of the target picture according to the image direction information, and then perform cropping to obtain an image region including the target object.
[0175] In an embodiment, the terminal corrects the direction of the target picture, including mirroring the target picture shot by the front camera. The terminal reads the camera type in the attribute information of the target picture. When the target picture is a picture shot by the front camera, the terminal performs mirroring on the target picture, and then crops an image region from the picture after mirroring according to the cropping position information determined based on the promotion mark.
[0176] In an embodiment, the terminal corrects the direction of the target picture, including rotating the target picture shot by the back camera. Specifically, the terminal can read the direction angle information in the attribute information of the target picture. For example, the rotation angle information is 1, indicating that the target picture does not need to be rotated, the rotation angle information is 2, indicating that the target picture needs to be rotated clockwise by 90 degrees, the rotation angle information is 3, indicating that the target picture needs to be rotated counterclockwise by 90 degrees, and the rotation angle information is 4, indicating that the target picture needs to be rotated by 180 degrees. The terminal performs rotation on the target picture shot by the back camera, and then crops an image region from the picture after rotation according to the cropping position information determined based on the promotion mark.
[0177] In addition, in order to present the target object in the target picture completely by the cropped image, the terminal can also optimize the position of the target object determined by the prompt mark to have certain fault tolerance. The target object in the target picture collected by the front camera is generally large, and the target object in the target picture collected by the rear camera is generally small. The embodiment further optimizes the position of the target object determined by the prompt mark to have fault tolerance. The above method further comprises: determining the type of the camera when the target picture including the target object is collected; and performing fault tolerance optimization processing on the position of the target object marked by the prompt mark when the target picture is collected according to the preset size corresponding to the type of the camera, to obtain the cropping position information.
[0178] In one embodiment, the fault tolerance optimization processing on the position of the target object marked by the prompt mark when the target picture is collected according to the preset size corresponding to the type of the camera, to obtain the cropping position information, comprises: when the type of the camera is the front camera, taking the target object region marked by the prompt mark when the target picture is collected as a center region, expanding the center region according to a first preset size, and obtaining the cropping position information according to a first region obtained by the expansion; when the type of the camera is the rear camera, taking the target object region marked by the prompt mark when the target picture is collected as a center region, expanding the center region according to a second preset size, and obtaining the cropping position information according to a second region obtained by the expansion; wherein the first preset size is greater than the second preset size.
[0179] For example, the target object is a face, and the face region marked by the prompt mark is a facial feature region. If the face is directly cropped from the target picture according to the prompt mark as the cropped image, the whole portrait cannot be accurately presented, resulting in missing face. Therefore, the terminal can take the face region as a center region, expand the center region, take the expanded region as a region to be cropped, and take the position information corresponding to the expanded region as the cropping position information, so that the whole portrait can be cropped. In addition, for the target picture collected by the rear camera, the size of the expansion is larger than that of the target picture collected by the front camera.
[0180] In one embodiment, the above method further comprises: determining the cropping position information of the target picture based on the prompt mark of the target object; writing the cropping position information into the attribute information of the target picture; and storing the target picture carrying the cropping position information.
[0181] In the embodiment, for the original target picture, after the cropping position information for marking the image region including the target object is determined, the cropping position information is written into the attribute information of the original target picture, and then the original target picture is stored locally. When the stored original target picture needs to be previewed, the target picture can be selected through the album entrance, and the cropping position information in the attribute information of the target picture is directly used for cropping, so that the problem of time delay caused by manual selection of the cropping region or real-time detection is avoided, and the generation efficiency and display effect of the cropped image are improved.
[0182] In one embodiment, after the target picture is collected, the terminal can convert the resolution size of the target picture into the physical size, correct the direction of the target picture, determine the prompt mark of the target object after the direction correction according to the prompt mark of the target object when the target picture is collected, expand the target object region marked by the prompt mark, obtain the optimized image region, generate the position information of the image region as the final cropping position information, write the cropping position information into the attribute information of the original target picture, and then store the original target picture.
[0183] As shown in Figure 11 , it is a flowchart of the image processing method in one embodiment. Referring to Figure 11 , the process starts, and step 1102: the camera on the terminal is started to collect pictures; then step 1104: whether the target object is detected is determined; if yes, step 1106: the prompt mark of the target object is displayed in the real-time shooting picture; if no, step 1108: the user is prompted to change the shooting angle in real time; after step 1106, step 1110: the user confirms the shooting, and the target picture is collected; step 1112: the direction of the target picture is corrected; step 1114: the position of the target object determined by the prompt mark when the target picture is collected is expanded to obtain the optimized cropping position information, the target picture after the direction correction is cropped according to the cropping position information, and the cropped image is obtained; step 1116: the cropping position information is stored in the attribute information of the original target picture; step 1118: the size of the preview region is adapted to display the cropped image; and the process ends.
[0184] In one embodiment, the target image can be the video cover. The terminal can use the cropping method provided in this application embodiment to crop and preview the video cover. For example, after the video recording is completed, object detection is performed on the video cover, and the cropping position information corresponding to the target object in the detected video cover is written into the attribute information of the video. In the user interface that needs to display the video, the video cover is cropped according to the cropping position information in the video's attribute information to obtain a cropped image, which is then displayed in the preview area of the user interface. The video cover can be the first frame of the video. In this way, the cropped image can directly highlight the target object in the video cover, perfectly conveying the key content of the video cover, thereby achieving an accurate and effective preview of the video cover and attracting the attention of others to the video.
[0185] like Figure 12 The diagram shown is a flowchart of an image processing method in a specific embodiment. (Refer to...) Figure 12 The target object is a face. First, to capture the target image, the terminal creates a media management session and a device object representing a switchable camera. This device object is used to create input objects representing input data, output objects representing output image data, and output objects representing the target face's position data. These input and output objects are added to the media management session. Finally, a real-time preview layer object is created, and face-related metadata from the captured target image is obtained. Next, face-related metadata (face tilt angle, face rotation angle, and face region position) is used to draw face-related markers. Then, the capture is confirmed, and the target image and the face-related markers within it are acquired. The target image size is converted from resolution to physical size, the image orientation is corrected, and the face region position is corrected based on the markers. The cropping position information is obtained based on the corrected region's coordinates and size. Finally, the corrected image is cropped using the cropping position information, resulting in a cropped image, which is then displayed to fit the preview area. In addition, the cropping location information is written into the EXIF information of the original target image, and then the target image is saved to the local album.
[0186] For a target image stored in the local album, when cropping and previewing are needed, the target image is selected locally, its EXIF information is obtained, and the cropping position information within the EXIF information is read. If the cropping position information is valid, the orientation is corrected based on the target image's angle information, and then the image is cropped according to the cropping position information. The cropped image is then adapted to the size of the preview area and displayed. If the cropping position information is invalid, the selected target image is directly adapted to the size of the preview area and then filled into the preview area.
[0187] It should be understood that although the steps in the above flowcharts are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the steps are not strictly limited in sequence, and the steps can be executed in other sequences. Moreover, at least some of the steps in the above flowcharts can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of the steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.
[0188] In one embodiment, as shown in FIG. 13, an image processing apparatus 1300 is provided, which can be a part of a computer device in the form of a software module or a hardware module, or a combination of both. The apparatus specifically includes a display module 1302 and a picture selection module 1304, wherein: Figure 13 The display module 1302 is configured to display a photo album entry, and in response to a triggering operation on the photo album entry, display at least one candidate picture.
[0189] The picture selection module 1304 is configured to select a target picture from the displayed candidate pictures in response to a picture selection operation. The attribute information of the target picture includes cropping position information, and the cropping position information marks an image region in the target picture that includes a target object.
[0190] The display module 1302 is further configured to display a cropped image cropped from the target picture. The cropped image matches the image region in the target picture marked by the cropping position information.
[0191] In one embodiment, the display module 1302 is further configured to display an image display interface, and the image display interface includes the photo album entry.
[0192] In response to a triggering operation on the photo album entry, enter a picture browsing interface.
[0193] In the picture browsing interface, display at least one candidate picture.
[0194] In the above embodiment, the display module 1302 is further configured to, in response to a picture selection operation in the picture browsing interface, select a target picture from the displayed candidate pictures, and return from the picture browsing interface to the image display interface after selecting the target picture. In a preview area of the image display interface, display a cropped image cropped from the target picture.
[0195]
[0196] In one embodiment, the display module 1302 is further configured to display, in the preview area of the image display interface, a cropped image cropped from the target picture and adapted to the size of the preview area.
[0197] In the above embodiment, the image processing apparatus 1300 further comprises a preview area adaptation module configured to crop, according to the cropping position information, an image region including the target object from the target picture; when the size of the preview area is smaller than the size of the image region, redraw the image region in the preview area according to the size of the preview area to obtain the cropped image; and when the size of the preview area is larger than the size of the image region, perform scaling processing on the image region according to a scaling ratio determined according to the size of the preview area and the size of the image region to obtain the cropped image.
[0198] In the above embodiment, the image processing apparatus 1300 further comprises:
[0199] a direction correction module configured to read attribute information of the target picture; when the attribute information includes the cropping position information, crop the image region from the corrected image according to the cropping position information after direction correction of the target picture;
[0200] the preview area adaptation module is further configured to, when the attribute information does not include the cropping position information, directly crop the target picture according to the size of the preview area to obtain the cropped image.
[0201] In one embodiment, the picture acquisition portal includes a camera portal, as shown in Figure 14 The image processing apparatus 1300 further comprises a picture acquisition module 1306.
[0202] The display module 1302 is further configured to display, in response to a triggering operation on the camera portal, a real-time shooting picture; and display, in the real-time shooting picture, a prompt mark of the target object in the real-time shooting picture.
[0203] The picture acquisition module 1306 is configured to acquire, in response to a picture acquisition operation, a target picture including the target object.
[0204] The display module 1302 is further configured to display a cropped image cropped from the target picture; the cropped image matches an image region including the target object in the target picture prompted by the prompt mark of the target object.
[0205] In the above embodiment, the display module 1302 is further configured to display an image display interface; the image display interface includes the camera portal; in response to a triggering operation on the camera portal, enter a picture acquisition interface; and display, in the picture acquisition interface, a real-time shooting picture.
[0206] In the previous embodiment, the picture collection module 1306 is configured to collect a target picture including the target object in response to a picture collection operation in the picture collection interface, and return the image display interface from the picture collection interface.
[0207] The display module 1302 is further configured to display the cropped image cropped from the target picture in the preview area of the image display interface.
[0208] In an embodiment, the image processing apparatus 1300 further includes a position optimization module configured to determine a camera type when the target picture including the target object is collected, and perform fault-tolerant optimization processing on a target object position marked by the prompt mark when the target picture is collected according to a preset size corresponding to the camera type to obtain the cropping position information.
[0209] In the previous embodiment, the position optimization module is further configured to, when the camera type is a front camera, take a target object region marked by the prompt mark as a center region when the target picture is collected, expand the center region according to a first preset size, and obtain the cropping position information according to a first region obtained by the expansion; and when the camera type is a rear camera, take the target object region marked by the prompt mark as a center region when the target picture is collected, expand the center region according to a second preset size, and obtain the cropping position information according to a second region obtained by the expansion; wherein the first preset size is greater than the second preset size.
[0210] In an embodiment, with reference to Figure 14 , the image processing apparatus 1300 further includes a picture storage module 1308 configured to determine the cropping position information of the target picture based on the prompt mark of the target object, write the cropping position information into attribute information of the target picture, and store the target picture carrying the cropping position information.
[0211] In an embodiment, the display module 1302 is further configured to display a content sharing interface of a social application, and display a thumbnail cropped from the target picture and adapted to a size of a content editing area of the content sharing interface in the content editing area.
[0212] In the previous embodiment, the display module 1302 is further configured to, when a viewing operation on the thumbnail is triggered, display a target picture corresponding to the thumbnail, and when a sharing operation on the content to be shared in the content editing area is triggered, share the target picture corresponding to the thumbnail in a manner of displaying the thumbnail in the content sharing interface.
[0213] In an embodiment, the target picture is a certificate picture, and the display module 1302 is further configured to display a certificate image upload interface, and display a cropped image cropped from the certificate picture and adapted to a size of a preview area of the certificate image upload interface in the preview area.
[0214] In an embodiment, the display module 1302 is further configured to display the avatar setting interface, and display the cropped image, which is cropped from the target picture and is adapted to the size of the preview area, in a preview area of the avatar setting interface.
[0215] The image processing apparatus 1300 displays the album entry, displays at least one candidate picture in response to a triggering operation on the album entry, selects the target picture from the candidate picture when a picture selection operation is triggered, and the attribute information of the selected target picture includes accurate cropping position information, which marks the image area of the target picture including the target object. In this way, after the target picture is selected, the target picture can be directly cropped according to the accurate cropping position information, and after a cropped image matching the image area marked by the cropping position information is obtained, the cropped image is directly displayed. On the one hand, compared with directly cropping the central area from the target picture, the cropping position information can accurately locate the image area of the target object in the target picture, avoiding the missing of the target object part in the cropped image. On the other hand, compared with manually selecting the cropping area or locating the cropping area through real-time detection, only the cropping position information in the attribute information of the target picture is needed to crop, avoiding the time delay problem caused by manual selection of the cropping area or real-time detection each time the target picture is displayed, and improving the generation efficiency and display effect of the cropped image.
[0216] The specific limitations of the image processing apparatus 1300 can be referred to the limitations of the image processing method in the foregoing, which will not be repeated here. Each module in the image processing apparatus 1300 can be realized by software, hardware and combinations thereof in whole or in part. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0217] In an embodiment, a computer device is provided, which can be a terminal, and the internal structure diagram thereof can be as shown in FIG. 13B. Figure 15As shown in the figure. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, operator network, NFC (near field communication) or other technologies. The computer program is executed by the processor to implement an image processing method. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0218] Those skilled in the art can understand that, Figure 15 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0219] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in each of the above method embodiments.
[0220] In one embodiment, a computer readable storage medium is provided, storing a computer program, which is executed by a processor to implement the steps in each of the above method embodiments.
[0221] In one embodiment, a computer program product or computer program is provided, which includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the steps in each of the above method embodiments.
[0222] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, storage, database or other medium used in each embodiment provided by the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0223] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of each technical feature in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0224] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that for those skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.
Claims
1. An image processing method, characterized in that, The method includes: The image acquisition interface displays an image acquisition entry point, which includes an album entry point and a camera entry point. In response to a trigger operation on the camera entry point, the real-time captured image is displayed; In response to an image acquisition operation, acquire a target image including the target object; Determine the cropping position information of the target image, wherein the cropping position information is the position information of an image region in the target image, and the image region includes the target object in the target image; The cropping position information is written into the attribute information of the target image; Store the target image carrying the cropping position information; In response to a trigger operation on the album entry, at least one candidate image is displayed; In response to an image selection operation, select the target image from the displayed candidate images; Read the attribute information of the selected target image; If the selected target image's attribute information includes cropping position information, an image region is located in the selected target image according to the cropping position information in the target image's attribute information. Based on the image region, a cropped image that is cropped from the target image and adapted to the size of the preview area is displayed in the preview area of the image display interface; the cropped image matches the image region that includes the target object. If the selected target image does not include cropping location information in its attribute information, the target image is directly cropped according to the size of the preview area to obtain a cropped image, and then the cropped image cropped from the target image is displayed.
2. The method according to claim 1, characterized in that, The step of displaying a cropped image, cropped from the target image and adapted to the size of the preview area, in the preview area of the image display interface includes: When the size of the preview area is smaller than the size of the image area, the image area is redrawn in the preview area according to the size of the preview area to obtain the cropped image; When the size of the preview area is larger than the size of the image area, the image area is scaled according to a scaling ratio determined based on the size of the preview area and the size of the image area to obtain the cropped image.
3. The method according to claim 2, characterized in that, When the selected target image's attribute information includes cropping position information, locating the image region in the selected target image based on the cropping position information in the target image's attribute information includes: If the selected target image's attribute information includes cropping position information, then after correcting the orientation of the target image, the image region is located in the selected target image based on the cropping position information in the target image's attribute information.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: In the live-stream video feed, a prompt mark is displayed for the target object in the live-stream video feed; Display a cropped image extracted from the target image; the cropped image matches the image region of the target image that includes the target object, as indicated by the object's prompt mark.
5. The method according to claim 4, characterized in that, The method of displaying a prompt mark for the target object in the real-time captured image includes: The target object in the real-time captured image is detected, and the detection result of the target object is obtained; In the real-time captured footage, prompt markers are displayed in real time based on the detection results of the target object.
6. The method according to claim 4, characterized in that, The method further includes: Determine the type of camera used when acquiring target images that include the target object; Based on the preset size corresponding to the camera type, the position of the target object marked by the prompt mark when the target image is captured is subjected to fault-tolerant optimization processing to obtain the cropping position information.
7. The method according to claim 6, characterized in that, The step of performing fault-tolerant optimization processing on the target object position marked by the prompt marker when the target image is captured, based on a preset size corresponding to the camera type, to obtain cropping position information includes: When the camera type is a front-facing camera, the target area marked by the prompt mark when the target image is captured is taken as the central area, and the central area is expanded according to the first preset size. Then, the cropping position information is obtained based on the expanded first area. When the camera type is a rear camera, the target area marked by the prompt mark when the target image is captured is taken as the central area, and the central area is expanded according to the second preset size. Then, the cropping position information is obtained according to the expanded second area. Wherein, the first preset size is larger than the second preset size.
8. The method according to claim 1, characterized in that, The image display interface is a content sharing interface for a social application. The preview area of the image display interface displays a cropped image, cut from the target image and adapted to the size of the preview area, including: In the content editing area of the content sharing interface, a thumbnail cropped from the target image and adapted to the size of the content editing area is displayed.
9. The method according to claim 8, characterized in that, The method further includes: When a view operation of the thumbnail is triggered, the target image corresponding to the thumbnail is displayed; When a sharing operation is triggered on the content to be shared in the content editing area, the target image corresponding to the thumbnail is shared in the manner shown in the content sharing interface.
10. The method according to claim 1, characterized in that, The image display interface is a document image upload interface, the target image is a document image, and the preview area of the image display interface displays a cropped image that is cut from the target image and adapted to the size of the preview area, including: In the preview area of the document image upload interface, a cropped image that is cut from the document image and adapted to the size of the preview area is displayed.
11. The method according to claim 1, characterized in that, The image display interface is an avatar setting interface. The preview area of the image display interface displays a cropped image, cut from the target image and adapted to the size of the preview area, including: In the preview area of the avatar settings interface, a cropped image that is cut from the target image and adapted to the size of the preview area is displayed.
12. An image processing apparatus, characterized in that, The device includes: The display module is used to display the album and camera entry points in the image display interface. The image acquisition module is used to display the real-time shooting screen in response to the trigger operation of the camera entry, and to acquire target images including the target object in response to the image acquisition operation. The image storage module is used to determine the cropping position information of the target image, wherein the cropping position information is the position information of an image region in the target image, the image region includes the target object in the target image, the cropping position information is written into the attribute information of the target image, and the target image carrying the cropping position information is stored. The display module is also configured to display at least one candidate image in response to a trigger operation on the album entry; The image selection module is used to select the target image from the displayed candidate images in response to the image selection operation; The display module is further configured to read the attribute information of the selected target image, and if the attribute information of the selected target image includes cropping position information, locate an image region in the selected target image according to the cropping position information in the attribute information of the target image, and display a cropped image that is cropped from the target image and adapted to the size of the preview area in the preview area of the image display interface according to the image region; the cropped image matches the image region including the target object; The preview area adaptation module is also used to directly crop the target image according to the size of the preview area to obtain a cropped image when the cropping position information is not included in the attribute information of the selected target image, and then display the cropped image cropped from the target image.
13. The apparatus according to claim 12, characterized in that, The preview area adaptation module is further configured to: when the size of the preview area is smaller than the size of the image area, redraw the image area in the preview area according to the size of the preview area to obtain the cropped image; when the size of the preview area is larger than the size of the image area, scale the image area according to a scaling ratio determined based on the size of the preview area and the size of the image area to obtain the cropped image.
14. The apparatus according to claim 13, characterized in that, The device further includes: The orientation correction module is used to correct the orientation of the target image and locate the image region in the selected target image according to the cropping position information in the target image's attribute information when the target image's attribute information includes cropping position information.
15. The apparatus according to any one of claims 12 to 14, characterized in that, The display module is further configured to display a prompt mark for the target object in the real-time captured image; display a cropped image cropped from the target image; and the cropped image is matched with the image area of the target image that includes the target object, as indicated by the prompt mark for the target object.
16. The apparatus according to claim 15, characterized in that, The display module is also used to detect the target object in the real-time captured image and obtain the detection result of the target object; and to display a prompt mark in real time in the real-time captured image based on the detection result of the target object.
17. The apparatus according to claim 15, characterized in that, The device further includes: The position optimization module is used to determine the camera type when acquiring a target image including the target object; based on the preset size corresponding to the camera type, it performs fault-tolerant optimization processing on the position of the target object marked by the prompt mark when the target image is acquired, and obtains cropping position information.
18. The apparatus according to claim 17, characterized in that, The position optimization module is further configured to, when the camera type is a front-facing camera, take the target object area marked by the prompt mark when the target image is captured as the central area, expand the central area according to a first preset size, and obtain cropping position information based on the expanded first area; When the camera type is a rear camera, the target area marked by the prompt mark when the target image is captured is taken as the central area, and the central area is expanded according to the second preset size. Then, the cropping position information is obtained according to the expanded second area; wherein, the first preset size is larger than the second preset size.
19. The apparatus according to claim 12, characterized in that, The image display interface is a content sharing interface for a social application. The display module is also used to display a thumbnail cropped from the target image and adapted to the size of the content editing area in the content editing area of the content sharing interface.
20. The apparatus according to claim 19, characterized in that, The display module is further configured to display the target image corresponding to the thumbnail when a viewing operation of the thumbnail is triggered; and to share the target image corresponding to the thumbnail in the same manner as the thumbnail is displayed in the content sharing interface when a sharing operation of the content to be shared in the content editing area is triggered.
21. The apparatus according to claim 12, characterized in that, The image display interface is an ID card image upload interface, the target image is an ID card image, and the display module is also used to display a cropped image that is cut from the ID card image and adapted to the size of the preview area in the preview area of the ID card image upload interface.
22. The apparatus according to claim 12, characterized in that, The image display interface is an avatar setting interface. The display module is also used to display a cropped image that is cut from the target image and adapted to the size of the preview area in the preview area of the avatar setting interface.
23. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.
24. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
25. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Method for generating user head portrait and electronic equipment
CN110377204A
Thumbnail display method and device, storage medium and terminal
CN111127469A
Image processing method, device, equipment and medium
CN111753766A
Image processing method and device, electronic equipment and storage medium
CN112036241A
Image presentation device with user-inputted attribute changing procedures
US5982388A