Image processing method, device, electronic device and computer storage medium

By obtaining the pending images from the preset image cache path in the applet and compressing them according to the image parameters, the problem of inconsistent image quality and size acquisition by different models of smartphones is solved, reducing development costs and improving adaptability and reliability.

CN114302146BActive Publication Date: 2025-02-25ALIBABA INNOVATION PRIVATE LIMITED
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111660603.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-02-25
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

Due to the different cameras equipped with different models of smartphones, the quality and size of the collected images are inconsistent, which leads to the need for additional camera functions and debugging camera parameters, which increases the development cost.

Method used

By obtaining the image to be processed from the preset image cache path, and comparing the image with the set threshold value, the image is determined according to the image parameters, the image is compressed, and the compressed image is obtained, and it is stored in the system storage path.

Benefits of technology

The image compression processing is realized, the image volume is reduced, and the adaptability and reliability are improved, so that the applet can use the system camera to obtain available images on different smart devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114302146B_ABST
    Figure CN114302146B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide an image processing method, device, electronic device and computer storage medium. The method is used to process images captured by a camera mounted on a device, and the method includes: obtaining an image to be processed from a storage space corresponding to a preset image cache path; comparing the image parameters of the image to be processed with a preset image parameter threshold to determine the compression ratio of the image to be processed; compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image; storing the compressed image to a system storage path of the image, so that a preset application can obtain the compressed image from the storage space corresponding to the system storage path. The method has better adaptability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image technology, and in particular to an image processing method, device, electronic device, and computer storage medium. Background Art

[0002] Mini programs are lightweight applications. During their operation, existing mini programs may need to use data collected by sensors on the device running the mini program.

[0003] Taking the case of a smartphone as the device running the mini program, when the data used by the mini program is images captured by the smartphone's camera, even if the mini program runs on different models of smartphones, the mini program's standards for the quality and size of the images it uses are the same.

[0004] In the process of studying related technologies, the inventors of the present application discovered that since different models of smartphones are equipped with different cameras, the quality and size of images captured by different models of smartphones are also different. In order to obtain images that meet the usage standards of the mini-program, one implementation method is for the mini-program to call the camera of the smartphone to capture images that meet its usage standards. At this time, the developer of the mini-program needs to additionally develop camera functions and debug the camera parameters, resulting in higher development costs. Summary of the invention

[0005] In view of this, an embodiment of the present application provides an image processing solution to at least partially solve the above-mentioned problem.

[0006] According to a first aspect of an embodiment of the present application, an image processing method is provided for processing an image captured by a camera carried by a device, the method comprising: obtaining an image to be processed from a storage space corresponding to a preset image cache path; comparing image parameters of the image to be processed with a set image parameter threshold to determine a compression ratio of the image to be processed; compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image; and storing the compressed image to a system storage path of the image, so that a preset application obtains the compressed image from the storage space corresponding to the system storage path.

[0007] According to a second aspect of an embodiment of the present application, an image processing device is provided, comprising: a first acquisition module, used to acquire an image to be processed from a storage space corresponding to a preset image cache path; a determination module, used to compare image parameters of the image to be processed with a set image parameter threshold value, and determine the compression ratio of the image to be processed; a second acquisition module, used to compress the image to be processed using the compression ratio of the image to be processed to obtain a compressed image; and a storage module, used to store the compressed image to a system storage path of the image, so that a preset application can acquire the compressed image from the storage space corresponding to the system storage path.

[0008] According to a third aspect of an embodiment of the present application, a computer program product is provided, which, when executed by a processor, implements the positioning method of the first aspect.

[0009] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the image processing method as described in the first aspect is implemented.

[0010] According to the image processing solution provided by the embodiment of the present application, the image to be processed is obtained from the storage space corresponding to the preset image cache path, and the image to be processed is compressed to obtain a compressed image. Since the image volume of the compressed image is reduced, and since different images to be processed can be graded, the adaptability can be improved, and the system cameras on different smart devices can be better adapted, the adaptability is guaranteed, and the reliability is improved, so that the preset application can use the system camera on different smart devices to obtain a usable image. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] 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 recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0012] Figure 1A is a flowchart of the steps of an image processing method according to Embodiment 1 of the present application;

