Image acquisition method and device, electronic device, and computer storage medium
By determining the type of target image, obtaining feature images and candidate images, and rating it, the problem that users need to manually crop due to size mismatch when setting the background image of electronic devices is solved, and quickly and effectively obtaining pictures that meet the needs.
Patent Information
- Application Number
- CN202011344321.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-25
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2040-11-25
AI Technical Summary
When setting up background pictures of electronic devices, users often need to manually cut due to mismatched image sizes, which consumes a lot of time and energy, but the effect may not be satisfactory.
By determining the image type of the target image, obtaining feature images, and obtaining multiple candidate images from the target image, finally rating these candidate images, and selecting the highest-rated image as the final image.
It realizes automatic and fast acquisition of pictures that meet user needs, saves users time to crop pictures, and improves the efficiency and effect of picture settings.
Smart Images

Figure CN114549830B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and specifically to a method and device for obtaining an image, an electronic device, and a computer storage medium. Background Art
[0002] With the popularization of electronic devices and the improvement of people's quality of life, users pay more attention to the user experience when using electronic devices. Therefore, users are often dissatisfied with the default background pictures of electronic devices. In order to meet the spiritual needs of users, users will find satisfactory pictures by themselves and set the pictures as background pictures. However, at present, due to the diversity of picture content, the picture sizes are also different. Therefore, not every picture can match the display screen of the electronic device. If it is not cropped, the displayed picture content will not meet the user's expectations. Therefore, in order to display pictures that satisfy users on electronic devices, users will crop them according to their needs after selecting pictures to adapt to electronic devices or make the background pictures displayed on electronic devices meet user expectations. Such multiple cropping will not only consume a lot of energy and time of users, but also may not necessarily enable users to obtain satisfactory results. Summary of the invention
[0003] The embodiments of the present application provide a method and device for obtaining an image, an electronic device, and a computer storage medium, so as to quickly obtain an image that meets the user's needs based on the target image, thereby saving the user's time.
[0004] In a first aspect, an embodiment of the present application provides a method for obtaining an image, the method comprising the following steps:
[0005] Determine the image type of the target image;
[0006] Acquire a characteristic image according to the image type, where the characteristic image is an image in the target image;
[0007] Acquire multiple candidate images from the target image according to the feature image, each of the multiple candidate images includes a first image, and the feature image includes the first image;
[0008] The multiple candidate images are scored, and the image with the highest score among the multiple candidate images is determined as the final image.
[0009] In a second aspect, an embodiment of the present application provides a picture acquisition device, the device comprising:
[0010] A determination unit, used to determine the image type of the target image;
[0011] A first acquisition unit, configured to acquire a feature image according to the image type, wherein the feature image is an image in the target image;
[0012] A second acquisition unit, configured to acquire a plurality of candidate images from the target image according to the feature image, each of the plurality of candidate images including a first image, and the feature image including the first image;
[0013] The scoring unit is used to score the multiple candidate images and determine the image with the highest score among the multiple candidate images as the final image.
[0014] In a third aspect, the present application provides an electronic device, characterized in that it includes a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps of any method described in the first aspect or the second aspect above.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in any method of the first aspect or the second aspect of the embodiment of the present application.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program, wherein the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect or the second aspect of the embodiment of the present application. The computer program can be a software installation package.
[0017] It can be seen that in the embodiment of the present application, the image type of the target image is first determined, and then a feature image is obtained according to the image type, and then multiple candidate images are obtained from the target image according to the feature image, and finally the multiple candidate images are scored, and the image with the highest score among the multiple candidate images is determined as the final image. It can be seen that in this way, an image that meets the user's needs can be automatically and quickly obtained from the target image, saving the user's time in cropping images. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1ais a schematic diagram of a picture acquisition system provided in an embodiment of the present application;
[0020] Figure 1b is a schematic diagram of a picture acquisition system provided in an embodiment of the present application;
[0021] Figure 1c is a schematic diagram of another electronic device structure provided by an embodiment of the present application;
[0022] Figure 2a It is a flowchart of a method for obtaining an image provided in an embodiment of the present application;
[0023] Figure 2b This is a schematic diagram of determining a target candidate frame provided by an embodiment of the present application;
[0024] Figure 2c is a schematic diagram of a picture frame selection process provided by an embodiment of the present application;
[0025] Figure 3a It is a flowchart of another method for obtaining an image provided in an embodiment of the present application;
[0026] Figure 3b is a schematic diagram of a feature image selection process provided by an embodiment of the present application;
[0027] Figure 4a It is a flowchart of another method for obtaining an image provided in an embodiment of the present application;
[0028] Figure 4b is a schematic diagram of a feature image selection process provided by an embodiment of the present application;
[0029] Figure 5 It is a structural schematic diagram of a picture acquisition device provided in an embodiment of the present application;
[0030] Figure 6 It is a schematic diagram of the structure of another image acquisition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0032] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0033] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0034] In order to better understand the technical solutions of the embodiments of the present application, the electronic devices and image acquisition systems that may be involved in the embodiments of the present application are first introduced below.
[0035] See also Figure 1a , Figure 1a 1 is a schematic diagram of an electronic device provided in an embodiment of the present application, wherein the electronic device 101 includes a picture acquisition device 102 and a display screen 103, and the electronic device 101 can be a user handheld device or a vehicle-mounted device located in a vehicle. The picture acquisition device 102 is used to acquire a background picture suitable for the display screen 103 of the electronic device 101 according to the original picture selected by the user, and the display screen 103 of the electronic device 101 is used to display the acquired background picture.
[0036] See also Figure 1b , Figure 1b 1 is a schematic diagram of a picture acquisition system provided by an embodiment of the present application, wherein the picture acquisition system 110 includes an electronic device 111 and a picture acquisition device 112 located in the cloud, and the electronic device 111 includes a display screen 113. The picture acquisition device 112 is in communication connection with the electronic device 111, and the picture acquisition device 112 can acquire an original picture from the cloud or through the electronic device 111, and then acquire the size information of the display screen 113 of the electronic device 111 according to the electronic device 111, and finally acquire a background picture according to the size information and the original picture, and send the background picture to the electronic device 111, so that the display screen 113 can display the background picture in the electronic device.
[0037] Specifically, as mentioned above Figure 1a and Figure 1bThe electronic device may also include the following structure, see Figure 1c , Figure 1c 1 is another schematic diagram of the structure of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device can implement the steps in the image acquisition method, and the electronic device 100 includes an application processor 120, a memory 130, a communication interface 140, and one or more programs 131, wherein the one or more programs 131 are stored in the above-mentioned memory 130 and are configured to be executed by the above-mentioned application processor 120, and the one or more programs 131 include instructions for executing any step in the following method embodiment.
[0038] The communication unit is used to support the communication between the first electronic device and other devices. The terminal may also include a storage unit for storing program codes and data of the terminal.
[0039] Among them, the processing unit can be an application processor 120 or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, units and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like. The communication unit can be a communication interface 140, a transceiver, a transceiver circuit, etc., and the storage unit can be a memory 130.
[0040] The memory 130 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0041] In a specific implementation, the application processor 120 is used to execute any step performed by the electronic device in the following method embodiment, and when performing data transmission such as sending, the communication interface 140 can be selectively called to complete the corresponding operation.
[0042] The current background image replacement method is that the user first selects an original image that he wants to set as the background image, and then directly matches the original image as the background image of the electronic device according to the internal instructions of the electronic device. When the size of the original image is different from that of the display screen of the electronic device, the user can manually crop the original image, and then set the cropped image as the background image. Since it is manually cropped by the user at will, there is a high probability that the cropped image still cannot be adapted to the screen size of the electronic device, so the user needs to repeat the above operation until the cropped image matches the screen size of the current electronic device. When the size of the original image is different from that of the display screen of the electronic device, the electronic device can also directly stretch or compress the original image so that the size of the original image matches the screen size of the electronic device, but the background image displayed in this way is quite different from the original image, and often cannot meet the user's expectations. For example, the screen aspect ratio of the current electronic device is 16:9, while the aspect ratio of the original picture that the user wants to set as the background picture is 4:3. At this time, the original picture does not match the screen size of the electronic device. The user either needs to manually crop the picture to a size with an aspect ratio of 16:9, which will consume a lot of user time and energy, or the electronic device will automatically stretch the picture with an aspect ratio of 4:3 to a size of 16:9, which will cause distortion of the picture content. Even if it is set as a background picture, it is far from meeting user needs.
[0043] Combined with the above description, the following will introduce the execution steps of the image acquisition method from the perspective of method examples. Figure 2a , Figure 2a 1 is a flow chart of a method for obtaining an image provided in an embodiment of the present application. As shown in the figure, the method for obtaining an image includes:
[0044] S201, determining the image type of the target image.
[0045] Among them, the image type includes image categories and image subcategories, and the image subcategories are subcategories in the image categories. Specifically, the image categories can be divided into several categories, such as people, animals, scenery, food, and text. The people category can be subdivided into subcategories such as single-person pictures and multi-person pictures, and can also be subdivided into subcategories such as real people and cartoon characters. The scenery type can also be subdivided into subcategories such as buildings, lakes, and plants.
[0046] It should be noted that the determination of the image type of the target image is performed by a neural network, and the parameters of the neural network are obtained through training, wherein the training method of the neural network may include the following steps: obtaining a training sample, which is all the image element information contained in the image, and the image element information includes the position, type, quantity and image area occupied by the image element, etc. The training sample is input into the neural network to obtain the predicted image type corresponding to the training sample, wherein the initial parameters of the neural network are obtained through random initialization; according to the predicted image type and the real image type, the parameters of the neural network are adjusted to obtain a trained neural network, wherein the image element is the smallest image unit constituting the image, such as a tree, a bird, etc.
[0047] Specifically, the neural network can be first trained to determine the major categories of the image, and then the accuracy of determining the major categories can be judged. When the accuracy of determining the major categories according to the neural network reaches a preset value, for example, when the accuracy reaches 98%, the neural network is trained again so that the subcategories of the target image can be determined according to the neural network.
[0048] S202: Acquire a characteristic image according to the picture type, where the characteristic image is an image in the target picture.
[0049] Among them, different types of pictures correspond to different feature images, and the feature image is consistent with the picture type. For example, when the picture type is a scenery category, the feature image should be a scenery-related image such as a lake or a building that makes up the scenery. Even if the picture also includes people, because it is a scenery-type picture, the importance of the people in the picture is relatively low, and the feature image will not be a person.
[0050] It should be noted that when there are multiple candidate frames whose picture types are the same as the target picture, the target candidate frames determined in this way include multiple ones. Therefore, the multiple target candidate frames can be merged into one target candidate frame according to their positional relevance. At this time, the image content in the target candidate frame includes multiple ones, and the multiple images can be determined to be feature images at the same time. Of course, the multiple target candidate frames can also be processed to determine one of the multiple target candidate frames as the final target candidate frame, and the image in the final target candidate frame can be determined to be the feature image.
[0051] For example, when the target image type is a landscape type, if there are multiple landscape-related images, the multiple images can be merged according to their positional relevance to obtain a feature image. In other words, the feature image can include the contents of multiple landscape-related images at the same time. Of course, the final merged feature image may not completely include all landscape-related images. Figure 2b As shown, Figure 2b A schematic diagram for determining a target candidate frame is provided for an embodiment of the present application. Figure 2b The image type in is a landscape type. At this time, three target candidate frames are determined, namely, candidate frame 1, candidate frame 2 and candidate frame 3. Therefore, the position correlation of the three candidate frames can be determined according to the position correlation of the three candidate frames, that is, according to the relationship between the relative distance between the three candidate frames and the preset distance. Since the relative distance between target candidate frame 1 and target candidate frame 2 is less than the preset distance, and the relative distance between target candidate frame 3 and target candidate frame 1 and target candidate frame 2 is greater than the preset distance, target candidate frame 1 and target candidate frame 2 can be merged to obtain target candidate frame 4, and target candidate frame 4 is determined to be the final target candidate frame.
[0052] Specifically, multiple candidate frames can be generated based on the target image, each of the multiple candidate frames includes a second image, and then the image type of the second image included in each candidate frame is obtained, and then the target candidate frame is obtained, and the image type of the second image included in the target candidate frame is the same as the image type of the target image, and finally the second image included in the target candidate frame is determined to be the feature image. In this way, multiple candidate frames are generated based on the target image, and the image in the target candidate frame is determined to be the feature image, so that the entire image can be processed quickly, and the speed of acquiring the feature image can be improved.
[0053] Among them, all image elements contained in the target image are obtained, and the position information and area ratio information of any image element are determined, the position information is used to indicate the distance between the element and the center of the target image or the visual center of the target image, and when the position information is less than a first preset value and / or the area ratio information is greater than a second preset value, a candidate frame is generated according to the element, and the candidate frame can completely include the element. In a specific implementation, the target image can also be directly divided into multiple areas, each area corresponding to a candidate frame. Since each candidate frame has a complete element, namely the second image, the picture type corresponding to the second image can be determined, and then the candidate frame corresponding to the second image whose picture type is consistent with the picture type of the target image is determined as the target candidate frame. Figure 2c As shown, Figure 2cThis is a schematic diagram of a picture selection process provided by an embodiment of the present application. It can be seen that the elements in the target picture include people, cows, and multiple trees. After determining the position information and area ratio information of each element, the people and cows in the target picture are selected to obtain two target candidate frames, namely target candidate frame 1 and target candidate frame 2. Then, since the picture type of the target picture is a person type, the picture type of the images corresponding to the elements in the two target candidate frames is determined again. It can be seen that the picture type of the image corresponding to the element in target candidate frame 1 is an animal type, and the picture type of the image corresponding to the element in target candidate frame 2 is a person type. Therefore, it is determined that the image in target candidate frame 2 is a feature image. It should be noted that when the picture type of the second image contained in multiple candidate frames is the same as the picture type of the target picture, a candidate frame can be re-determined based on the multiple candidate frames. The re-determined candidate frame includes the multiple candidate frames at the same time. At this time, the image contained in the re-determined candidate frame is also a feature image.
[0054] S203: Acquire multiple candidate images from the target image according to the feature image.
[0055] Among them, each of the multiple candidate images includes a first image, and the feature image includes the first image. Acquiring multiple candidate images from the target image according to the feature image may include the following steps: acquiring the size information of the display screen, and cropping the image according to the size information. Each cropped candidate image includes the content of the feature image, that is, the candidate image may include the complete feature image or only a part of the feature image. For example, when the feature image is a person's whole body, the candidate image may include the person's whole body or only the person's upper body.
[0056] S204: Score the multiple candidate images, and determine the image with the highest score among the multiple candidate images as the final image.
[0057] The cropped candidate images may be aesthetically scored, and the candidate image with the highest score may be selected as the final image according to the aesthetic score, and the final image may be set as the background image of the electronic device. Alternatively, the images may be set as the background images in sequence, and the user may score the images set each time, and finally the candidate image with the highest score may be determined as the final image.
[0058] In a specific implementation, scoring the multiple candidate images may include the following steps: obtaining a template image, the image type of the template image is the same as the image type of the target image; matching each candidate image in the multiple candidate images with the template image to obtain a matching value of each candidate image; obtaining a second ratio of each candidate image, the second ratio being the ratio of the area of the first image in the candidate image to the area of the feature image; determining a first weighting coefficient of the matching value and a second weighting coefficient of the second ratio; and scoring each candidate image according to the matching value, the second ratio, the first weighting coefficient, and the second weighting coefficient. In this way, scoring each candidate image according to the matching value, the second ratio, the first weighting coefficient, and the second weighting coefficient can simultaneously ensure the aesthetics and content of the acquired image to meet user needs.
[0059] It should be noted that different template images can be generated according to different image types, and the template image includes the position information and proportion information of the elements corresponding to the image type. For example, if the current image type is a person type, the template image reports the position of the person in the image, the size of the person, etc. At the same time, even for a person type image, different template images can be determined according to a single person or multiple people. Since the obtained candidate image may only include a part of the feature image, the second ratio is the ratio of the area of the first image to the area of the feature image. The larger the ratio, the larger the range of the feature image contained in the candidate image. The size of the first weighting coefficient and the second weighting coefficient can be determined according to the image type or user needs. For example, when the user cares more about the content of the feature image but not the aesthetics of the image or the image type is a landscape type, the value of the second weighting coefficient can be increased. In this example, each candidate image is scored according to the matching value, the second ratio, the first weighting coefficient and the second weighting coefficient, which can be: scoring value = first weighting coefficient × matching value + second weighting coefficient × second ratio. The first weighting coefficient can be adjusted differently according to the confidence level determined for the accuracy of the matching value. For example, when the confidence level of the accuracy of the matching value is (85%, 95%) on 0.95, it means that there is a 95% probability that the accuracy of the matching value is between 85% and 95%. At this time, the value of the first weighting coefficient can be determined at 0.9 or 0.8, etc. If the confidence level of the accuracy of the matching value is (50%, 60%) on 0.95, it means that there is a 95% probability that the accuracy of the matching value is between 50% and 60%. At this time, the value of the first weighting coefficient can be determined at about 0.5.
[0060] It can be seen that in this example, the image type of the target image is first determined, and then a feature image is obtained according to the image type, and then multiple candidate images are obtained from the target image according to the feature image, and finally the multiple candidate images are scored, and the image with the highest score among the multiple candidate images is determined as the final image. It can be seen that in this way, an image that meets the user's needs can be automatically and quickly obtained from the target image, saving the user's time in cropping images.
[0061] In a possible instance, determining that the second image included in the target candidate frame is the feature image includes: determining that the second image included in a target candidate frame having a largest first ratio among multiple target candidate frames is the feature image, wherein the first ratio is a ratio of an area of the target candidate frame to an area of the target image.
[0062] It can be seen that in this example, the image contained in the target candidate frame with the largest area is determined as the feature image, which can ensure that the cropped candidate image contains the main content of the target image and meets user needs.
[0063] In a possible instance, the target candidate box includes multiple target candidate boxes, and determining the second image included in the target candidate box as the feature image includes: obtaining the first center coordinates of the target image; obtaining the second center coordinates of each target candidate box in the multiple target candidate boxes; and determining that the second image included in the target candidate box corresponding to the second center coordinate closest to the first center coordinate is the feature image.
[0064] It can be seen that in this example, the image contained in a target candidate frame closest to the center of the target image is determined as the feature image, which can ensure that the cropped candidate image contains the main content of the target image, meeting user needs.
[0065] See also Figure 3a , Figure 3a FIG. 1 is a flow chart of another method for obtaining an image provided in an embodiment of the present application. Figure 3a For example, another method for obtaining an image provided by an embodiment of the present application may include:
[0066] S301, determining the image type of the target image;
[0067] S302, generating a plurality of candidate boxes according to the target image, each of the plurality of candidate boxes including a second image;
[0068] S303, obtaining the picture type of the second image included in each candidate frame;
[0069] S304, obtaining a target candidate frame, wherein the picture type of the second image included in the target candidate frame is the same as the picture type of the target picture;
[0070] S305, determining that a second image included in a target candidate frame having a maximum first ratio among multiple target candidate frames is the feature image, wherein the first ratio is a ratio of an area of the target candidate frame to an area of the target image;
[0071] S306, acquiring a plurality of candidate images from the target image according to the feature image;
[0072] S307: Score the multiple candidate images, and determine the image with the highest score among the multiple candidate images as the final image.
[0073] Wherein, each candidate picture in the plurality of candidate pictures includes a first image, and the characteristic image includes the first image. After determining the picture type of the target picture, multiple candidate frames can be generated for the image in the target picture, and then a target candidate frame with the same picture type as the target picture can be determined according to the picture type of the image in the candidate frame. When the picture type of the image included in multiple candidate frames is the same as the picture type of the target picture at the same time, since the elements contained in each target candidate frame are different, the size of each candidate frame is positively correlated with the size of the elements contained therein, so that the area of each target candidate frame can be determined, and then the area proportion of each target candidate frame in the target picture is obtained, and the image included in the target candidate frame with the largest area proportion is determined as the characteristic image. Finally, the target picture is cropped. When cropping, the size of the display screen of the electronic device and the display area of the characteristic image need to be considered at the same time, so that multiple pictures with the same size but different contents of the characteristic images contained can be obtained at the same time. The only difference in the content is that the display ratio of the same characteristic image in the cropped picture is different.
[0074] For example Figure 3b As shown, Figure 3b is a schematic diagram of a feature image selection process provided by an embodiment of the present application. Figure 3b The image type in is animal type, so there are three target candidate frames determined, namely candidate frame 1, candidate frame 2 and candidate frame 3. The image types of the images contained in these three candidate frames are also animal types. In order to obtain the final feature image, it is necessary to calculate the areas of these three candidate frames. Since the area of candidate frame 1 accounts for a larger proportion of the entire target image than the other two candidate frames, candidate frame 1 is determined as the final candidate frame, that is, the image in candidate frame 1 is the feature image.
[0075] It can be seen that in this example, multiple target candidate frames are determined from multiple candidate frames in the image according to the image type of the target image, and then the image contained in the target candidate frame with the largest area is determined as the feature image, which can ensure that the cropped candidate image contains the main content of the target image and meets user needs.
[0076] See also Figure 4a , Figure 4a FIG. 1 is a flow chart of another method for obtaining an image provided in an embodiment of the present application. Figure 4a For example, another method for obtaining an image provided by an embodiment of the present application may include:
[0077] S401, determining the image type of the target image;
[0078] S402, generating a plurality of candidate frames according to the target image, each of the plurality of candidate frames including a second image;
[0079] S403, obtaining the picture type of the second image included in each candidate frame;
[0080] S404, obtaining a target candidate frame, wherein the picture type of the second image included in the target candidate frame is the same as the picture type of the target picture;
[0081] S405, obtaining the first center coordinates of the target image;
[0082] S406, obtaining the second center coordinates of each target candidate box in the plurality of target candidate boxes;
[0083] S407, determining that a second image included in a target candidate box corresponding to a second center coordinate closest to the first center coordinate is the feature image;
[0084] S408, acquiring a plurality of candidate images from the target image according to the feature image, each of the plurality of candidate images including a first image, and the feature image including the first image;
[0085] S409: Score the multiple candidate images, and determine the image with the highest score among the multiple candidate images as the final image.
[0086] Among them, after determining the image type of the target image, multiple candidate frames can be generated for the image in the target image, and then the target candidate frame with the same image type as the target image can be determined according to the image type of the image in the candidate frame. When the image type included in multiple candidate frames is the same as the image type of the target image at the same time, a final feature image can be determined according to the position of the image in the target image. The closer the image is to the center of the image, the more important the image can be determined. The first center coordinate of the target image can be the center coordinate of the center of the image in the physical sense, or the center coordinate of the visual center of the image. The visual center can be the same as or different from the physical center, depending on the size of the image and the type of electronic device. After determining the first center coordinate and the second center coordinate, the straight-line distance of each second center coordinate from the first center coordinate is calculated, and then the image contained in the target candidate frame with the shortest straight-line distance is the feature image.
[0087] For example Figure 4b As shown, Figure 4b is a schematic diagram of a feature image selection process provided by an embodiment of the present application. Figure 4b The image type in is animal type, so there are two target candidate frames determined, namely candidate frame 1 and candidate frame 2. The image types of the images in these two candidate frames are also animal types. In order to obtain the final feature image, it is necessary to first obtain the center coordinates of the image. In this example, the physical center of the image is used as the first center coordinate, and then the second center coordinates of target candidate frame 1 and target candidate frame 2 are obtained respectively. At this time, the distance between the two second center coordinates and the first center coordinate is compared. It can be seen that the first center coordinate of the target image is the same as the second center coordinate of target candidate frame 1. Therefore, the distance between the second center coordinate of target candidate frame 2 and the first center coordinate is greater than the distance between the second center coordinate of target candidate frame 1 and the first center coordinate. In this way, target candidate frame 1 can be determined as the final target candidate frame, and the image in target candidate frame 1 is the feature image.
[0088] It can be seen that in this example, multiple target candidate frames are determined from multiple candidate frames in the image according to the image type of the target image, and then the image contained in the target candidate frame closest to the center of the target image is determined as the feature image, which can ensure that the cropped candidate image contains the main content of the target image and meets user needs.
[0089] The following examples are given to explain the embodiments of the present application in detail.
[0090] When the image acquisition method is applied to the vehicle's on-board equipment, if the user has stored a photo with an aspect ratio of 4:3 on the vehicle's on-board equipment, the photo is the user's own selfie, but at the same time there is someone else's back in the upper right corner of the photo. At this time, the user wants to set this photo as the wallpaper of the vehicle's on-board equipment, and the screen aspect ratio of the vehicle's on-board equipment is 16:9. At this time, the vehicle will first determine that the picture is a person-type picture based on the picture content, and then select the user's selfie image and the back in the upper right corner of the picture as two target candidate frames. At this time, the user's selfie image can be determined as a feature image based on the distance between the two target candidate frames and the physical center of the picture. Therefore, the original picture will be cropped or adjusted based on the feature image to obtain multiple pictures with an aspect ratio of 16:9 containing the user's selfie image, and then these multiple pictures will be scored, and then the picture with the highest score will be set as the vehicle's on-board wallpaper.
[0091] With the above Figure 2a , Figure 3a and Figure 4a For details on the embodiments shown in the drawings, please refer to Figure 5 , Figure 5 It is a structural schematic diagram of a picture acquisition device provided in an embodiment of the present application, wherein the picture acquisition device 500 includes a determination unit 501, for determining the picture type of a target picture; a first acquisition unit 502, for acquiring a feature image according to the picture type, wherein the feature image is an image in the target picture; a second acquisition unit 503, for acquiring multiple candidate pictures from the target picture according to the feature image, wherein each of the multiple candidate pictures includes a first image, and the feature image includes the first image; a scoring unit 504, for scoring the multiple candidate pictures, and determining the picture with the highest score among the multiple candidate pictures as the final picture.
[0092] In a possible example, in terms of acquiring the characteristic image according to the picture type, the first acquisition unit 502 is specifically used to: generate multiple candidate frames according to the target picture, each of the multiple candidate frames includes a second image; acquire the picture type of the second image included in each candidate frame; acquire a target candidate frame, the picture type of the second image included in the target candidate frame is the same as the picture type of the target picture; and determine that the second image included in the target candidate frame is the characteristic image.
[0093] In a possible instance, the target candidate frame includes multiple target candidate frames, and in terms of determining that the second image included in the target candidate frame is the feature image, the first acquisition unit 502 is specifically used to: determine that the second image included in the target candidate frame with the largest first ratio among the multiple target candidate frames is the feature image, and the first ratio is the ratio of the area of the target candidate frame to the area of the target image.
[0094] In a possible instance, in aspect, the specific use is: in a possible instance, the target candidate box includes multiple, and in aspect of determining that the second image included in the target candidate box is the feature image, the first acquisition unit 502 is specifically used to: obtain the first center coordinates of the target image; obtain the second center coordinates of each target candidate box in multiple target candidate boxes; determine that the second image included in the target candidate box corresponding to the second center coordinate closest to the first center coordinate is the feature image.
[0095] In a possible instance, in terms of scoring the multiple candidate images, the scoring unit 504 is specifically used to: obtain a template image, the image type of the template image is the same as the image type of the target image; match each candidate image among the multiple candidate images with the template image to obtain a matching value of each candidate image; obtain a second ratio of each candidate image, the second ratio being the ratio of the area of the first image in the candidate image to the area of the feature image; determine a first weighting coefficient of the matching value and a second weighting coefficient of the second ratio; and score each candidate image according to the matching value, the second ratio, the first weighting coefficient and the second weighting coefficient.
[0096] It can be understood that since the method embodiment and the device embodiment are different presentation forms of the same technical concept, the content of the method embodiment part in this application should be synchronously adapted to the device embodiment part and will not be repeated here.
[0097] In the case of integrated units, such as Figure 6 As shown, Figure 6 is a schematic diagram of the structure of another image acquisition device provided in an embodiment of the present application. Figure 6 In the embodiment, the image acquisition device 600 includes: a processing module 602 and a communication module 601. The processing module 602 is used to control and manage the actions of the image acquisition device, for example, to control and manage the determination unit 501, the first acquisition unit 502, the second acquisition unit 503 and the scoring unit 504 when executing related commands, and / or to perform other processes of the technology described herein. The communication module 601 is used to support the interaction between the image acquisition device and other devices. Figure 6 As shown, the image acquisition device may further include a storage module 603, and the storage module 603 is used to store program codes and data of the image acquisition device.
[0098] Among them, the processing module 602 can be a processor or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements a computing function, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like. The communication module 601 can be a transceiver, an RF circuit or a communication interface, and the like. The storage module 603 can be a memory.
[0099] Among them, all relevant contents of each scene involved in the above method embodiment can be referred to the functional description of the corresponding functional module, and will not be repeated here. The above picture acquisition device 500 and the picture acquisition device 600 can both execute the above Figure 2a , Figure 2b and Figure 2c The picture acquisition method shown.
[0100] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. 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 computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless 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 contains one or more available media sets. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.
[0101] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0102] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0103] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0104] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0105] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0106] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0107] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0108] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions without departing from the spirit and scope of the present invention, and can make various changes and modifications, including the combination of the above-mentioned different functions and implementation steps, including software and hardware implementation methods, all of which are within the scope of protection of the present invention.
Claims
1. A method for obtaining a picture, characterized in that: The method comprises the following steps: Determine the image type of the target image; Acquire a characteristic image according to the image type, where the characteristic image is an image in the target image; Acquire multiple candidate images from the target image according to the feature image, each of the multiple candidate images includes a first image, and the feature image includes the first image; Scoring the multiple candidate images, and determining the image with the highest score among the multiple candidate images as the final image; Among them, the obtaining of the characteristic image according to the picture type includes: generating multiple candidate frames according to the target picture, each of the multiple candidate frames includes a second image; obtaining the picture type of the second image included in each candidate frame; obtaining the target candidate frame, the picture type of the second image included in the target candidate frame is the same as the picture type of the target picture; determining that the second image included in the target candidate frame is the characteristic image; the scoring of the multiple candidate pictures includes: obtaining a template picture, the picture type of the template picture is the same as the picture type of the target picture; matching each candidate picture in the multiple candidate pictures with the template picture to obtain a matching value of each candidate picture; obtaining a second ratio of each candidate picture, the second ratio being the ratio of the area of the first image in the candidate picture to the area of the characteristic image; determining a first weighting coefficient of the matching value and a second weighting coefficient of the second ratio; scoring each candidate picture according to the matching value, the second ratio, the first weighting coefficient and the second weighting coefficient.
2. According to the method of claim 1, the target candidate frame includes a plurality of target candidate frames, and the determining the second image included in the target candidate frame as the feature image comprises: It is determined that a second image included in a target candidate frame having a maximum first ratio among multiple target candidate frames is the feature image, and the first ratio is a ratio of an area of the target candidate frame to an area of the target image.
3. The method according to claim 1, wherein the target candidate frame includes a plurality of target candidate frames, and the step of determining that the second image included in the target candidate frame is the feature image comprises: Obtaining the first center coordinates of the target image; Obtain the second center coordinates of each target candidate box in the multiple target candidate boxes; Determine that a second image included in a target candidate box corresponding to a second center coordinate that is closest to the first center coordinate is the feature image.
4. A picture acquisition device, characterized in that: The device comprises: A determination unit, used to determine the image type of the target image; A first acquisition unit, configured to acquire a feature image according to the image type, wherein the feature image is an image in the target image; a second acquisition unit, configured to acquire a plurality of candidate images from the target image according to the feature image, each of the plurality of candidate images including a first image, and the feature image including the first image; A scoring unit, used to score the multiple candidate images and determine the image with the highest score among the multiple candidate images as the final image; Among them, the obtaining of the characteristic image according to the picture type includes: generating multiple candidate frames according to the target picture, each of the multiple candidate frames includes a second image; obtaining the picture type of the second image included in each candidate frame; obtaining the target candidate frame, the picture type of the second image included in the target candidate frame is the same as the picture type of the target picture; determining that the second image included in the target candidate frame is the characteristic image; the scoring of the multiple candidate pictures includes: obtaining a template picture, the picture type of the template picture is the same as the picture type of the target picture; matching each candidate picture in the multiple candidate pictures with the template picture to obtain a matching value of each candidate picture; obtaining a second ratio of each candidate picture, the second ratio being the ratio of the area of the first image in the candidate picture to the area of the characteristic image; determining a first weighting coefficient of the matching value and a second weighting coefficient of the second ratio; scoring each candidate picture according to the matching value, the second ratio, the first weighting coefficient and the second weighting coefficient.
5. The device according to claim 4, wherein the target candidate frame includes a plurality of target candidate frames, and the step of determining that the second image included in the target candidate frame is the feature image comprises: It is determined that a second image included in a target candidate frame having a maximum first ratio among multiple target candidate frames is the feature image, and the first ratio is a ratio of an area of the target candidate frame to an area of the target image.
6. The device according to claim 4, wherein the target candidate frame includes a plurality of target candidate frames, and the step of determining that the second image included in the target candidate frame is the feature image comprises: Obtaining the first center coordinates of the target image; Obtain the second center coordinates of each target candidate box in the multiple target candidate boxes; Determine that a second image included in a target candidate box corresponding to a second center coordinate that is closest to the first center coordinate is the feature image.
7. An electronic device, characterized in that: The method comprises a processor, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that: A computer program for electronic data exchange is stored, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Image processing apparatus, image processing method, and program
CN104134186A
A method and apparatus for image cropping
CN109523503A