Image processing method and related apparatus
By detecting target information in the image to determine the rotation angle and automatically adjusting the image orientation, the problem of complicated operations for users when rotating images is solved, improving interaction efficiency and browsing experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-11-29
- Publication Date
- 2026-05-29
AI Technical Summary
When users adjust the display orientation of an image, they need to perform complicated operations to rotate the image to the user's desired orientation, especially when the display orientation of the image content differs significantly from the user's expected orientation, resulting in low interaction efficiency.
Electronic devices detect target information in an image, such as a face or text, determine the rotation angle, and automatically rotate the image based on that angle to ensure the target information is displayed face-up on the screen, reducing the number of user operations.
It improves the efficiency of user interaction with electronic devices, simplifies the process of rotating images to the user's desired orientation, and enhances the browsing experience.
Smart Images

Figure CN122115220A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to image processing methods and related devices. Background Technology
[0002] With the development of electronic technology, electronic devices such as mobile phones and computers are equipped with applications for browsing or editing digital images. When users browse or process images through these applications, the image display orientation may not meet their expectations. Therefore, users need to rotate the image to adjust its orientation so that the content of interest in the image is displayed in the direction they expect.
[0003] However, for some images downloaded from the internet or images taken from poor angles, the displayed content may be quite varied, and the orientation of the content may deviate significantly from the user's desired orientation. This can lead to users performing complex operations to adjust the image's orientation to their preferred view. Therefore, for these scenarios, more efficient image processing methods need to be researched. Summary of the Invention
[0004] The purpose of this application is to provide an image processing method and related apparatus. Implementing this method, after receiving a user's operation to rotate an image, the electronic device can determine the rotation angle of the image based on the display orientation of information such as faces and text within the image, and rotate the image based on the determined rotation angle so that information such as faces and text is displayed facing forward on the screen. In this way, the user can easily rotate the image to the desired orientation, effectively improving the interaction efficiency between the user and the electronic device while ensuring a good image browsing experience.
[0005] The aforementioned and other objectives will be achieved through the features described in the independent claims. Further implementations are illustrated in the dependent claims, the specification, and the drawings.
[0006] In a first aspect, this application provides an image processing method, the method comprising: detecting target information in a first image in response to a first operation, the first operation being used to rotate the first image; determining a target rotation angle based on a first display direction and a second display direction, the first display direction being the display direction of the target information in the first image, and the second display direction being the display direction when the target information is displayed facing forward; and rotating the first image according to the target rotation angle.
[0007] Understandably, users often have a general preference for the display orientation of certain information within an image. For example, when an image contains facial information, if the face is a frontal view including eyes, nose, and mouth, the user is likely to want the face to be displayed upright, i.e., with the eyes, nose, and mouth displayed sequentially from top to bottom (i.e., the top of the head facing upwards). Therefore, in this method, after receiving the first operation to rotate the image, the electronic device can determine the image rotation angle based on the display orientation of the target information (such as faces, text, etc.) contained in the image, and rotate the image based on the determined rotation angle so that the target information is displayed upright on the screen. In this way, users can easily rotate the image to their desired orientation with a simple operation, effectively improving the interaction efficiency between the user and the electronic device while ensuring the user's image browsing experience.
[0008] Optionally, the target information may include one or more of the following: faces, text, plants, and buildings.
[0009] Optionally, the first operation described above can be a user's click operation on the rotation control; wherein, when the first operation is detected, the rotation control can be displayed on the same interface as the first image described above.
[0010] Optionally, the first image mentioned above can be an image from an application (e.g., a gallery) on the electronic device used for storing and managing images, or it can be an image cached by the electronic device from other applications (e.g., existing in an application). Images can be found in chat messages and viewed by users, or they can be obtained from any other application installed on an electronic device that can be used to view or edit digital images.
[0011] Optionally, the target rotation angle can be a vector, which includes not only a specific angle value but also the direction of rotation of the image. This direction can be clockwise or counterclockwise, and can be determined by the default image rotation direction set by the electronic device.
[0012] In conjunction with the first aspect, in one possible implementation, determining the target rotation angle based on the first display direction and the second display direction includes: when the target information is not displayed in the first image in a forward orientation, determining the angle formed by the first display direction and the second display direction as the target rotation angle; or, when the target information is displayed in the first image in a forward orientation, determining a preset angle as the target rotation angle.
[0013] Understandably, if the target information is not displayed in the first image in a forward orientation, that is, when the first display orientation and the second display orientation are different, the electronic device can determine that the target information is the information that the user is interested in in the first image, and the user rotates the image in order to display the target information in a forward orientation on the screen of the electronic device.
[0014] If the target information is already displayed facing forward in the first image, the angle formed by the first and second display directions is actually 0°. If this angle is determined as the target rotation angle, the electronic device will not rotate the image. However, the user has still performed the first operation mentioned above, indicating that the user intends to change the display direction of the first image. Therefore, in this case, the electronic device can no longer determine the image rotation angle based on the image content, but directly rotate the image by a fixed angle (i.e., the aforementioned preset angle) according to the original default method of the electronic device. In this way, even when the information contained in the first image is already displayed facing forward, the electronic device can still respond to the user's rotation operation and rotate the image, avoiding the first operation being invalid and ensuring the interaction efficiency between the user and the electronic device to a certain extent.
[0015] Optionally, the preset angle can be 90°.
[0016] In conjunction with the first aspect, in one possible implementation, detecting target information in the first image includes: detecting first information in the first image; determining the first information as target information when the first image contains the first information and the first information is not displayed in the first image in a forward orientation; detecting second information in the first image when the first image does not contain the first information or the first information is displayed in the first image in a forward orientation; and determining the second information as target information when the first image contains the second information and the second information is not displayed in the first image in a forward orientation. The first information and the second information are of different types.
[0017] In this embodiment, the electronic device can preset multiple information classes, including first information and second information. These information classes can include, but are not limited to, information classes that can clearly determine the forward display direction, such as faces, text, plants, and buildings. The priority set for each information class of the electronic device (the order of priority indicates the probability that the information of this class may be of interest to the user) is different, with the priority of the first information being greater than that of the second information.
[0018] After receiving the first operation to rotate the first image, the electronic device can detect whether the information class of each type exists in the first image according to the priority of each information class. If the information class corresponding to the information class is not successfully detected, the device will then detect the information class of the next priority, until the information corresponding to a certain information class is successfully detected in the first image. If the information is not displayed in the first image in a positive orientation, then the information is identified as the target information. Understandably, performing hierarchical detection of the image based on the priority of each type of information can, as far as possible, combine the display direction of the information most likely to be of interest to the user in the image to determine the rotation angle of the image, so that the final display direction of the image is as close as possible to the user's expectations.
[0019] Optionally, the first information mentioned above can be facial information, and the second information mentioned above can be text information.
[0020] In conjunction with the first aspect, in one possible implementation, the above method further includes: determining a preset angle as a target rotation angle when the first image does not contain first information and the first image does not contain second information.
[0021] Similarly, in this embodiment, the electronic device can preset multiple information classes, including first information and second information. These information classes can include, but are not limited to, information classes that can clearly determine the forward display direction, such as faces, text, plants, and buildings. The priority set for each information class of the electronic device (the order of priority indicates the probability that the information of this class may be of interest to the user) is different. The priority of the first information is higher than that of the second information, and the second information is the information class with the lowest priority among the above multiple information classes.
[0022] Understandably, if the first image does not contain the first information and the second information, it means that the electronic device has detected the information contained in the first image according to the priority of the aforementioned multiple information classes, but still has not detected any information that can serve as target information (specifically, it may be that the first image does not contain information belonging to any of the aforementioned multiple information classes, or that the first image does not contain information belonging to one or more of the aforementioned multiple information classes that is already displayed in the first image). Therefore, the electronic device cannot determine the aforementioned target rotation angle based on the content of the first image. However, considering that the user has still performed the aforementioned first operation on the electronic device, it indicates that the user currently intends to change the display direction of the first image. Therefore, in this case, the electronic device can no longer determine the rotation angle of the image based on the image content, but directly rotate the image by a fixed angle in a fixed manner according to the original default method of the electronic device (i.e., the aforementioned preset angle). In this way, the electronic device can still respond to the user's rotation operation on the image and rotate the image accordingly, avoiding the aforementioned first operation being an invalid operation, and ensuring the interaction efficiency between the user and the electronic device to a certain extent.
[0023] In conjunction with the first aspect, in one possible implementation, the target information includes n pieces of information, where any two pieces of information are of different types. The first display direction includes the display direction of each of the n pieces of information in the first image, and the second display direction includes the display direction of each of the n pieces of information when it is displayed in the forward direction. The rotation angle corresponding to any piece of information is the angle formed by the display direction of that piece of information in the first image and the display direction of that piece of information when it is displayed in the forward direction. Determining the target rotation angle based on the first display direction and the second display direction includes: determining the target rotation angle based on the rotation angle and weight corresponding to each piece of information in the n pieces of information.
[0024] As explained above, when an image contains a large amount of information, all of its various types of information may be of interest to the user. Therefore, in this embodiment, the target information may include n pieces of information belonging to n information classes, and corresponding weights are assigned to the n information classes. When the image is rotated, the electronic device can determine the rotation angle based on the display direction of each type of information in the image, and determine the target rotation angle from multiple rotation angles based on the weights corresponding to each information class.
[0025] Assume the above n information classes include face information, text information, and other information classes (each other information class corresponds to only one information class, such as plant information). The electronic device pre-sets the weights for these three information classes as Wface, Wword, and Wother, respectively. The electronic device provides five selectable rotation angles: 0°, 90°, 180°, 270°, and invalid (representing an invalid value). The angle formed by the display direction of face information in the first image and its orientation when displayed upright is the first rotation angle (degA). The angle formed by the display direction of text information in the first image and its orientation when displayed upright is the second rotation angle (degB). The angle formed by the display direction of other information in the first image and its orientation when displayed upright is the third rotation angle (degC). It is understood that degA, degB, and degC are all values from 0°, 90°, 180°, 270°, and invalid, and any two angle values in degA, degB, and degC can be the same or different. The electronic device will then assign the weight values Wface, Wword, and Wother to the three angle values degA, degB, and degC, respectively. Afterward, the electronic device can determine the total weight value from the five angle values: 0°, 90°, 180°, 270°, and invalid. If the angle value with the largest total weight value is neither 0° nor invalid, the electronic device can determine this angle value as the target angle; otherwise, it can directly determine the preset angle value as the target rotation angle.
[0026] For example, assuming the electronic device presets the weights of three types of information—face, text, and other information—as follows: Wface, Wword, and Wother are 0.4, 0.35, and 0.25 respectively, and the first, second, and third rotation angles are 90°, 180°, and 180° respectively, then the electronic device will assign the weight value of 0.4 to the angle value of 90°, and assign the weight values of 0.35 and 0.25 to the angle value of 180°. Therefore, the total weight values obtained for the five angle values of 0°, 90°, 180°, 270°, and invalid are 0, 0.4, 0.6, 0, and 0 respectively. Based on the above explanation, since the total weight value of 0.6 corresponding to the angle value of 180° is the maximum value among 0, 0.4, 0.6, 0, and 0, and 0.6 is not 0, the electronic device will determine 180° as the target rotation angle.
[0027] Understandably, by combining the display orientation of various information types in the image to determine the rotation angle, and combining the weights corresponding to each information type to determine the target rotation angle from multiple rotation angles, the electronic device can determine the rotation angle of the image by comprehensively considering the display orientation of various information types that the user may be interested in, so that the display orientation of the rotated image is more likely to meet the user's expectations.
[0028] In conjunction with the first aspect, in one possible implementation, before determining the target rotation angle based on the first display direction and the second display direction, the method further includes determining whether the first operation is the first rotation operation on the first image; determining the target rotation angle based on the first display direction and the second display direction includes: if the first operation is the first rotation operation on the first image, determining the target rotation angle based on the first display direction and the second display direction.
[0029] It should be understood that if the first operation of the electronic device is the user's initial rotation operation on the first image, it means that after responding to the user's initial rotation operation, the rotation result of the electronic device based on faces, text, or other information in the image does not meet the user's expectations. In other words, the user cannot rotate the first image to the direction they expect through a single operation. In this case, even if the electronic device responds to the first operation and rotates the first image again based on faces, text, or other information in the image, it is highly likely that it will not be able to directly rotate the first image to the direction the user expects.
[0030] Therefore, in this embodiment, after receiving the first operation, the electronic device can first determine whether the first operation is the first rotation operation on the first image. Only if the first operation is the first rotation operation on the first image will the electronic device detect the target information in the image and determine the target rotation angle based on the first display direction and the second display direction of the target information. In this way, the electronic device can avoid determining a meaningless target rotation angle based on the target information even if the first operation is not the first rotation operation on the first image, and can effectively reduce the invalid operations of the electronic device.
[0031] In conjunction with the first aspect, in one possible implementation, the method further includes: determining a preset angle as a target rotation angle if the first operation is not the first rotation operation on the first image.
[0032] It is important to understand that if the first operation of the electronic device is not the first rotation operation of the user's first image, even if the electronic device responds to the first operation and rotates the first image again based on faces, text, or other information in the image, it may still be unable to directly rotate the first image to the user's expected orientation. Therefore, in this embodiment, when the first operation is the user's first rotation operation on the first image, after the electronic device responds to the first operation, it may no longer rotate the image based on faces, text, or other information in the image, but instead rotate the first image according to a preset rotation angle. Even if the electronic device cannot rotate the first image to the user's expected orientation based on the image content, the user can still rotate the first image again in a fixed direction and at a fixed angle value through user operation until the user rotates the first image to the user's expected orientation through one or more subsequent operations.
[0033] Optionally, the preset angle can be 90°.
[0034] In a second aspect, this application provides an electronic device comprising: one or more processors and a memory; the memory being coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method of the first aspect or any possible implementation thereof.
[0035] Thirdly, this application provides a chip system applied to an electronic device, the chip system including one or more processors, the processors being configured to invoke computer instructions to cause the electronic device to perform the methods as described in the first aspect or any possible implementation thereof.
[0036] Fourthly, this application provides a computer program product containing instructions that, when the computer program product is run on an electronic device, cause the electronic device to perform the method as described in the first aspect or any possible implementation thereof.
[0037] Fifthly, this application provides a computer-readable storage medium including instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in the first aspect or any possible implementation thereof. Attached Figure Description
[0038] Figure 1 A schematic diagram illustrating a scene where the same image is rotated by different angles is provided for an embodiment of this application;
[0039] Figure 2This is a schematic diagram illustrating the process by which an electronic device adjusts the display orientation of an image, as provided in an embodiment of this application.
[0040] Figure 3 A schematic diagram illustrating a scenario where an electronic device rotates an image based on facial information, as provided in an embodiment of this application.
[0041] Figure 4 A flowchart illustrating an image processing method provided in an embodiment of this application;
[0042] Figure 5 A schematic diagram illustrating a scenario of rotating an image based on facial information, provided as an embodiment of this application;
[0043] Figure 6 This is a schematic diagram illustrating a scenario where an image is rotated based on text information, as provided in an embodiment of this application.
[0044] Figure 7 A flowchart illustrating an image processing method provided in an embodiment of this application;
[0045] Figure 8 This is a schematic diagram illustrating a scenario where an image is rotated based on its content, as provided in an embodiment of this application.
[0046] Figure 9 This is a schematic diagram illustrating a scenario where an image is rotated based on its content, as provided in an embodiment of this application.
[0047] Figure 10 A structural diagram of an electronic device provided in an embodiment of this application;
[0048] Figure 11 This is a schematic diagram of the software architecture of an electronic device provided in an embodiment of this application. Detailed Implementation
[0049] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0050] To facilitate understanding, the relevant terms involved in the embodiments of this application will be introduced below.
[0051] (1) Image rotation and rotation angle
[0052] In geometry, the transformation of a figure in a plane by rotating it around a fixed point O by a certain angle to obtain another figure is called rotation. The direction of rotation can be counterclockwise or clockwise. The fixed point around which the rotation occurs is called the center of rotation, and the angle of rotation is called the rotation angle. If point P on the figure becomes point P' after rotation, then these two points are called corresponding points of the rotation, and ∠POP' is the rotation angle.
[0053] Similarly, in electronic devices, the display screen is the plane on which the image is located. The image can be rotated by a certain angle around a fixed point on the display screen, changing its display orientation while keeping the image content unchanged. Understandably, the shape of an image displayed on an electronic device is generally rectangular. Therefore, in this application, when a user rotates an image through user operation, the rotation center of the image can be the center of the image (also called the centroid, i.e., the image is considered a rectangle, and the intersection of the two diagonals of the rectangle is the center of the rectangle).
[0054] Since the center of rotation of an image is its center, and based on basic geometry, if it is necessary to rotate an image around its center to a certain direction, the electronic device can do so by rotating the image clockwise or counterclockwise. For example, rotating the same image 90° clockwise around its center and rotating it 270° counterclockwise around its center achieve the same result. Therefore, in this application, for ease of explanation, we will use counterclockwise rotation as an example.
[0055] Furthermore, although the rotation angle of an image by an electronic device can be any value greater than 0, for ease of explanation and based on the premise that the image shape is rectangular, this application will use only four angle values—0°, 90°, 180°, and 270°—for example to illustrate the concept. It is understandable that if the image is originally displayed flat (i.e., when the image is viewed as a rectangle, two parallel sides are displayed horizontally, and the other two parallel sides are displayed vertically, the same applies below), rotating the image by any of the four angles—0°, 90°, 180°, or 270°—will still result in a flat display. Figure 1 The illustrations show scenarios where an electronic device rotates the same image counterclockwise by 0°, 90°, 180°, and 270° respectively. Figure 1As shown, Image 10 can be a flat image displayed on the screen of an electronic device, with the intersection of its two diagonals at point O1. Image 10 may display the letter "A". Images 11, 12, 13, and 14 are the images obtained after rotating Image 10 counterclockwise around point O1 by 0°, 90°, 180°, and 270°, respectively. From Images 11-14, it can be seen that by rotating the image at different angles, the orientation of the letter "A" in the image also changes. Taking Images 11 and 12 as examples, in Image 11, the tip of the letter "A" points upwards and the opening points downwards; while in Image 12, the tip of the letter "A" points to the left and the opening points to the right.
[0056] Understandably, for information that users might find interesting, such as text or faces, when such information is present in an image, there may be an angular deviation between the displayed orientation of this information and the user's expected orientation. This angular deviation not only disrupts the original intent of the image but also makes it difficult for the viewer to grasp the core information it is trying to convey, reducing the overall viewing experience. More seriously, in scenarios where precise information needs to be conveyed, incorrect orientation can lead to misunderstandings and distorted information delivery. In such cases, users may rotate the image to make these information elements appear upright (i.e., adjust the display orientation of the elements to the most common or frequently used orientation).
[0057] Taking the letter "A" contained in images 11-14 as an example, in image 11, the display direction of the letter "A" is the normal display direction of text, which is also the most conventional display direction of text (i.e., the tip of the letter "A" points upwards and the opening points downwards). However, in images 12-14, the display direction of the letter "A" deviates significantly from the most conventional display direction of text. Therefore, when any of the images 12-14 is displayed on an electronic device, the user may need to rotate the image to make the display direction of the rotated image the same as that of image 11, so that the user can better browse the text information in the image. For example, when an image contains facial information, if the face in the image is a frontal view including the eyes, nose, and mouth, and the eyes, nose, and mouth are displayed from top to bottom (i.e., the top of the person's head is facing upwards), then the face is displayed in the image in a positive orientation. When the face is not displayed in a positive orientation, the user may not be able to capture the key information contained in the face well. In this case, the user may need to rotate the image so that the face in the rotated image is displayed in a positive orientation, so that the user can better browse and analyze the facial information in the image.
[0058] To rotate the image, in this application, the electronic device can simultaneously display a rotation control while displaying the image. This rotation control responds to user input, causing the electronic device to rotate the displayed image around its center by a predetermined angle. Specifically, when the user's operation of the rotation control is the first time, the electronic device can respond to this operation by detecting information such as faces and text contained in the image, and rotating the image based on the direction of this information, so that the faces, text, and other information in the image are displayed facing forward. When the user's operation of the rotation control is not the first time, or when the rotation angle determined by the electronic device based on the face, text, and other information is 0 or empty, the electronic device can respond to this operation by rotating the displayed image counterclockwise around its center by a certain angle (e.g., 90°). Furthermore, each time the user clicks the rotation control subsequently, the electronic device will again rotate the currently displayed image counterclockwise around its center by the same angle (e.g., 90°). For details, please refer to the relevant descriptions in the following embodiments; they will not be repeated here.
[0059] (2) Thumbnail
[0060] A thumbnail is a smaller version of an image on an electronic device after compression. It usually contains a hyperlink to the full-size image. Common thumbnail file formats include gif, jpg, png, and bmp.
[0061] Because of their small size and extremely fast loading speed, thumbnails allow users to quickly browse images, serve as previews of the original image files, and act as an image directory. For example, when a user saves or takes a new image, the electronic device's gallery app automatically generates a small thumbnail. When the user browses images in the gallery app, the device can directly display the thumbnail corresponding to each image, allowing the user to preview multiple images simultaneously and easily find the image they need.
[0062] In this application, when an electronic device detects information such as faces and text in an image, the electronic device may not detect the original image, but instead detect the corresponding thumbnail. Since the thumbnail has smaller memory and size compared to the original image, detecting the corresponding thumbnail can effectively reduce the performance burden on the electronic device and improve the detection efficiency of the electronic device for information such as faces and text in the image.
[0063] With the development of electronic technology, electronic devices such as mobile phones and computers are equipped with applications for browsing or processing digital images. When users browse or process images through such applications, the image display orientation may not meet their expectations. Therefore, users need to rotate the image to adjust its orientation so that the content of interest in the image is displayed in the direction they expect.
[0064] Figure 2 This example illustrates the process by which a user adjusts the display orientation of an image on an electronic device.
[0065] like Figure 2 As shown in (A), the electronic device displays user interface 21 at this time. User interface 21 may include image 211 and function control bar 212, wherein:
[0066] Image 211 may include facial information 211a. In user interface 21, the top of the face in image 211 is facing to the right, which, as can be seen from the foregoing description, means that the face is not displayed facing forward.
[0067] The function control bar 212 may include multiple function controls. Among them, the rotation control 212a is used to rotate the image 211 in a specified direction by a fixed angle (here assumed to be a 90° counterclockwise rotation), and the center of rotation around which the image 211 rotates is the center of the image 211; the edit control 212b allows the user to edit the image 211, such as cropping, blurring, and annotating the image 211; the text recognition control 212c is used to recognize and extract text from the image 211; the forward control 212d is used to forward the image 211; the save control 212e is used to download and save the image 211 to the electronic device if the electronic device has not yet saved the image 211, such as saving it to the image library of the electronic device; the expand control is used to display more function controls 212f provided for the image 211, such as a transfer control to transfer the image 211 to a user-specified storage location, a copy control to copy the image 211, etc. Any function control in the function control bar 212 can respond to user operations, such as click operations, so that the electronic device can perform the corresponding function for the image 211.
[0068] As explained above, when displaying user interface 21, because the face is not displayed facing forward, it may make it difficult for the user to capture key facial information. Therefore, as... Figure 2 As shown in (A), in response to a user's click on the rotation control 212a, the electronic device can rotate the image 211 90° counterclockwise around the center of the image 211 and display it as shown in Figure 212. Figure 2 User interface 22 is shown in (B) above. Figure 2 As shown in (B), the user interface 22 may include an image 221 and a function control bar 212, wherein:
[0069] The function control bar 212 is the function control bar 212 in the aforementioned user interface 21. It may include multiple function controls. For details, please refer to the aforementioned description of the function control bar 212. It will not be repeated here.
[0070] Image 221 is the image obtained by rotating image 211 counterclockwise by 90° around its center. Similarly, image 221 can also include facial information 221a. Accordingly, facial information 221a is obtained by rotating facial information 211a in image 211 counterclockwise by 90°, so the face corresponding to facial information 221a in image 221 has its head facing upwards. Combined with the foregoing explanation, it can be seen that the face is now displayed facing forward, and the display direction of the face is more in line with the user's browsing habits, making it easier for the user to capture facial information in the image.
[0071] from Figure 2 As shown in (A) and (B), a single click on the rotation control is sufficient to orient the face in the image. However, current electronic devices rotate the image by a fixed angle in a fixed direction with each click. For example, as explained above, each click rotates the image 90° counterclockwise. Therefore, if information of interest to the user, such as faces or text, is not oriented, multiple clicks on the rotation control may be required to orient the information correctly. Please refer to [link / reference needed]. Figure 2 (C)-(F) in the middle.
[0072] like Figure 2 As shown in (C), the electronic device displays a user interface 23. The user interface 23 may include an image 231 and a function control bar 232, wherein:
[0073] Image 231 may include facial information 231a. From Figure 2 As can be seen from (C), the face in image 231 is not displayed upright at this time. However, unlike... Figure 2 Image 211, shown in (A), shows a face in image 231 with the top of the head facing left.
[0074] The function control bar 232 may include multiple function controls. The specific functions of each control can be referred to in the previous description of the function control bar 212, and will not be repeated here.
[0075] Similarly, since the face in image 231 is not displayed in a forward orientation, the user needs to rotate image 231 using the rotation control 232a in the function control bar 232 so that the face in it is displayed in a forward orientation.
[0076] Specifically, such as Figure 2 As shown in (C), in response to the user's first click on the rotation control 232a, the electronic device can rotate the image 231 counterclockwise by 90° around the center of the image 231 and display it as shown in (C). Figure 2 User interface 24 is shown in (D).
[0077] like Figure 2 As shown in (D), the user interface 24 may include an image 241 and a function control bar 232. The function control bar 232 is the same as the function control bar 232 in the aforementioned user interface 23, as detailed in the previous explanation; it will not be repeated here or in subsequent descriptions. The image 241 is the image obtained by rotating the image 231 counterclockwise by 90° around its center, and it may contain facial information 241a. Understandably, corresponding to the rotation of the image 231, the top of the face corresponding to the facial information 241a is facing downwards. As explained above, the face in the image 241 is still not displayed upright. Therefore, the user needs to rotate the image 241 again using the rotation control 232a in the function control bar 232 to make the face displayed upright.
[0078] like Figure 2 As shown in (D), in response to a second click of the rotation control 232a by the user, the electronic device can rotate the image 241 counterclockwise by 90° around the center of the image 241 and display it as shown in (D). Figure 2 User interface 25 is shown in (E) in the image.
[0079] like Figure 2 As shown in (E), the user interface 25 may include an image 251 and a function control bar 232. The image 251 is the result of rotating the image 241 counterclockwise by 90° around its center, and it may contain facial information 251a. Understandably, corresponding to the rotation of image 241, the top of the face corresponding to facial information 251a faces to the right. As explained above, the face in image 251 is still not displayed upright. Therefore, the user needs to rotate image 251 again using the rotation control 232a in the function control bar 232 to make the face displayed upright.
[0080] like Figure 2 As shown in (E), in response to the user's third click on the rotation control 232a, the electronic device can rotate the image 251 counterclockwise by 90° around the center of the image 251 and display it as shown in (E). Figure 2 User interface 26 is shown in (F).
[0081] like Figure 2As shown in (F), the user interface 26 may include an image 261 and a function control bar 232. The image 261 is the image obtained by rotating the image 251 counterclockwise by 90° around its center, and it may contain facial information 261a. Understandably, corresponding to the rotation of the image 251, the top of the face corresponding to the facial information 261a is facing upwards. Combined with the foregoing description, it can be seen that the face is now displayed facing forward in the image 261, and the display direction of the face conforms to the user's browsing habits, which is beneficial for the user to capture facial information in the image.
[0082] from Figure 2 As can be seen from (C)-(F), since each time the user clicks the rotation control, the image can only be rotated by the same angle in a fixed direction, in some cases, the user may need to perform multiple operations on the rotation control to adjust the information of interest to the user in the image to be displayed in the correct orientation. This makes the interaction between the user and the electronic device inefficient and seriously affects the user's browsing experience of the image.
[0083] To address the shortcomings of the aforementioned methods, this application provides an image processing method. Implementing this method, after receiving a user's operation to rotate an image, the electronic device can determine the image's rotation angle based on the display orientation of information such as faces and text within the image, and rotate the image based on the determined rotation angle, ensuring that information such as faces and text is displayed facing forward on the screen. In this way, users can easily rotate images to their desired orientation with a simple operation, effectively improving the interaction efficiency between the user and the electronic device while ensuring a good image browsing experience.
[0084] Figure 3 An example is shown of an electronic device determining the rotation angle of an image based on facial information in the image, and rotating the image based on the determined rotation angle after receiving a user's rotation operation on the image.
[0085] Here, it is also assumed that the electronic device rotates the image counterclockwise. For example... Figure 3 As shown in (A), the electronic device displays user interface 31 at this time. User interface 31 can be an image browsing interface provided by a gallery application on the electronic device, or it can be a social application (e.g., ...) on the electronic device. The interface displayed by the electronic device after clicking on an image in the message browsing interface provided can also be the interface provided by any other application installed on the electronic device that can be used to browse or edit digital images; this application does not limit this. The user interface 31 may include an image 311 and a function control bar 312. The image 311 is the original image (not a thumbnail), which may include facial information 311a. In the user interface 31, the top of the face in the image 311 faces to the left; the face is not displayed facing forward. The function control bar 312 may include multiple function controls, as detailed above. Figure 2 The relevant explanations will not be repeated here.
[0086] As explained above, when a face is not displayed correctly on the screen, the user can rotate the image using the rotation control 12a in the function control bar 312. Understandably, if the image is rotated counter-clockwise, to make the face in image 311 appear correctly, image 311 needs to be rotated 270° counter-clockwise. Therefore, as... Figure 3 As shown in (A), when the user clicks the rotation control 312a in the function control bar 312 for the first time, the electronic device can determine the corresponding rotation angle deg1 = 270° (counterclockwise rotation) between the current display direction and the forward display direction, based on the face information 311a corresponding to the current display direction of the face. If the current display direction is not forward, the electronic device can then rotate the image 311 counterclockwise by deg1 = 270° and display it as shown in (A). Figure 3 The user interface 32 shown in (B) is shown in the image.
[0087] like Figure 3 As shown in (B), the user interface 32 may include an image 321 and a function control bar 312. The image 321 is the image obtained by rotating image 311 counterclockwise by deg1 = 270° around its center, and it may contain facial information 321a. Understandably, corresponding to the rotation of image 311, the top of the face corresponding to facial information 321a faces upwards. Combined with the foregoing explanation, it can be seen that the face is now displayed facing forward in image 321, and the display direction of the face conforms to the user's browsing habits, which is beneficial for the user to capture facial information in the image. Understandably, if according to the aforementioned... Figure 2The image processing logic shown in the previous example states that each time the user clicks the rotation control, the electronic device rotates the currently displayed image 90° counterclockwise. Therefore, the user would need to click the rotation control at least three times to rotate the display direction of image 311 counterclockwise by 270°. However, in this application, the user only needs to click the rotation control 312a once to rotate image 321 by 270°, so that the face in image 321 is displayed face-up on the screen of the electronic device, effectively reducing user operations.
[0088] Similarly, when a face in an image is displayed on the screen in a direction different from that shown in image 321 (non-frontal display), the electronic device can rotate the image according to the determined rotation angle by the current display direction and the frontal display direction of the face. However, the user can rotate the image according to the determined rotation angle by a single click of the rotation control so that the face in the image is displayed on the screen in a frontal position.
[0089] like Figure 3 As shown in (C), the electronic device displays user interface 33 at this time. User interface 33 may include image 331 and function control bar 312. Among them, image 331 is the original image (not a thumbnail), which may include facial information 331a. In user interface 33, the face in image 331 is facing downwards, and the face is not displayed in a forward-facing position.
[0090] As explained above, when a face is not displayed correctly on the screen, the user can rotate the image using the rotation control 312a in the function control bar 312. Understandably, if the image is rotated counter-clockwise, to make the face in image 311 appear correctly, image 331 needs to be rotated 180° counter-clockwise. Therefore, as... Figure 3 As shown in (C), when the user clicks the rotation control 312a in the function control bar 312 for the first time, the electronic device can determine the rotation angle deg2 = 180° (counterclockwise rotation), and after rotating the image 311 counterclockwise by deg2 = 180°, it will be displayed as shown. Figure 3 The user interface 34 is displayed in (D).
[0091] like Figure 3 As shown in (D), the user interface 34 may include an image 341 and a function control bar 312. The image 341 is the image obtained by rotating the image 331 counterclockwise by deg2 = 180° around its center, and it may contain facial information 341a. Understandably, corresponding to the rotation of the image 331, the top of the face corresponding to the facial information 341a is facing upwards, and the face is now displayed positively in the image 341. Similarly, according to the aforementioned... Figure 2The image processing logic shown in the figure requires the user to click the rotation control at least twice to rotate the display direction of image 331 counterclockwise by 180°; however, in this embodiment, the user only needs to click the rotation control 312a once to rotate image 331 by 180°.
[0092] In other words, if the initially displayed image contains information with a clear orientation (such as faces, text, etc.), and if this information is not displayed in the initial image, then after the user performs an operation to rotate the image (such as clicking a rotation control), the electronic device can adaptively determine the rotation angle of the image based on the display orientation of this information in the original image. Compared to methods that rotate the image by a fixed angle in a fixed direction every time a user performs a rotation operation, the image processing method provided in this application can more efficiently rotate the image to the user's expected display orientation for display, effectively improving the interaction efficiency between the user and the electronic device while ensuring the user's image browsing experience.
[0093] In this embodiment, when the electronic device displays user interface 31 and user interface 32, image 311 can be referred to as "first image," facial information 311a in image 311 can be referred to as "target information," and the user's click operation on the rotation control 312a in user interface 31 can be referred to as "first operation." The display direction of facial information 311a in image 311 (i.e., the display direction with the top of the head facing left) can be referred to as "first display direction," and the display direction of facial information 321a in image 321 (i.e., the display direction with the top of the head facing upward) can be referred to as "second display direction." The counterclockwise rotation angle deg1 of image 311 can be referred to as "target rotation angle."
[0094] When the electronic device displays user interface 33 and user interface 34, image 331 can be referred to as the "first image," facial information 331a in image 331 can be referred to as "target information," and the user's click operation on the rotation control 312a in user interface 33 can be referred to as the "first operation." The display direction of facial information 331a in image 331 (i.e., the display direction with the top of the head facing left) can be referred to as the "first display direction," and the display direction of facial information 341a in image 341 (i.e., the display direction with the top of the head facing upward) can be referred to as the "second display direction." The counterclockwise rotation angle deg2 of image 331 can be referred to as the "target rotation angle."
[0095] Next, combine Figure 4 The flowchart of the image processing method provided in this application is introduced.
[0096] First, it should be noted that the electronic device used to execute the image processing method provided in the embodiments of this application can be a mobile phone, tablet computer, computer with data transceiver function (such as a laptop computer, PDA, etc.), vehicle-mounted device (such as an on-board unit (OBU)), mobile internet device (MID), terminal in industrial control, terminal in smart city, terminal in smart home, terminal device in 5G network, or terminal device in future evolved public land mobile network (PLMN), etc. Specifically, the above-mentioned electronic device can be... Figure 3 The electronic device shown is not limited to any particular form of the device. Any electronic device capable of displaying digital images can be used to perform the image processing method provided in this application.
[0097] Furthermore, in this embodiment, the electronic device categorizes the information that may exist in the image. Specific categories may include, but are not limited to, information categories with a clear forward display direction, such as faces, text, houses, and plants. Additionally, the electronic device assigns different priorities to each information category. When detecting information in the image, the electronic device can detect the corresponding type of information in the image in an orderly manner according to the priority of each information category. For ease of explanation, this embodiment uses the information categories including faces, text, and other information, and follows the priority order of faces > text > other information. After receiving a user's rotation operation on the image, the electronic device will sequentially determine whether faces, text, and other information exist in the image according to the aforementioned priority order. When any one of these three types of information is successfully detected, the electronic device can determine the rotation angle of the image based on the display direction of that information. If the rotation angle is not 0, the image is rotated according to that rotation angle; otherwise, the electronic device will continue to detect the next type of information.
[0098] like Figure 4 As shown, the image processing method provided in this application may include, but is not limited to, the following steps:
[0099] S101, The user's first action was detected.
[0100] The first operation described above is used to rotate the first image. The electronic device detects this first operation and determines that the user currently has a need to rotate the first image.
[0101] Optionally, the first image can be an image from an application on the electronic device used for storing and managing images (e.g., a gallery), or it can be an image cached by the electronic device from other applications (e.g., existing in an application). Images can be viewed in chat messages or by users, or they can be obtained from any other application installed on an electronic device that can be used to view or edit digital images; this application does not limit this.
[0102] Optionally, the first operation can be a user's click on the rotation control; wherein, upon detecting the first operation, the rotation control can be displayed on the same interface as the first image. Optionally, in some embodiments, the first operation can also be a voice command type operation, for example, the user can issue a voice command "rotate image" to the electronic device to enable the electronic device to determine the user's rotation request for the image. Optionally, in some embodiments, the first operation can also be other types of operations, such as a double-click operation on the image, or a pinch-to-rotate operation, which is not limited in this application.
[0103] S102. Determine whether this is the first rotation of the first image.
[0104] That is, to determine whether the first operation mentioned above is the user's first rotation operation on the first image.
[0105] If the first operation is the user's first rotation operation on the first image, the electronic device executes step S103; otherwise, the electronic device may skip the subsequent steps S103-S115 and directly execute the subsequent step S116.
[0106] It should be understood that the method provided in this application aims to allow users to rotate an image to the user's desired orientation with a single operation. If the aforementioned first operation is not the user's first rotation operation on the first image, it means that after responding to the user's first rotation operation on the image, the rotation result of the electronic device based on faces, text, or other information in the image does not meet the user's expectations; that is, the user cannot rotate the first image to the user's desired orientation with a single operation. In this case, even if the electronic device responds to the aforementioned first operation and rotates the first image again based on faces, text, or other information in the image, it is highly unlikely that it can directly rotate the first image to the user's desired orientation. Therefore, when the aforementioned first operation is the user's first rotation operation on the first image, after the electronic device responds to the aforementioned first operation, the electronic device may no longer rotate the image based on faces, text, or other information in the image, but instead rotate the first image according to a preset rotation angle (e.g., a 90° counterclockwise rotation). That is, the electronic device can skip the subsequent steps S103-S115, and determine the target rotation angle according to the preset rotation angle, and then directly execute step S116.
[0107] S103. Detect facial information in the first image.
[0108] S104. Determine whether the first image contains a human face.
[0109] In the case where the first operation is the user's first rotation operation on the first image, the electronic device can first detect the facial information in the first image.
[0110] If the first image contains facial information, the electronic device executes the subsequent step S105. Otherwise, the electronic device may skip steps S105-S106 and directly execute the subsequent step S107. In other words, when facial information exists in the first image, the electronic device can determine that this facial information is most likely the information the user is interested in within the first image, and the user's rotation of the first image may actually be intended to display the face corresponding to that facial information facing forward on the electronic device's screen. When facial information does not exist in the first image, the electronic device can determine that other information of interest to the user exists in the image. Based on the aforementioned priority order of information types, the electronic device can further detect whether text information exists in the image.
[0111] S105. Determine the first rotation angle based on the display direction of the face.
[0112] When the first image contains a human face, the electronic device can first determine the rotation angle of the first image during the process of rotating the human face in the first image to be displayed on the screen in a positive direction, based on the display orientation of the human face in the first image. This first rotation angle is the aforementioned first rotation angle.
[0113] Optionally, after detecting facial information, the electronic device can determine several key points corresponding to the face in the first image, and based on the relative positional relationship between all or some of these key points, determine the rotation angle of the first image when the facial image is displayed facing forward. For example, the electronic device can determine the first selected rotation angle based on the angle formed by the line connecting the left and right eyes on the face and the upper (or lower) edge of the display screen. Figure 3 Taking (A) as an example, assuming image 311 is the first image mentioned above, the top of the face in the current first image faces left, so the first rotation angle is a counterclockwise rotation of 270° around the center. Let's take... Figure 3 Taking (B) as an example, assuming that image 331 is the first image mentioned above, the top of the face in the current first image is facing down, and the first rotation angle is a counterclockwise rotation of 180° from the center.
[0114] Optionally, when the first image contains multiple faces, the electronic device can determine the target face based on the area of each face in the first image, identifying the face with the largest area, and determining the first rotation angle based on the display direction of the target face. Alternatively, the electronic device can determine the target face based on the distance (e.g., Manhattan distance) between the center point of each face and the center of the first image, identifying the face closest to the center point of the first image, and determining the first rotation angle based on the display direction of the target face.
[0115] S106. Determine if the first rotation angle is 0.
[0116] If the first rotation angle is not 0, the electronic device may skip the subsequent steps S107-S115 and directly execute the subsequent step S116; otherwise, the electronic device will directly execute the subsequent step S107.
[0117] Understandably, if the first rotation angle determined by the electronic device is not 0, it means that the face in the first image is not currently displayed face-up on the screen of the electronic device. In this case, the electronic device can determine that the user's rotation operation on the first image is intended to display the face in the first image face-up on the screen. Therefore, in this situation, the electronic device can directly determine the first rotation angle as the target rotation angle and directly execute the subsequent step S116.
[0118] Correspondingly, if the first rotation angle determined by the electronic device is 0, it indicates that the face in the first image is already displayed facing forward. However, if the user still performs the aforementioned first operation on the electronic device even though the face is already displayed facing forward, it means that in addition to the face, there is other information of interest to the user in the first image (such as text), and the user's rotation operation on the first image is actually to rotate this part of the information. Therefore, according to the aforementioned priority order of information types, the electronic device can further detect whether there is text information in the image.
[0119] S107. Detect text information in the first image.
[0120] S108. Determine whether the first image contains text.
[0121] If the first image does not contain facial information, or if the first rotation angle is 0, the electronic device can further detect text information in the first image.
[0122] If the first image contains text information, the electronic device executes subsequent step S109. Otherwise, the electronic device may skip subsequent steps S109-S110 and directly execute subsequent step S111. In other words, when the first image contains text information, the electronic device can determine that the text information is most likely information of interest to the user in the first image, and the user's rotation of the first image may actually be intended to display the corresponding text information in a positive orientation on the electronic device's screen. When the first image does not contain text information, the electronic device can determine that other information of interest to the user exists in the image. Based on the aforementioned priority order of information types, the electronic device can further detect whether other types of information exist in the image.
[0123] S109. Determine the second rotation angle based on the text display direction.
[0124] When the first image contains text, the electronic device can determine the rotation direction of the first image during the process of rotating the text in the first image to be displayed in the positive direction on the display screen, which is the second rotation angle mentioned above, based on the display direction of the text in the first image.
[0125] Optionally, when there are multiple regions containing text information in the first image, the electronic device can determine the text in the region with the largest area as the target text based on the area of each region in the first image, and determine the aforementioned second rotation angle based on the display direction of the target text. Alternatively, the electronic device can determine the text in the region closest to the center point of the first image as the target text based on the distance (e.g., Manhattan distance) between the center point of each region containing text and the center of the first image, and determine the aforementioned second rotation angle based on the display direction of the target text.
[0126] Optionally, there are significant up-and-down differences in the directions of the strokes of the text. The electronic device can determine the display direction of the text in the first image by judging the mural orientation of the text in the image and the up-and-down structure of the text. For example, assume that there are Chinese characters such as "家" and "票" in the first image. Since the up-and-down structures of such characters will change significantly after being inverted or tilted, and the directions of the strokes containing left-falling and right-falling strokes in these characters have significant up-and-down differences, and the up-and-down structures and the directions of the strokes of these characters are fixed within a certain standard range when displayed upright, the electronic device can determine the above-mentioned second rotation angle by analyzing the stroke direction and the up-and-down structure of the characters in the first image and the standard range corresponding to the up-and-down structure and the stroke direction of the characters when displayed upright.
[0127] Taking the above Figure 1 as an example, assume that Image 12 is the above-mentioned first image. If the tip of the letter "A" in the current first image points to the left and the opening points to the right, the second rotation angle is a 270° counterclockwise central rotation; similarly, assume that Image 13 is the above-mentioned first image. If the tip of the letter "A" in the current first image points downward and the opening points upward, the second rotation angle is a 180° counterclockwise central rotation (the specific display style of the final image can refer to Image 11 or Image 10).
[0128] S110. Determine whether the second rotation angle is 0.
[0129] When the second rotation angle is not 0, the electronic device may not perform the subsequent steps S111 - S115, but directly perform the subsequent step S116; otherwise, the electronic device may directly perform the subsequent step S111.
[0130] It can be understood that if the second rotation angle determined by the electronic device is not 0, it means that the text in the first image is not currently displayed upright on the display screen of the electronic device. Then the electronic device can determine that the user's current rotation operation on the first image is to display the text in the first image upright on the display screen. Therefore, in this case, the electronic device can directly determine the second rotation angle as the target rotation angle and directly perform the subsequent step S116.
[0131] Correspondingly, if the second rotation angle determined by the electronic device is 0, it means that the text in the first image is already displayed upright. Similarly, when the face is already displayed upright and the user still performs the above-mentioned first operation on the electronic device, it means that there is other information of interest to the user in the first image in addition to the face and the text (for example Figure 3The user's rotation operation on the first image is actually to rotate this other type of information. Therefore, according to the priority of the aforementioned information classes, the electronic device can further detect whether there is other type of information in the image.
[0132] S111, Detect other class information in the first image.
[0133] S112. Determine whether the first image contains other types of information.
[0134] Even if the first image does not contain facial or text information, or if the first rotation angle is 0 and the second rotation angle is also 0, or if the first rotation angle is 0 and the first image does not contain text information, the electronic device can further detect other types of information in the first image.
[0135] If the first image contains other types of information, the electronic device executes the subsequent step S113. Otherwise, the electronic device may skip steps S113-S114 and directly execute the subsequent step S115. In other words, when other types of information exist in the first image, the electronic device can determine that this other type of information is most likely the information the user is interested in within the first image. The user's rotation of the first image may actually be intended to display the text corresponding to this other information in a forward orientation on the electronic device's screen. When no other types of information exist in the first image, the electronic device may not rotate the image based on faces, text, or other types of information, but instead rotate the first image according to a preset rotation angle (e.g., a 90° counter-clockwise rotation).
[0136] The types of information included in the aforementioned "other information" categories can be predefined by the electronic device. Optionally, the aforementioned "other information" categories may include one or more of the following: building information, plant information, animal information, etc. Understandably, when there are multiple types of information included in the aforementioned "other information" categories, the electronic device may also set a priority order for these information according to specific categories, and sequentially detect whether the information corresponding to these categories exists in the first image, following the detection order for faces and text as described above. For example, assuming that the other types of information mentioned above only include information on two categories: buildings and plants, and the electronic device has a higher priority for buildings than for plants; then the electronic device can first detect whether there are buildings in the first image. If there are, it can directly execute the subsequent step S113 (i.e., determine the third rotation angle based on the display direction of the building); otherwise, the electronic device can further detect whether there are plants in the image. If there are, it can directly execute the subsequent step S113 (i.e., determine the third rotation angle based on the display direction of the plant); otherwise, if the electronic device determines that there are no other types of information in the first image, then the electronic device can rotate the image without rotating it based on faces, text, or other types of information in the image, but instead rotate the first image according to a preset rotation angle of the electronic device (e.g., rotate 90° counterclockwise).
[0137] S113. Determine the third rotation angle based on the display direction of other types of information.
[0138] When the first image contains other types of information, the electronic device can determine the rotation angle of the first image during the process of rotating the other types of information in the first image to be displayed in the positive direction on the display screen, which is the aforementioned third rotation angle, based on the display orientation of the other types of information.
[0139] Optionally, after detecting other types of information, the electronic device can also determine several key points corresponding to the other types of information in the first image. Understandably, when other types of information are displayed in the forward direction, the lines or shapes formed by all or some of these key points will exhibit a specific relationship (for example, the line between two points will be parallel to the top and bottom edges of the display screen). Therefore, the electronic device can also determine the rotation angle of the first image when other types of information are displayed in the forward direction, i.e., the third rotation angle from the top, based on the relative positional relationship between all or some of these key points.
[0140] Optionally, when multiple other types of information exist in the first image (all of these other types of information belong to the same category, such as all plants or all buildings), the electronic device can determine the other type of information with the largest area as the target other type of information based on the area of each other type of information in the first image, and determine the aforementioned second rotation angle based on the display direction of the target other type of information. Alternatively, the electronic device can determine the other type of information closest to the center point of the first image as the target other type of information based on the distance (e.g., Manhattan distance) between the center point of each other type of information and the center of the first image, and determine the aforementioned third rotation angle based on the display direction of the target other type of information.
[0141] S114. Determine if the third rotation angle is 0.
[0142] If the third rotation angle is not 0, the electronic device may skip step S115 and directly execute step S116; otherwise, the electronic device may directly execute step S115.
[0143] Understandably, if the third rotation angle determined by the electronic device is not 0, it means that other types of information in the first image are not displayed face-up on the screen of the electronic device. In this case, the electronic device can determine that the user's rotation operation on the first image is for displaying other types of information in the first image face-up on the screen. Therefore, in this case, the electronic device can directly determine the third rotation angle as the target rotation angle and directly execute the subsequent step S116.
[0144] Correspondingly, if the second rotation angle determined by the electronic device is 0, it means that other types of information in the first image have been displayed in the forward direction. Similarly, if the user still performs the first operation mentioned above on the electronic device when the face is already displayed in the forward direction, the electronic device may no longer determine the display direction of the image based on the image content, but instead rotate the first image according to the fixed rotation direction and rotation angle preset by the electronic device (for example, rotate 90° counterclockwise).
[0145] Optionally, when the electronic device detects faces, text, and other types of information in the first image, the electronic device may not directly detect the original image of the first image, but instead detect the thumbnail of the first image, in order to reduce the power consumption of the electronic device and improve the detection efficiency.
[0146] S115. Determine the fourth rotation angle based on the preset fixed angle.
[0147] The aforementioned fourth rotation angle is a preset fixed angle for the electronic device. Optionally, the fourth rotation angle can be a 90° counterclockwise rotation of the center.
[0148] S116. Rotate the first image according to the target rotation angle.
[0149] As can be seen from the foregoing description, the target rotation angle may be any one of the first rotation angle, the second rotation angle, the third rotation angle, and the fourth rotation angle under different circumstances.
[0150] Specifically, when the electronic device successfully determines the first rotation angle and the first rotation angle is not zero, the target rotation angle is the first rotation angle; when the electronic device successfully determines the second rotation angle and the second rotation angle is not zero, the target rotation angle is the first rotation angle; when the electronic device successfully determines the third rotation angle and the third rotation angle is not zero, the target rotation angle is the third rotation angle; and when the electronic device successfully determines the fourth rotation angle, the target rotation angle is the fourth rotation angle.
[0151] Finally, the electronic device can rotate the first image according to the target rotation angle and display the resulting image on the screen.
[0152] Understandably, in this embodiment, the electronic device can detect information in an image that the user may be interested in according to a preset priority of information types. Until a certain type of information is successfully detected and its display orientation on the screen is not forward, the electronic device can determine that the image needs to be rotated to the angle corresponding to the forward display orientation of that type of information on the screen. Based on this rotation angle, the image is rotated, allowing the user to rotate the image to the desired orientation with a single operation, effectively reducing the user's image rotation operations and improving the interaction efficiency between the user and the electronic device. Furthermore, by performing hierarchical detection of the image based on the priority of various types of information, the rotation angle of the image can be determined by combining the display orientation of the information most likely to be of interest to the user, ensuring that the final display orientation of the image matches the user's expectations as closely as possible.
[0153] Figure 5 and Figure 6 An example shows an electronic device according to Figure 4 The image processing method shown herein rotates the image in a specific way. For ease of explanation, in this embodiment, when the electronic device detects information in the image, the priority order is also taken as face > text > other types of information.
[0154] like Figure 5 As shown, image 501 contains facial information 501a and text information 501b. Combined with... Figure 5 As can be seen from the foregoing description, neither the face information 501a nor the text information 501b is displayed in the positive orientation in image 501.
[0155] To display the face in image 501 facing forward, image 501 needs to be rotated 180° counterclockwise to obtain image 511. Image 511 contains face information 511a and text information 511b. In image 511, the face corresponding to face information 511a is displayed facing forward, but the text corresponding to text information 511b is still not displayed facing forward.
[0156] To display the text in image 501 in the correct orientation, image 501 needs to be rotated 270° counterclockwise to obtain image 512. Image 512 contains face information 512a and text information 512b. In image 512, the face corresponding to face information 512a is still not displayed in the correct orientation, but the text corresponding to text information 512b is displayed in the correct orientation.
[0157] In other words, simply rotating image 501 cannot simultaneously make the faces and text it contains display in the correct orientation.
[0158] In combination with the above Figure 4 According to the relevant description, when the electronic device displays image 501, if the user rotates the image, the electronic device can first detect the face information in image 501, and determine the rotation angle corresponding to rotating image 501 to the face-facing position based on the display direction of the face in image 501, and rotate image 501 based on the rotation angle, and finally display image 511 on the display screen.
[0159] like Figure 5 As shown in (A), the electronic device displays a user interface 50. The user interface 50 may include an image 501 and a function control bar 502. When the user first clicks the rotation control 502a in the function control bar 502, the electronic device can detect that the image 501 contains facial information 501a, and based on the display direction of the face corresponding to the facial information 501a, determine the rotation angle deg3 = 270° (counter-clockwise rotation) corresponding to rotating the image 501 to the face-facing position. Since the rotation angle deg3 is not 0°, the electronic device will not detect text or other information in the image 501, but will directly determine the rotation angle deg3 = 270° as the target rotation angle, and after rotating the image 501 counter-clockwise by deg3 = 270°, display as shown in (A). Figure 5 The user interface 51 shown in (B) is shown in the image.
[0160] like Figure 5As shown in (B), the user interface 51 may include an image 511 and a function control bar 502. The image 511 is the image obtained by rotating the image 501 counterclockwise by deg3 = 270° around its center, and it may contain facial information 511a. Understandably, corresponding to the rotation of the image 501, the face corresponding to the facial information 511a is now displayed facing forward on the screen.
[0161] In this embodiment, image 501 can be referred to as "first image," facial information 501a in image 501 can be referred to as "first information," and text information 501b in image 501 can be referred to as "second information." Facial information 501a can be referred to as "target information," and the user's click operation on the rotation control 502a in the user interface 50 can be referred to as "first operation." The display direction of facial information 501a in image 501 (i.e., the head-down display direction) can be referred to as "first display direction," and the display direction of facial information 511a in image 511 (i.e., the head-up display direction) can be referred to as "second display direction." The counter-clockwise rotation angle deg3 of image 501 can be referred to as "target rotation angle."
[0162] Figure 6 This illustrates another scenario where an electronic device rotates an image according to the image processing method provided in this application.
[0163] like Figure 6 As shown, image 601 contains facial information 601a and text information 601b. Combined with... Figure 6 As can be seen from the foregoing description, in image 601, the face information 601a is displayed in the forward orientation, but the text information 601b is not displayed in the forward orientation.
[0164] To display the text in image 601 in the correct orientation, image 601 needs to be rotated 90° counterclockwise to obtain image 611. Image 611 contains face information 611a and text information 611b. In image 611, the face corresponding to face information 611a is still not displayed in the correct orientation, but the text corresponding to text information 611b is displayed in the correct orientation.
[0165] like Figure 6As shown in (A), the electronic device displays a user interface 60. The user interface 60 may include an image 601 and a function control bar 602. When the user first clicks the rotation control 602a in the function control bar 602, the electronic device can detect that the image 601 contains facial information 601a. Since the facial information 601a is already displayed facing forward in the image 601, the electronic device determines, based on the display direction of the face corresponding to the facial information 601a, that the rotation angle corresponding to rotating the image 601 to display the face facing forward is 0°. In this case, the electronic device will further detect the text information 601b in the image 601, and based on the display direction of the text corresponding to the text information 601b, determine the rotation angle deg4 = 90° corresponding to rotating the image 601 to display the text facing forward. Furthermore, since deg4 is not 0, the electronic device will directly determine the rotation angle deg4 = 90° as the target rotation angle, and after rotating the image 601 counterclockwise by deg4 = 90°, display as shown... Figure 5 The user interface 51 shown in (B) is shown in the image.
[0166] like Figure 6 As shown in (B), the user interface 61 may include an image 611 and a function control bar 602. The image 611 is the image obtained by rotating image 601 counterclockwise by deg4 = 90° around its center, and it may contain facial information 611a and text information 611b. Understandably, corresponding to the rotation of image 601, the text information 611b is already displayed facing forward on the screen.
[0167] In subsequent processes, if the user clicks the rotation control 602a again, the electronic device can determine that this is not the user's first operation on the rotation control 602a (i.e., the display direction of image 612 still does not meet the user's expectations). Therefore, the electronic device can no longer determine the image rotation angle based on the image content, but instead rotate the image by a fixed angle deg5 = 90°. Furthermore, each time the user clicks the rotation control 602a subsequently, the electronic device will rotate the currently displayed image by the fixed angle deg5 = 90°.
[0168] like Figure 6 As shown in (B), in response to the user's second click on the rotation control 602a, the electronic device can directly determine the preset fixed rotation angle deg5 = 90° as the target rotation angle, and after rotating the image 611 counterclockwise by deg5 = 90°, it displays as shown in (B). Figure 6 The user interface 62 is displayed in (C).
[0169] like Figure 6As shown in (C), the user interface 62 may include an image 621 and a function control bar 602. The image 621 is the image obtained by rotating the image 611 counterclockwise around the center by deg5 = 90°, and it may contain facial information 621a and text information 621b.
[0170] Similarly, such as Figure 6 As shown in (C), in response to the user's third click on the rotation control 602a, the electronic device will again directly determine the preset rotation angle deg5 = 90° as the target rotation angle, and after rotating the image 621 counterclockwise by deg5 = 90°, it will display as shown in (C). Figure 6 The user interface 63 is displayed in (D). The user interface 63 may include an image 631 and a function control bar 602. The image 631 is the image obtained by rotating the image 621 counterclockwise around the center by deg5 = 90°, and it may contain facial information 631a and text information 631b.
[0171] In this embodiment, image 601 can be referred to as "first image," facial information 501a in image 601 can be referred to as "first information," and text information 601b in image 601 can be referred to as "second information." Text information 601b can be referred to as "target information," and the user's click operation on the rotation control 602a in the user interface 60 can be referred to as "first operation." The display direction of text information 601b in image 601 can be referred to as "first display direction," and the display direction of text information 611b in image 611 can be referred to as "second display direction." The counter-clockwise rotation angle deg4 of image 601 can be referred to as "target rotation angle," and the counter-clockwise rotation angle deg5 of images 611 and 621 can be referred to as "preset angle."
[0172] As explained above, when an image contains a large amount of information, all types of information may be of interest to the user. Therefore, this application also provides an image processing method. Implementing this method, an electronic device can set different information classes and assign corresponding weights to each information class. When the image is rotated, the electronic device can determine the rotation angle based on the display orientation of each type of information in the image, and determine the target rotation angle from multiple rotation angles based on the weights corresponding to each information class. In this way, the electronic device can determine the image rotation angle by comprehensively considering the display orientation of various types of information that the user may be interested in, making the displayed orientation of the rotated image more likely to meet the user's expectations. For details, please refer to [link to relevant documentation]. Figure 7 .
[0173] Figure 7 This is a flowchart illustrating an image processing method provided in an embodiment of this application. Figure 7As shown, the image processing method may include, but is not limited to, the following steps:
[0174] S201, The user's first action was detected.
[0175] S202. Determine whether this is the first rotation of the first image.
[0176] The specific operations for steps S201-S202 can be referred to the aforementioned... Figure 4 The relevant explanations of steps S101-S102 are not repeated here.
[0177] It should be noted that, in this embodiment, when the electronic device determines that the first operation is the user's first rotation operation on the first image, the electronic device will necessarily execute subsequent steps S203, S207, and S211. Optionally, the electronic device can execute subsequent steps S203, S207, and S211 simultaneously, or it can execute subsequent steps S203, S207, and S211 sequentially in a certain order; this application does not limit this. That is, when the electronic device determines that the first operation is the user's first rotation operation on the first image, the electronic device will detect facial information, text information, and other types of information in the first image. When the electronic device determines that the first operation is not the user's first rotation operation on the first image, the electronic device can skip executing subsequent steps S203-S217 and directly execute subsequent step S218, that is, the electronic device can directly determine the fourth rotation angle (the fourth rotation angle is a preset fixed angle of the electronic device) as the target rotation angle.
[0178] S203. Detect facial information in the first image.
[0179] S204. Determine whether the first image contains a human face.
[0180] S205. Determine the first rotation angle based on the display direction of the face.
[0181] S206. Determine the first rotation angle as invalid.
[0182] The specific operations for steps S203-S205 can be referred to the aforementioned... Figure 4 The relevant explanations for steps S103-S105 are not repeated here.
[0183] It should be noted that, in this embodiment, when the electronic device determines that the first image contains a face, the electronic device determines a first rotation angle based on the display orientation of the face in the first image. This first rotation angle is the rotation angle of the first image during the process of rotating the face in the first image to be displayed face-up on the screen. As can be seen from the foregoing description, the angle value of the first rotation angle can be any one of 0°, 90°, 180°, 270°, and invalid. However, when the electronic device determines that the first image does not contain a face, the electronic device directly determines the angle value of the first rotation angle as invalid, that is, an invalid value. This means that when there is no face in the first image, the electronic device cannot determine the specific image rotation angle value based on the display orientation of the face.
[0184] S207. Detect text information in the first image.
[0185] S208. Determine whether the first image contains text.
[0186] S209. Determine the second rotation angle based on the text display direction.
[0187] S210, Determine the second rotation angle as invalid.
[0188] For specific instructions on steps S207-S209, please refer to the aforementioned instructions. Figure 4 The relevant explanations for steps S107-S109 are not repeated here.
[0189] Similarly, in this embodiment, when the electronic device determines that the first image contains text, it determines a second rotation angle based on the display direction of the text in the first image. This second rotation angle is the rotation angle of the first image during the process of rotating the text in the first image to be displayed face-up on the screen. As can be seen from the foregoing description, the angle value of the first rotation angle can be any one of 0°, 90°, 180°, 270°, and invalid. However, when the electronic device determines that the first image does not contain text, it directly determines the angle value of the second rotation angle as invalid, that is, an invalid value. This means that when there is no text in the first image, the electronic device cannot determine the specific rotation angle value of the image based on the display direction of the text.
[0190] S211, Detect other class information in the first image.
[0191] S212. Determine whether the first image contains other types of information.
[0192] S213. Determine the third rotation angle based on the display direction of other types of information.
[0193] S214. Determine the third rotation angle as invalid.
[0194] The specific operations for steps S211-S213 can be referred to the aforementioned... Figure 4 The relevant explanations of steps S111 and S113 are not repeated here.
[0195] Similarly, in this embodiment, when the electronic device determines that the first image contains other types of information, the electronic device determines a third rotation angle based on the display direction of the other types of information in the first image. This third rotation angle is the rotation angle of the first image during the process of rotating the other types of information in the first image to be displayed in the forward direction on the display screen. As can be seen from the foregoing description, the angle value of the first rotation angle can be any one of 0°, 90°, 180°, 270°, and invalid. However, when the electronic device determines that the first image does not contain other types of information, the electronic device directly determines the angle value of the third rotation angle as invalid, that is, an invalid value. This means that when there is no other types of information in the first image, the electronic device cannot determine the rotation angle value of the specific image based on the display direction of the other types of information.
[0196] S215. Determine the fifth rotation angle based on the first rotation angle, the second rotation angle, and the third rotation angle.
[0197] After determining the angle values of the first rotation angle, the second rotation angle, and the third rotation angle, the electronic device can determine the fifth rotation angle based on the angle values of the first rotation angle, the second rotation angle, and the third rotation angle, as well as the weights preset by the electronic device for the three types of information: face, text, and other types of information.
[0198] For ease of explanation, it is assumed that the electronic device has preset weights of W for the three types of information: face, text, and other information. face W word W other Based on the foregoing explanation, the values of the first, second, and third rotation angles are all values among 0°, 90°, 270°, and invalid, and these three angle values may contain the same value. Therefore, the electronic device can assign the weights corresponding to various types of information to the angle values determined based on the corresponding categories of information, and then determine the total weight values obtained from the five angle values of 0°, 90°, 180°, 270°, and invalid. The angle value with the largest total weight value is determined as the fifth rotation angle.
[0199] For example, suppose W face W wordW other The specific values are 0.4, 0.35, and 0.25, respectively. If the three angle values of the first rotation angle, the second rotation angle, and the third rotation angle are 90°, 180°, and 270°, respectively, the electronic device will assign weight values of 0.4, 0.35, and 0.25 to the three angle values of 90°, 180°, and 270°, respectively. Then, the total weight values obtained by the five angle values of 0°, 90°, 180°, 270°, and invalid are 0, 0.4, 0.35, 0.25, and 0, respectively. Based on the above explanation, since the total weight value of 0.4 corresponding to the angle value of 90° is the maximum value among the five values of 0, 0.4, 0.35, 0.25, and 0, the electronic device will determine the angle value of 90° as the fifth rotation angle. For example, if the first rotation angle, the second rotation angle, and the third rotation angle are 90°, 180°, and 180° respectively, the electronic device will assign a weight value of 0.4 to the angle value of 90°, and assign weight values of 0.35 and 0.25 to the angle value of 180°. Then, the total weight values obtained by the five angle values of 0°, 90°, 180°, 270°, and invalid are 0, 0.4, 0.6, 0, and 0 respectively. According to the above explanation, since the total weight value of 0.6 corresponding to the angle value of 180° is the maximum value among the five values of 0, 0.4, 0.6, 0, and 0, the electronic device will determine 180° as the fifth rotation angle.
[0200] S216. Determine whether the fifth rotation angle is 0 or invalid.
[0201] After determining the fifth rotation angle, the electronic device checks whether the fifth rotation angle is 0° or invalid.
[0202] If the rotation angle of the fifth element is determined to be neither 0 nor invalid, the electronic device may skip step S218 and directly execute step S217; if the rotation angle of the fifth element is determined to be 0 or invalid, the electronic device may skip step S217 and directly execute step S218.
[0203] Understandably, if the fifth rotation angle determined by the electronic device based on the first rotation angle, the second rotation angle, and the third rotation angle is not 0° and is not invalid, it means that the fifth rotation angle determined by the electronic device from the image content contained in the first image can make some information in the first image that was originally not displayed in the forward direction (such as faces, text, etc., which are highly likely to be information of interest to the user) be displayed in the forward direction. Therefore, the electronic device can directly determine the fifth rotation angle as the target rotation angle.
[0204] If the fifth rotation angle determined by the electronic device based on the first, second, and third rotation angles is 0° or invalid, it means that the electronic device cannot determine a meaningful rotation angle from the image content contained in the first image. However, the fact that the electronic device receives the first operation indicates that the user has a need to rotate the first image. Therefore, the electronic device can no longer determine the display direction of the image based on the image content, but instead rotate the first image according to a preset fixed rotation direction and rotation angle (e.g., rotate 90° counterclockwise).
[0205] S217. Determine the fifth rotation angle as the target rotation angle.
[0206] S218. Set the preset fourth rotation angle as the target rotation angle.
[0207] S219. Rotate the first image according to the target rotation angle.
[0208] As can be seen from the foregoing description, the target rotation angle may be any one of the fifth rotation angle and the fourth rotation angle under different circumstances.
[0209] Specifically, if the first operation is not the first rotation operation on the image, or if the fifth rotation angle is 0 or invalid, the target rotation angle is the fourth rotation angle. Correspondingly, if the first operation is the first rotation operation on the image, and the fifth rotation angle is neither 0 nor invalid, the target rotation angle is the fifth rotation angle.
[0210] Finally, the electronic device can rotate the first image according to the target rotation angle and display the resulting image on the screen.
[0211] Figure 8 and Figure 9 An example shows an electronic device according to Figure 7 The image processing method shown illustrates the specific process of rotating the image. For ease of explanation, in this embodiment, other types of information are represented as flowers, and the weights W for faces, text, and flowers are... face W word W other The following explanation uses values of 0.4, 0.35, and 0.25 as examples.
[0212] like Figure 8 As shown, image 801 includes face information 801a, text information 801b, and flower information 801c. Combined with... Figure 8As can be seen from the foregoing description, in image 801, the face information 801a, the text information 801b, and the flower 801c are not displayed in the positive direction.
[0213] To display the face in image 801 facing forward, image 801 needs to be rotated 180° counterclockwise to obtain image 811. Image 811 contains face information 811a, text information 811b, and flower information 811c. In image 811, the face corresponding to face information 811a is already displayed facing forward, but the text corresponding to text information 811b and the flower information 811c are still not displayed facing forward.
[0214] To display the text in image 801 in the correct orientation, image 801 needs to be rotated 270° counterclockwise to obtain image 812. Image 812 contains face information 812a, text information 812b, and flower information 812c. In image 812, the face corresponding to face information 812a and flower information 812c are still not displayed in the correct orientation, but the text corresponding to text information 812b is displayed in the correct orientation.
[0215] To display the flower in image 801 facing forward, image 801 needs to be rotated 90° counterclockwise to obtain image 813. Image 813 contains face information 813a, text information 813b, and flower 813c. In image 812, the face corresponding to face information 813a and the text corresponding to text information 813b are still not displayed facing forward, but flower 813c is now displayed facing forward.
[0216] In combination with the above Figure 7 According to the relevant explanation, when the electronic device displays image 801, if the user rotates the image, the electronic device can detect the facial information, text information, and flowers in image 801, and determine the location based on the display orientation of the facial information, text information, and flowers in image 801, as well as the corresponding weights W of the facial information, text information, and flowers. face W word W other A fifth rotation angle is jointly determined, and image 801 is rotated based on the fifth rotation angle if the fifth angle is neither 0 nor invalid.
[0217] like Figure 8As shown in (A), the electronic device displays a user interface 80. The user interface 80 may include an image 801 and a function control bar 802. When the user first clicks the rotation control 802a in the function control bar 802, the electronic device can detect that the image 801 contains face information 801a, and based on the display direction of the face information 801a, determine a first rotation angle of 180° (counter-clockwise rotation, the same below) corresponding to rotating the image 801 to the face-facing position. The electronic device will also detect that the image 801 contains text information 801b, and based on the display direction of the text information 802b, determine a second rotation angle of 270° corresponding to rotating the image 801 to the text-facing position. Furthermore, the electronic device will detect that the image 801 contains a flower 801c, and based on the display direction of the flower 801c, determine a third rotation angle of 90° corresponding to rotating the image 801 to the flower-facing position. Finally, the electronic device can, based on the display directions of the face, text, and flower, and the corresponding weights W of the face information, text information, and flower, determine the rotation angle. face W word W other The total weight values obtained for the five angle values 0°, 90°, 180°, 270°, and invalid are 0, 0.25, 0.4, 0.35, and 0, respectively. Since the total weight value of 0.4 corresponding to the angle value 180° is the maximum value among 0, 0.25, 0.4, 0.35, and 0, and 0.4 is neither 0 nor invalid, the electronic device will determine the target rotation angle as deg6 = 180°. After rotating image 801 counterclockwise by deg6 = 180°, the display will show... Figure 8 The user interface 81 shown in (B) is shown in the image.
[0218] like Figure 8 As shown in (B), the user interface 81 may include an image 811 and a function control bar 802. The image 811 is the image obtained by rotating image 801 counterclockwise by deg6 = 180° around its center, and it may contain face information 811a, text information 811b, and flower information 811c. Understandably, corresponding to the rotation of image 801, the face information 811a is displayed facing forward on the screen, but the text information 811b and the flower information 811c are still not displayed facing forward on the screen.
[0219] In this embodiment, image 801 can be referred to as the "first image," and the face information 801a, text information 801b, and flower 801c in image 801 can be collectively referred to as the "target information." The display direction of face information 801a, text information 801b, and flower 801c in image 801 can be collectively referred to as the "first display direction." The display direction of face information 811a in image 811, the display direction of text information 812b in image 812, and the display direction of flower 813c in image 813 can be collectively referred to as the "second display direction." The first rotation angle, the second rotation angle, and the third rotation angle can all be referred to as "the rotation angle corresponding to any one of the n pieces of information." The user's click operation on the rotation control 802a in the user interface 80 can be referred to as the "first operation." The counterclockwise rotation angle deg6 of image 801 can be referred to as the "target rotation angle."
[0220] Understandable, based on Figure 7 When rotating an image using the method shown, the display orientation of various types of information in the image will also affect the final value of the target rotation angle.
[0221] like Figure 9 As shown, image 901 contains face information 901a, text information 901b, and flower information 901c. Combined with... Figure 9 As can be seen from the foregoing description, in image 901, the face information 901a, the text information 901b, and the flower 901c are not displayed in the positive direction.
[0222] To display the face in image 901 facing forward, image 901 needs to be rotated 180° counterclockwise to obtain image 811. Image 911 contains face information 911a, text information 911b, and flower information 911c. In image 911, the face corresponding to face information 911a is already displayed facing forward, but the text corresponding to text information 911b and the flower information 911c are still not displayed facing forward.
[0223] To display the text and flowers in image 901 facing forward, image 901 needs to be rotated 270° counterclockwise to obtain image 921. Image 921 contains face information 921a, text information 921b, and flowers 921c. In image 921, the face corresponding to face information 921a is not displayed facing forward, but the text corresponding to text information 921b and the flowers 921c are both displayed facing forward.
[0224] In combination with the above Figure 7According to the relevant explanation, when the electronic device displays image 901, if the user rotates the image, the electronic device can detect the facial information, text information, and flowers in image 901, and determine the location based on the display orientation of the facial information, text information, and flowers in image 901, as well as the corresponding weights W of the facial information, text information, and flowers. face W word W other A fifth rotation angle is jointly determined, and image 901 is rotated based on the fifth rotation angle if the fifth angle is neither 0 nor invalid.
[0225] like Figure 9 As shown in (A), the electronic device displays a user interface 90. The user interface 90 may include an image 901 and a function control bar 902. When the user first clicks the rotation control 902a in the function control bar 902, the electronic device can detect that the image 901 contains face information 901a, and based on the display direction of the face information 901a, determine that the first rotation angle corresponding to rotating the image 901 to the face-facing position is 180° (counter-clockwise rotation, the same below). The electronic device will also detect that the image 901 contains text information 901b, and based on the display direction of the text information 902b, determine that the second rotation angle corresponding to rotating the image 901 to the text-facing position is 270°. Furthermore, the electronic device will also detect that the image 901 contains a flower 901c, and based on the display direction of the flower 901c, determine that the third rotation angle corresponding to rotating the image 901 to the flower-facing position is also 270°. Finally, the electronic device can, based on the display directions of the face, text, and flower, and the corresponding weights W of the face information, text information, and flower, determine the rotation angle. face W word W other The total weight values obtained for the five angle values 0°, 90°, 180°, 270°, and invalid are 0, 0, 0.4, 0.6, and 0, respectively. Since the total weight value of 0.6 corresponding to the angle value 270° is the maximum value among 0, 0.25, 0.4, 0.35, and 0, and 0.6 is neither 0 nor invalid, the electronic device will determine the target rotation angle as deg7 = 270°. After rotating image 901 counterclockwise by deg7 = 270°, the display will show... Figure 9 (B) shows the user interface 92.
[0226] like Figure 9As shown in (B), the user interface 92 may include an image 921 and a function control bar 902. The image 921 is the image obtained by rotating image 901 counterclockwise by deg7 = 270° around its center, and it may contain face information 921a, text information 921b, and flower information 921c. Understandably, corresponding to the rotation of image 901, the face information 921a is still not displayed correctly, but the text information 921b and the flower information 921c are displayed correctly on the screen.
[0227] In this embodiment, image 901 can be referred to as the "first image," and the face information 901a, text information 901b, and flower 901c in image 901 can be collectively referred to as the "target information." The display direction of face information 901a, text information 901b, and flower 901c in image 901 can be collectively referred to as the "first display direction." The display direction of face information 911a in image 911, the display direction of text information 921b in image 921, and the display direction of flower 921c in image 921 can be collectively referred to as the "second display direction." The first rotation angle, the second rotation angle, and the third rotation angle can all be referred to as "the rotation angle corresponding to any one of the n pieces of information." The user's click operation on the rotation control 902a in the user interface 90 can be referred to as the "first operation." The counterclockwise rotation angle deg7 of image 901 can be referred to as the "target rotation angle."
[0228] The electronic device provided in the embodiments of this application will be described below.
[0229] The electronic device can be a mobile phone, tablet computer, wearable device, in-vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), or dedicated camera (e.g., SLR camera, point-and-shoot camera), etc. This application does not impose any limitation on the specific type of the electronic device. Specifically, the electronic device can be one of the aforementioned... Figures 4-9 The electronic devices mentioned in the relevant instructions.
[0230] Figure 10 The structure of the electronic device is shown as an example.
[0231] Electronic device 100 may include a processor 110, internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, a sensor module 180, buttons 190, a camera 193, a display screen 194, etc. The sensor module 180 may include a pressure sensor 180A, a touch sensor 180K, etc.
[0232] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0233] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.
[0234] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0235] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0236] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0237] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the electronic device 100 to capture images. The processor 110 and the display screen 194 communicate via the DSI interface to enable the electronic device 100 to display images.
[0238] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0239] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0240] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0241] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, camera 193, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0242] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0243] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0244] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0245] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0246] Internal memory 121 can be used to store computer executable program code, which includes instructions. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of electronic device 100 by running instructions stored in internal memory 121 and / or instructions stored in memory located in the processor.
[0247] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A may be disposed on display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may include at least two parallel plates with conductive material. When a force is applied to pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the intensity of the touch operation based on pressure sensor 180A. Electronic device 100 may also calculate the touch position based on the detection signal from pressure sensor 180A.
[0248] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.
[0249] In this embodiment, when a click operation is applied to the rotation control of an image, the touch sensor 180K can detect the touch operation and transmit it to the application processor to determine the touch event type. The pressure sensor 180A can detect the user's touch position, enabling the processor 110 to determine that the operation is applied to the rotation control of the image. The processor 110 can combine the instructions sent by the application processor and the touch position information determined by the pressure sensor 180A to determine that the user has clicked the rotation control of the image, and respond to the operation by executing an instruction to rotate the image.
[0250] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0251] In this embodiment, the processor 110 can respond to user operations, such as clicking the rotation control corresponding to the image, by detecting information such as faces and text in the image and determining the image rotation angle based on the current display orientation of the faces and text on the display screen 194. If the angle is not 0 and is valid, the processor 110 can issue an image rotation command with the determined rotation angle. The GPU can respond to this command and, under the control of the processor 110, draw the image rotated according to the aforementioned rotation angle onto the display screen 194 for display.
[0252] The operating system of the electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of the electronic device. Figure 11 This is a software architecture block diagram of electronic device 100. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. Taking the Android system as an example, in some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer (Framework), the hardware abstraction layer (HAL), and the system kernel layer (Kernel).
[0253] The application layer can include a series of application packages. These application packages may include apps such as camera, gallery, calendar, call, map, navigation, WLAN, and Bluetooth. The application framework layer provides application programming interfaces (APIs) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. For example, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, and notification manager.
[0254] HAL can contain multiple library modules, each implementing a set of interfaces for a specific type of hardware component. For example, HAL includes an image recognition module and an image rotation module. The image recognition module can identify information such as faces and text in an image, and can also determine the target rotation angle of the image based on the display orientation of the information contained in the image. The image rotation module can rotate the image according to the target rotation angle determined by the image recognition module. The image recognition module and the image rotation module each have a set of interfaces. The application layer (APP) can call the interfaces of the image recognition module and / or the image rotation module, which are used to implement the image processing method described in this application. The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver and a sensor driver.
[0255] The above Figure 11 The processing procedure of the software structure shown is as follows: The processor receives an image rotation request, such as when the APP in the application layer sends an image rotation request to the processor; the processor calls the image recognition module in the HAL to analyze the image content, determines the rotation angle based on the display direction of all or part of the information contained in the image, and the processor further calls the image rotation module to rotate the image according to the rotation angle. The rotated image is then returned to the application layer for display.
[0256] This application also provides an electronic device, which includes one or more processors and a memory; wherein the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the methods shown in the foregoing embodiments.
[0257] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0258] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0259] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. An image processing method, characterized in that, The method includes: In response to a first operation, target information in a first image is detected, wherein the first operation is used to rotate the first image; The target rotation angle is determined based on a first display direction and a second display direction, wherein the first display direction is the display direction of the target information in the first image, and the second display direction is the display direction when the target information is displayed in the forward direction; Rotate the first image according to the target rotation angle.
2. The method according to claim 1, characterized in that, Determining the target rotation angle based on the first display direction and the second display direction includes: When the target information is not displayed in the first image in a forward orientation, the angle formed by the first display direction and the second display direction is determined as the target rotation angle; or... When the target information is displayed in the first image facing forward, the preset angle is determined as the target rotation angle.
3. The method according to claim 1 or 2, characterized in that, The target information detected in the first image includes: Detect the first information in the first image; If the first image contains the first information, and the first information is not displayed in the first image in a forward orientation, then the first information is determined to be the target information. If the first image does not contain the first information or the first information is displayed positively in the first image, the second information in the first image is detected. If the first image contains the second information, and the second information is not displayed in the first image in a forward orientation, then the second information is determined to be the target information. The first information and the second information are of different types.
4. The method according to claim 3, characterized in that, The method further includes: If the first image does not contain the first information and the first image does not contain the second information, the preset angle is determined as the target rotation angle.
5. The method according to claim 1, characterized in that, The target information includes n pieces of information, and any two pieces of information are of different types. The first display direction includes the display direction of each of the n pieces of information in the first image. The second display direction includes the display direction of each of the n pieces of information when it is displayed in the forward direction. The rotation angle corresponding to any piece of information is the angle formed by the display direction of any piece of information in the first image and the display direction of any piece of information when it is displayed in the forward direction. Determining the target rotation angle based on the first display direction and the second display direction includes: The target rotation angle is determined based on the rotation angle and weight corresponding to each of the n pieces of information.
6. The method according to any one of claims 1-5, characterized in that, Before determining the target rotation angle based on the first display direction and the second display direction, the method further includes: Determine whether the first operation is the first rotation operation on the first image; Determining the target rotation angle based on the first display direction and the second display direction includes: In the case where the first operation is the first rotation operation on the first image, the target rotation angle is determined based on the first display direction and the second display direction.
7. The method according to claim 6, characterized in that, The method further includes: If the first operation is not the first rotation operation on the first image, the preset angle is determined as the target rotation angle.
8. An electronic device, characterized in that, The electronic device includes: one or more processors, memory, and a display screen; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-7.
9. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1-7.