[0013] Figure 1B for Figure 1A A schematic diagram of an example scenario in the illustrated embodiment;

[0014] Figure 2A is a flowchart of the steps of an image processing method according to Embodiment 2 of the present application;

[0015] Figure 2B for Figure 2A A schematic diagram of a quality compression strategy in the illustrated embodiment;

[0016] Figure 2C for Figure 2A A schematic diagram of a size compression strategy in the illustrated embodiment;

[0017] Figure 3 is a structural block diagram of an image processing device according to Embodiment 3 of the present application;

[0018] Figure 4 This is a schematic diagram of the structure of an electronic device according to the fourth embodiment of the present application. DETAILED DESCRIPTION

[0019] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.

[0020] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.

[0021] Reference Figure 1A , shows a schematic diagram of the step flow of the image processing method of Example 1 of the present application.

[0022] In this embodiment, an image processing method is provided, which can be applied in the scenario of running a mini-program to process images used by the mini-program to reduce the data transmission and processing load when the mini-program is used. A mini-program is a lightweight application that can be run without downloading and installing. Of course, in other embodiments, the method can also be applied to other appropriate scenarios, without limitation.

[0023] The method comprises the following steps:

[0024] Step S102: acquiring the image to be processed from the storage space corresponding to the preset image cache path.

[0025] The image to be processed may be an original image captured by a system camera, or an image obtained by subjecting the original image to certain processing.

[0026] In one feasible manner, when the applet needs to capture images and use the captured images, the system camera can be directly called to capture images, and the captured images can be stored in the storage space corresponding to the pre-set image cache path. The pre-set image cache path can be a manually set path for temporarily storing images. The pre-set image cache path is different from the system storage path corresponding to the system camera.

[0027] The system storage path is the default image storage path configured by the operating system of the smart device for the system camera. For example, the system storage path corresponding to the system camera in the Android operating system is the DCIM folder of the built-in storage space. In the data processing logic of the operating system, when a new image is added to the system storage path, the operating system can be triggered to scan the DCIM folder to obtain the path corresponding to each image under the system storage path.

[0028] In this embodiment, an image cache path is configured for the images captured by the system camera, so that the images captured by the system camera will not be directly stored in the system storage path, and the operating system will not be triggered to scan the DCIM folder immediately after shooting is completed. Instead, the images will be stored in the image cache path, which can be conveniently processed to solve the problem that the images captured by the system camera cannot be used directly.

[0029] This problem includes but is not limited to: the parameters of the cameras configured in different smart devices and the configuration of the system cameras may be different, resulting in different sizes and storage sizes of images collected by the system cameras. Excessively large sizes or storage sizes contain a lot of redundant information, which is not necessary for the functions of the mini program. However, this redundant information will occupy computing power, storage space and transmission bandwidth, resulting in a waste of resources.

[0030] In order to avoid these problems, the image to be processed can be obtained from the image cache path, and the image to be processed can be processed through the following steps, so that the processed image retains the required information while occupying less storage space to meet the usage requirements of the mini program, and there is no need to develop additional cameras, thereby improving adaptability.

[0031] Step S104: Compare the image parameter of the image to be processed with the set image parameter threshold to determine the compression ratio of the image to be processed.

[0032] Different image parameters may correspond to different image parameter thresholds. For example, the image parameter may include at least one of image volume and image size.

[0033] The image volume is used to indicate the storage space occupied by the image to be processed, such as 8M, 4M, 100KB, and so on.

[0034] The image size is used to indicate the spatial size of the image to be processed. Since the image to be processed is formed by multiple pixels, the image size of the image to be processed can be converted into pixel numbers, such as 2560x1440px (2560 pixels in the width direction and 1440 pixels in the height direction), 1920x1080px, 1280x720px, etc. Since each pixel of the image to be processed has pixel information (such as RGB value, etc.), the image size of the image to be processed can also be mapped to the corresponding image volume.

