Image processing method and apparatus
View Patent ↗An image processing method and apparatus, relating to the technical field of image processing. The method comprises: calling an image acquisition device by means of an application program to obtain first image data; cropping the first image data to second image data, the ratio of the first image data being different from that of the second image data, the ratio of the first image data being a ratio supported by the image acquisition device, and the ratio of the second image data being a ratio supported by the application program; performing effect processing on the second image data; and performing first processing on the second image data subjected to effect processing, the first processing comprising at least one of displaying in an interface of the application program, encoding, and storing.
1 . An image processing method, comprising:
calling an image acquisition device by an application program to obtain first image data;
adjusting a ratio to be used for second image data in response to a screen rotation angle being greater than or equal to a pre-set angle threshold;
cropping the first image data to the second image data, wherein a ratio of the first image data is different from a ratio of the second image data, the ratio of the first image data is a ratio supported by the image acquisition device, and the ratio of the second image data is a ratio supported by the application program;
performing effect processing on the second image data; and
performing first processing on the second image data subjected to the effect processing, wherein the first processing comprises at least one of displaying in an interface of the application program, encoding and storing.
2 . The method according to claim 1 , wherein cropping the first image data to the second image data comprises:
determining a target region in the first image data, wherein a ratio of the target region is equal to the ratio of the second image data; and
converting a texture of the target region from a first type to a second type to obtain the second image data constituted by the target region, wherein the converting comprises the cropping for the first image data, the first type is a texture type supported when the image acquisition device performs image displaying, and the second type is a texture type supported when the application program performs image displaying.
3 . The method according to claim 2 , wherein
in response to the ratio of the first image data being greater than the ratio of the second image data, a height of the target region is a height of the first image data;
in response to the ratio of the first image data being smaller than the ratio of the second image data, a width of the target region is a width of the first image data.
4 . The method according to claim 2 , wherein determining the target region in the first image data comprises:
determining key image information included in the first image data; and
determining a region including the key image information in the first image data as the target region.
5 . The method according to claim 1 , wherein before performing the first processing on the second image data subjected to the effect processing, the method further comprises:
determining a first angle according to the screen rotation angle, wherein a sum of the first angle and the screen rotation angle is 0 degrees or 360 degrees; and
transposing the second image data subjected to the effect processing according to the first angle.
6 . The method according to claim 1 , wherein before cropping the first image data to the second image data, the method further comprises:
receiving a target ratio input into the application program; and
adjusting the ratio to be used for the second image data to the target ratio.
7 . The method according to claim 6 , further comprising:
in response to the adjusted ratio to be used for the second image data not matching the ratio of the first image data, selecting, from candidate ratios of the image acquisition device, a ratio that matches the adjusted ratio to be used for the second image data as the ratio of the first image data.
8 . The method according to claim 7 , wherein after selecting, from the candidate ratios of the image acquisition device, the ratio that matches the adjusted ratio to be used for the second image data as the ratio of the first image data, the method further comprises:
restarting preview of the image acquisition device according to an adjusted ratio of the first image data, thereby entering the step of calling the image acquisition device by the application program to obtain the first image data.
9 . An electronic device, comprising: at least one processor and a memory;
the memory storing computer-executable instructions;
the at least one processor executing the computer-executable instructions stored in the memory, to cause the electronic device to perform operations comprising:
calling an image acquisition device by an application program to obtain first image data;
adjusting a ratio to be used for second image data in response to a screen rotation angle being greater than or equal to a pre-set angle threshold;
cropping the first image data to the second image data, wherein a ratio of the first image data is different from a ratio of the second image data, the ratio of the first image data is a ratio supported by the image acquisition device, and the ratio of the second image data is a ratio supported by the application program;
performing effect processing on the second image data; and
performing first processing on the second image data subjected to the effect processing, wherein the first processing comprises at least one of displaying in an interface of the application program, encoding and storing.
10 . The electronic device according to claim 9 , wherein cropping the first image data to the second image data comprises:
determining a target region in the first image data, wherein a ratio of the target region is equal to the ratio of the second image data; and
converting a texture of the target region from a first type to a second type to obtain the second image data constituted by the target region, wherein the converting comprises the cropping for the first image data, the first type is a texture type supported when the image acquisition device performs image displaying, and the second type is a texture type supported when the application program performs image displaying.
11 . The electronic device according to claim 10 , wherein
in response to the ratio of the first image data being greater than the ratio of the second image data, a height of the target region is a height of the first image data;
in response to the ratio of the first image data being smaller than the ratio of the second image data, a width of the target region is a width of the first image data.
12 . The electronic device according to claim 10 , wherein determining the target region in the first image data comprises:
determining key image information included in the first image data; and
determining a region including the key image information in the first image data as the target region.
13 . The electronic device according to claim 9 , wherein before performing the first processing on the second image data subjected to the effect processing, the operations further comprise:
determining a first angle according to the screen rotation angle, wherein a sum of the first angle and the screen rotation angle is 0 degrees or 360 degrees; and
transposing the second image data subjected to the effect processing according to the first angle.
14 . The electronic device according to claim 9 , wherein before cropping the first image data to the second image data, the operations further comprise:
receiving a target ratio input into the application program; and
adjusting the ratio to be used for the second image data to the target ratio.
15 . The electronic device according to claim 14 , wherein the operations further comprise:
in response to the adjusted ratio to be used for the second image data not matching the ratio of the first image data, selecting, from candidate ratios of the image acquisition device, a ratio that matches the adjusted ratio to be used for the second image data as the ratio of the first image data.
16 . The electronic device according to claim 15 , wherein after selecting, from the candidate ratios of the image acquisition device, the ratio that matches the adjusted ratio to be used for the second image data as the ratio of the first image data, the operation further comprise:
restarting preview of the image acquisition device according to an adjusted ratio of the first image data, thereby entering the step of calling the image acquisition device by the application program to obtain the first image data.
17 . A non-transitory computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, cause a computing device to perform operations comprising:
calling an image acquisition device by an application program to obtain first image data;
adjusting a ratio to be used for second image data in response to a screen rotation angle being greater than or equal to a pre-set angle threshold;
cropping the first image data to the second image data, wherein a ratio of the first image data is different from a ratio of the second image data, the ratio of the first image data is a ratio supported by the image acquisition device, and the ratio of the second image data is a ratio supported by the application program;
performing effect processing on the second image data; and
performing first processing on the second image data subjected to the effect processing, wherein the first processing comprises at least one of displaying in an interface of the application program, encoding and storing.
18 . The non-transitory computer-readable storage medium according to claim 12 , wherein cropping the first image data to the second image data comprises:
determining a target region in the first image data, wherein a ratio of the target region is equal to the ratio of the second image data; and
converting a texture of the target region from a first type to a second type to obtain the second image data constituted by the target region, wherein the converting comprises the cropping for the first image data, the first type is a texture type supported when the image acquisition device performs image displaying, and the second type is a texture type supported when the application program performs image displaying.