[0035] In this embodiment, in order to adapt to the images to be processed with different image parameters, ensure that the image volume of the compressed image can be effectively reduced, and try to ensure that the compressed image is not distorted and can retain key information, a strategy of hierarchical compression is performed on the images to be processed. Hierarchical compression increases the compression rate of the images to be processed with larger image volumes and reduces the compression rate of the images to be processed with smaller image volumes, so that the image volumes of the images to be processed with different image volumes tend to be consistent after hierarchical compression, which is convenient for the use of the mini program.

[0036] In one feasible manner, the images to be processed can be graded according to their image volumes, and corresponding quality compression ratios can be determined, and quality compression can be performed on the images to be processed according to the quality compression ratios. The quality compression ratios indicate the proportion of image information retained by the quality-compressed images to the image information of the images to be processed.

[0037] In another feasible manner, the images to be processed can be graded according to their sizes, and the corresponding size compression ratio can be determined, and the size compression ratio is used to indicate the maximum image volume allowed, for example, the maximum image volume allowed for a 2560x1440px image to be processed is 400KB. In this way, the image volume can be reduced while ensuring that the compressed image is not distorted.

[0038] Of course, the aforementioned two hierarchical compressions can be combined to effectively reduce the image volume of the image to be processed, while preventing the compressed image from being distorted or losing key information through hierarchical compression.

[0039] Step S106: compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image.

[0040] The image to be processed may be compressed, cropped, etc. according to the compression ratio in any appropriate manner, and there is no limitation to this.

[0041] Step S108: storing the compressed image to the system storage path of the image, so that a preset application program can obtain the compressed image from the storage space corresponding to the system storage path.

[0042] The system storage path may be a path configured by the operating system in the smart device for storing images captured by the system camera. Taking Android as an example, the compressed image is stored in the DCIM folder, which can trigger the corresponding activity in the operating system to scan to obtain the path corresponding to the compressed image, and return the path to the preset application (such as a mini program), so that the preset application can obtain the compressed image.

[0043] In this way, the compressed image obtained by the preset application has a smaller image size, so the storage, processing and transmission loads thereof are all smaller.

[0044] The following is a description of the implementation process of this method in combination with a specific usage scenario:

[0045] In this usage scenario, the smart device can be a mobile phone running the Android system. As the pixels of the camera configured on the mobile phone become higher and higher, the image size of the image captured by the system camera on the mobile phone is also getting larger and larger. For example, the image size of the image captured by a 100-megapixel camera is already over 8M. For the mini program, such an image size contains a lot of redundant information that is irrelevant to the needs.

[0046] For example, when adding vehicle information to a mini program, the license plate number can be determined by taking a license plate image and identifying it. Increasing the pixel density in the license plate image only increases its fineness, which will only increase the amount of calculation for the image recognition model without having a beneficial improvement in recognition accuracy. Therefore, in this scenario, the image to be processed can be hierarchically compressed so that the mini program can use the compressed image for recognition to reduce the storage, transmission and computing loads.

[0047] In this usage scenario, in order to ensure that the image volume can be reduced without image distortion or loss of key information, hierarchical compression is performed according to the image parameters of the image to be processed and in accordance with the strategy.

[0048] For example, the quality compression and size compression are performed on the image to be processed respectively. Both compression methods can reduce the image volume of the image to be processed. In this usage scenario, the two methods are combined to retain key information to the greatest extent, ensure no distortion, and significantly reduce the image volume.

[0049] When performing quality compression, if the image size of the image to be processed is greater than 8MB, the quality compression ratio is determined to be 30% according to the classification strategy, that is, the image after quality compression retains 30% of the image information of the image to be processed. Then, the image to be processed is quality compressed according to the quality compression ratio. Quality compression can use appropriate algorithms, such as assimilating some pixels in the image to be processed with adjacent pixels, or deleting transparency information, or using other methods to perform quality compression.

[0050] The image after quality compression can be compressed to further reduce the image size. When performing size compression, if the size of the image to be processed is 2560x1440px, the maximum image size allowed is determined to be 500KB according to the classification strategy, which can avoid excessive cropping and loss of key information. Based on the determined maximum image volume, the image after quality compression is cyclically cropped and geometrically compressed (geometric compression does not change the aspect ratio of the image, so image distortion can be avoided) until the image volume of the size-compressed image is less than or equal to 500KB.

[0051] The compressed image is then stored in the system storage path, thereby triggering the scanning of the image, and the storage path of the scanned image is sent to the applet, so that the applet can obtain the compressed image in the scanned storage path, and can perform image recognition on the compressed image locally to obtain the license plate number, or send the compressed image to the server or cloud, which performs image recognition and obtains the license plate number returned by the server or cloud. In this way, since the image volume of the compressed image is significantly smaller than that of the original image to be processed, the load of computing, storage and data transmission can be reduced.

[0052] Through this embodiment, the image to be processed is obtained from the storage space corresponding to the preset image cache path, and the image to be processed is compressed to obtain a compressed image. Since the image volume of the compressed image is reduced, and different images to be processed can be graded, the adaptability can be improved, and the system cameras on different smart devices can be better adapted, so that the adaptability is guaranteed and the reliability is improved, so that the preset application can use the system camera on different smart devices to obtain a usable image.

[0053] The image processing method of this embodiment can be executed by any appropriate electronic device with data processing capability, including but not limited to: a server, a mobile terminal (such as a mobile phone, a PAD, etc.) and a PC, etc.

[0054] Embodiment 2

[0055] Reference Figure 2A, shows a schematic flow chart of the steps of the image processing method of the second embodiment of the present application.

[0056] In this embodiment, the method is applied to a mini program scenario as an example for explanation. The method includes the following steps:

[0057] Step S202: obtaining the image to be processed from the storage space corresponding to the preset image cache path.

[0058] In one example, the image to be processed in the image cache path can be obtained in the following manner: based on a system camera wake-up instruction obtained from the preset application, the system camera is called to obtain an image captured by the system camera, and the captured image is stored in the image cache path.

[0059] In this embodiment, the preset application program may be a small program, which is an application that can be run without downloading and installing. Taking the small program running in the map application as an example, the small program for managing the user's vehicle information can be run in the map application. By adding their own vehicle information, the user can query vehicle violations, pay fines, receive reminders for vehicle maintenance, and view driving information.

[0060] In this applet, in order to facilitate users to add their own vehicle information, the license plate number can be obtained by taking a photo of the license plate through the applet, so that users do not need to manually enter the license plate number. To this end, the applet needs to be able to drive the camera on the smart device to collect images. If the camera function is developed separately in the applet for this purpose, it will lead to high development costs. Therefore, the applet is enabled to call the system camera and drive the camera to capture images through the system camera.

[0061] In order to avoid the images taken by the system camera being directly stored in the default system storage path and affecting subsequent processing, you can pre-configure the image cache path, which is used to store images taken by the system camera called by the applet. For example, in the Android system, the preset image cache path is configured in the system's intent object. Intent is a messaging object that can be used to request operations from other Android components.

[0062] When the user uses the mini program, if the camera needs to be used to take photos, the mini program can call the system camera through the system camera wake-up command. For example, in Android, the system camera is called up using startActivityForResult, and the user can take photos using the operating system camera in the system camera interface. The captured image is stored in the image cache path based on the settings of the intent object. At the same time, the onActivityResult function of the Activity can also be triggered, which can realize the jump of the interface and the return of data.

[0063] During the execution of the onActivityResult process, the captured images are compressed in stages, so that the storage size of the compressed images returned to the mini program is smaller.

[0064] In this embodiment, step S202 may include the following process:

[0065] Process A1: Obtain the image to be processed from the storage space corresponding to the preset image cache path.

[0066] During the execution of the onActivityResult process, the captured image is obtained from the image cache path.

[0067] Process B1: Compare the angle of the image captured by the camera with the set angle. If the angles are inconsistent, rotate the captured image to obtain an image to be processed.

[0068] For example, the angle of the acquired image is determined based on the inherent angle attribute in the acquired image. If the angle of the acquired image is different from the set angle, the acquired image is rotated. The rotated image can be used as the image to be processed for subsequent processing. For images whose angles are consistent with the set angles, the rotation process can be omitted and they can be directly used as the image to be processed for subsequent hierarchical compression processing.

[0069] Step S204: Compare the image parameter of the image to be processed with the set image parameter threshold to determine the compression ratio of the image to be processed.

[0070] This step can be achieved in different ways.

[0071] In the first case, the compression ratio comprises a quality compression ratio and the image parameter comprises an image volume.

[0072] Step S204 may be implemented as follows: comparing the image volume of the image to be processed with one or more preset image volume thresholds to determine the image volume threshold interval into which the image volume of the image to be processed falls; and obtaining the compression ratio corresponding to the image volume threshold interval.

[0073] In order to implement the quality graded compression strategy, the image volume is compared with the image volume threshold, wherein the image volume threshold can be set as needed, and multiple image volume thresholds can be used to divide multiple different image volume threshold intervals, each image volume threshold interval can correspond to a different compression ratio, and the larger the image volume threshold, the smaller the corresponding quality compression ratio.

[0074] In one possible approach, Figure 2BAs shown, the image volume threshold and the corresponding quality compression ratio are:

[0075] 1. If the image size of the image to be processed is greater than a first set value, the corresponding quality compression ratio is a first ratio. The first set value is, for example, 8MB, 9MB or 10MB. The first ratio is, for example, 30%, 35%, etc.

[0076] 2. If the image volume of the image to be processed is less than or equal to the first setting value and greater than the second setting value, the corresponding quality compression ratio is the second ratio. The second setting value is less than the first setting value, and the second ratio is greater than the first ratio. The second setting value is, for example, 4MB, 4.5MB, 5MB, etc. The second ratio is, for example, 40%, 45%, etc.

[0077] 3. If the image volume of the image to be processed is less than or equal to the second setting value and greater than the third setting value, the corresponding quality compression ratio is the third ratio. The third setting value is less than the second setting value, and the third ratio is greater than the second ratio. The third setting value is, for example, 2MB, 3MB, etc. The third ratio is, for example, 45%, 50%, etc.

[0078] 4. If the image volume of the image to be processed is less than or equal to the third set value, the corresponding quality compression ratio is a fourth ratio. The fourth ratio is greater than the third ratio. The fourth ratio is, for example, 50%, 55%, etc.

[0079] In the second case, the compression ratio includes a size compression ratio, and the image parameter includes an image size.

[0080] Step S204 can be implemented as follows: comparing the image size of the image to be processed with one or more preset image size thresholds to determine the image size threshold interval into which the image size of the image to be processed falls; obtaining a compression ratio corresponding to the image size threshold interval, wherein the compression ratio includes a size compression ratio, and the size compression ratio is used to indicate the maximum image volume allowed by the image size threshold. The larger the image size threshold, the larger the maximum image volume allowed by the corresponding size compression ratio.

[0081] For example, Figure 2C As shown, the size compression ratio corresponding to the image size threshold can be:

[0082] 1. If the size of the image to be processed is larger than the first size value, the maximum allowed image volume is determined to be the first storage value. For example, the first size value is 2560x1440px. The first storage value is 500KB.

[0083] 2. If the size of the image to be processed is less than or equal to the first size value and greater than the second size value, the maximum allowed image volume is determined to be the second storage value. The second size value is less than the first size value, and the second storage value is less than the first storage value. For example, the second size value is 1920x1080px, and the second storage value is 400KB.

[0084] 3. If the size of the image to be processed is less than or equal to the second size value and greater than the third size value, the maximum allowed image volume is determined to be the third storage value. The third size value is less than the second size value, and the third storage value is less than the second storage value. For example, the third size value is 1280x720px, and the third storage value is 300KB.

[0085] 4. If the size of the image to be processed is less than or equal to the third size value, the maximum allowed image volume is determined to be a fourth storage value. The fourth storage value is less than the third storage value. For example, the fourth storage value is 200 KB.

[0086] Based on the determined compression ratio, step S206 may be executed to compress the image to be processed.

[0087] Step S206: compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image.

[0088] In one feasible manner, step S206 may be implemented by the following sub-steps:

[0089] Sub-step S2061: performing a quality compression on the image to be processed according to the quality compression ratio of the compression ratio.

[0090] For example, if the image size of the image to be processed is greater than 8MB, the corresponding quality compression ratio is 30%. Based on this, the image quality compression algorithm in the Android system can be used to perform quality compression once, so that the image information contained in the quality compressed image is 30% of the image information contained in the image to be processed, thereby reducing the image size of the quality compressed image. Since only one quality compression is performed, the image can be guaranteed not to be distorted.

[0091] Through the above-mentioned quality grading strategy, images with different image volumes are adapted. This quality grading strategy can effectively prevent the problem of blurring and distortion of images after quality compression while reducing the image volume.

[0092] The following sub-steps may be performed for the image after quality compression to perform size compression, thereby further reducing the image volume of the image. Of course, in other embodiments, size compression may not be performed, and there is no limitation to this. For example, if the image volume of the image after quality compression has met the maximum image volume allowed by its size, size compression may not be performed to prevent loss of key information.

[0093] Sub-step S2062: compressing the size of the quality-compressed image until the actual image volume of the size-compressed image satisfies the maximum image volume allowed by the image size threshold interval corresponding to the size of the image to be processed.

[0094] When compressing the size of the quality-compressed image, the image size threshold interval to which it belongs can be determined based on the image size of the quality-compressed image, and then the maximum image volume allowed can be determined. Then, the quality-compressed image is cyclically cropped and synchronously size-compressed until the image volume of the size-compressed image is less than or equal to the maximum image volume allowed.

[0095] Taking a 2560x1440px quality compressed image as an example, the size classification strategy determines that the maximum allowed image size is 500KB. If the image size of the quality compressed image is less than or equal to 500KB, size compression is not required. On the contrary, if it is greater than 500KB, it is compressed.

[0096] The size compression process is, for example: the image after quality compression is recorded as image A, image A is cropped and size compressed once to obtain image A1, if the image volume of image A1 is larger than the maximum image volume, image A1 is continuously cropped and size compressed to obtain image A2, if the image volume of image A2 is less than or equal to the maximum image volume, cropping is stopped, otherwise cropping and size compression are continued.

[0097] Determining the maximum image volume in this way ensures that the compressed image can meet the needs of the mini-program and can effectively prevent key image information from being cropped during the size cropping process.

[0098] Step S208 may be performed for the compressed image.

[0099] Step S208: storing the compressed image to the system storage path of the image, so that a preset application program can obtain the compressed image from the storage space corresponding to the system storage path.

[0100] For example, step S208 can be implemented as: storing the compressed image to the system storage path of the image to trigger an image scanning operation; sending the path of the scanned compressed image under the system storage path to a preset application (such as a mini program) so that the preset application obtains the compressed image according to the path under the system storage path.

[0101] The system storage path may be different for different operating systems. In the Android system, the system storage path may be the album path, that is, under the DCIM folder.

[0102] In this embodiment, the preset application is an application that does not need to be downloaded, such as a small program. The system returns the system storage path of the scanned compressed image to the small program for use, so that the small program can read the compressed image, identify it, or upload it to the server or cloud.

[0103] The size classification strategy and quality classification strategy are adapted to most images, so that the method can be adapted to different smart devices, and solve the problem of inconsistency in the size of various images when the images collected by the system camera are directly used. By compressing the images in a graded manner, the image volume and size of the processed images can be controlled within a reasonable range, and the difference in image volume after different image processing can be reduced. On the one hand, this can effectively reduce the image volume and prevent the image from being too large to be used directly. On the other hand, it can try to ensure that the image is not distorted, retain key information, etc., to prevent it from being unrecognizable.

[0104] In addition, the system camera is used directly for image acquisition. There is no need to develop camera functions for mini-program scenarios or perform special camera parameter debugging for different smart devices, which reduces the development workload. At the same time, the original image is saved using a temporary storage path without affecting the entire processing process.

[0105] Through this embodiment, the images captured by the system camera are stored in a temporary storage path different from the system storage path, and hierarchical compression is performed based on the image volume and / or size of the image to be processed, so that the image volume of the compressed image is reduced. At the same time, because different images to be processed can be graded, adaptability can be improved to better adapt to system cameras on different smart devices, thereby ensuring adaptability and improving reliability, so that preset applications can use the system camera on different smart devices to obtain usable images.

[0106] The image processing method of this embodiment can be executed by any appropriate electronic device with data processing capability, including but not limited to: a server, a mobile terminal (such as a mobile phone, a PAD, etc.) and a PC, etc.

[0107] Embodiment 3

[0108] Reference Figure 3 , shows a structural block diagram of an image processing device according to Embodiment 3 of the present application.

[0109] The image processing device of this embodiment includes:

[0110] A first acquisition module 302 is used to acquire the image to be processed from the storage space corresponding to the preset image cache path;

[0111] A determination module 304 is used to compare the image parameter of the image to be processed with a set image parameter threshold to determine the compression ratio of the image to be processed;

[0112] A second acquisition module 306 is used to compress the image to be processed using the compression ratio of the image to be processed to obtain a compressed image;

[0113] The storage module 308 is used to store the compressed image to the system storage path of the image, so that a preset application program can obtain the compressed image from the storage space corresponding to the system storage path.

[0114] Optionally, the image parameters include: image volume, and the determination module 304 is used to compare the image volume of the image to be processed with one or more preset image volume thresholds to determine the image volume threshold interval within which the image volume of the image to be processed falls; obtain the compression ratio corresponding to the image volume threshold interval, and the compression ratio includes a quality compression ratio, and the larger the image volume threshold, the smaller the corresponding quality compression ratio.

[0115] Optionally, the second acquisition module 306 is used to perform a quality compression on the image to be processed according to the quality compression ratio included in the compression ratio.

[0116] Optionally, the second acquisition module 306 is further used to size compress the quality-compressed image until the actual image volume of the size-compressed image meets the maximum image volume allowed by the image size threshold interval corresponding to the size of the image to be processed.

[0117] Optionally, the image parameters include image size, and the determination module 304 is used to compare the image size of the image to be processed with one or more preset image size thresholds to determine the image size threshold interval within which the image size of the image to be processed falls; obtain a compression ratio corresponding to the image size threshold interval, the compression ratio includes a size compression ratio, and the size compression ratio is used to indicate the maximum image volume allowed by the image size threshold, and the larger the image size threshold, the larger the maximum image volume allowed by the corresponding size compression ratio.

[0118] Optionally, the first acquisition module 302 is used to obtain the image captured by the camera from the storage space corresponding to the pre-set image cache path; compare the angle of the image captured by the camera with the set angle, and if the angles are inconsistent, rotate the captured image to obtain the image to be processed.

[0119] Optionally, the storage module 308 is used to store the compressed image to the system storage path of the image to trigger an image scanning operation; and send the path of the scanned compressed image under the system storage path to the preset application so that the preset application obtains the compressed image according to the system storage path, wherein the preset application is a mini-program.

[0120] The image processing device of this embodiment is used to implement the corresponding image processing methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here. In addition, the functional implementation of each module in the image processing device of this embodiment can refer to the description of the corresponding parts in the aforementioned method embodiments, which will not be described in detail here.

[0121] Embodiment 4

[0122] Reference Figure 4 , shows a schematic diagram of the structure of an electronic device according to the fourth embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the electronic device.

[0123] like Figure 4 As shown, the electronic device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .

[0124] in:

[0125] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .

[0126] The communication interface 404 is used to communicate with other electronic devices or servers.

[0127] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above-mentioned image processing method embodiment.

[0128] Specifically, the program 410 may include program codes, which include computer operation instructions.

[0129] The processor 402 may be a processor CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0130] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0131] The program 410 may be specifically used to enable the processor 402 to execute operations corresponding to the aforementioned method.

[0132] The specific implementation of each step in program 410 can refer to the corresponding description of the corresponding steps and units in the above-mentioned image processing method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiment, which will not be repeated here.

[0133] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.

[0134] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor or programmable or dedicated hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the image processing method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the image processing method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the image processing method shown herein.

[0135] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.

[0136] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.

Claims

1. An image processing method, wherein: The method is used to process an image captured by a camera mounted on a device, and the method includes: Obtaining the image to be processed from the storage space corresponding to the preset image cache path; Comparing the image parameter of the image to be processed with a set image parameter threshold to determine the compression ratio of the image to be processed; Compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image; storing the compressed image to a system storage path of the image to trigger an image scanning operation, wherein the image cache path is different from the system storage path; The path of the scanned compressed image under the system storage path is sent to a preset application, so that the preset application obtains the compressed image according to the system storage path, wherein the preset application is a small program.

2. The method according to claim 1, wherein: The image parameters include: image volume, comparing the image parameters of the image to be processed with a set image parameter threshold, and determining the compression ratio of the image to be processed, including: Comparing the image volume of the image to be processed with one or more preset image volume thresholds to determine the image volume threshold interval within which the image volume of the image to be processed falls; A compression ratio corresponding to the image volume threshold interval is obtained, where the compression ratio includes a quality compression ratio, and a larger image volume threshold corresponds to a smaller quality compression ratio.

3. The method according to claim 2, wherein: The step of compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image comprises: According to the quality compression ratio included in the compression ratio, the image to be processed is subjected to a quality compression.

4. The method according to claim 3, wherein: The step of compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image further comprises: The quality-compressed image is size-compressed until the actual image volume of the size-compressed image satisfies the maximum image volume allowed by the image size threshold interval corresponding to the size of the image to be processed.

5. The method according to claim 1, wherein: The image parameter includes an image size, and comparing the image to be processed with a set image parameter threshold to determine the compression of the image to be processed includes: Comparing the image size of the image to be processed with one or more preset image size thresholds to determine the image size threshold interval within which the image size of the image to be processed falls; A compression ratio corresponding to the image size threshold interval is obtained, wherein the compression ratio includes a size compression ratio, and the size compression ratio is used to indicate a maximum image volume allowed by the image size threshold. A larger image size threshold corresponds to a larger maximum image volume allowed by the corresponding size compression ratio.

6. The method according to any one of claims 1 to 5, wherein: Obtaining the image to be processed from the storage space corresponding to the preset image cache path, specifically including: Obtaining the image captured by the camera from the storage space corresponding to the preset image cache path; The angle of the image collected from the camera is compared with the set angle. If the angles are inconsistent, the collected image is rotated to obtain an image to be processed.

7. An image processing device, comprising: A first acquisition module, used to acquire the image to be processed from the storage space corresponding to the preset image cache path; A determination module, used for comparing the image parameter of the image to be processed with a set image parameter threshold value to determine the compression ratio of the image to be processed; A second acquisition module, used for compressing the image to be processed using the compression ratio of the image to be processed to obtain a compressed image; A storage module, used for storing the compressed image to a system storage path of the image to trigger an image scanning operation, wherein the image cache path is different from the system storage path; The path of the scanned compressed image under the system storage path is sent to a preset application, so that the preset application obtains the compressed image according to the system storage path, wherein the preset application is a small program.

8. A computer program product, comprising a computer program, wherein when the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and apparatus for taking photographs

    CN109040594A

  • Picture uploading control method and device, computer equipment and storage medium

    CN109918427A

  • Image processing method, device and equipment and computer readable storage medium

    CN111681291A