Picture uploading method and device, equipment and storage medium
By performing pre-upload operations and area encoding addressing methods in the video surveillance system, the problems of real-time transmission difficulties, upload timeouts and image loss during massive pictures are solved, and stable and efficient image upload is achieved.
Patent Information
- Application Number
- CN202411978542.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-15
AI Technical Summary
In the field of video surveillance, the upload of massive images has problems such as difficulty in real-time transmission, upload timeout and image loss, especially in places with crowded traffic and vehicles.
Compare the upload time with the time threshold by obtaining the image to be uploaded and performing a pre-upload operation to determine the upload time. When the upload time is less than or equal to the time threshold, it is directly uploaded to the file server; when the upload time is greater than the time threshold, the storage address of the local server is determined according to the area encoding of the picture, the picture is uploaded to the address, and the unuploaded record information is generated, and the pictures in the local server are finally uploaded to the file server.
It effectively avoids upload timeout and image loss, ensures the integrity of uploaded data, and ensures the stable and efficient upload of massive images.
Smart Images

Figure CN119835265A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method, device, equipment and storage medium for uploading pictures. Background Art
[0002] With the development of business, the number of cameras connected to the platform in various cities has gradually increased, and the front-end cameras with intelligent capture have become more and more common. In the field of video surveillance, the backend needs to receive the captured images of faces, people or vehicles pushed by the front-end devices in many occasions. For example, on holidays, commuting and other occasions with dense traffic and vehicles, the number of front-end captured images will be very large, so there is a need to store massive images. Usually, massive images are uploaded to the file server. When massive images are uploaded at the same time, the file server may occupy too much memory, which makes it difficult to transmit images in real time, and upload timeouts can easily lead to image loss. Summary of the invention
[0003] The embodiments of the present application provide a method, apparatus, device and storage medium for uploading pictures to solve at least one problem existing in the related art. The technical solution is as follows:
[0004] In a first aspect, an embodiment of the present application provides a method for uploading a picture, including:
[0005] Get the image to be uploaded and perform pre-upload operation to determine the upload time;
[0006] Compare the upload time with the time threshold, and when the upload time is less than or equal to the time threshold, upload the image to be uploaded to the file server;
[0007] When the upload time is greater than the time threshold, determining the storage address corresponding to the local server according to the area code corresponding to the image to be uploaded;
[0008] The pictures to be uploaded are uploaded to the storage address, unuploaded record information is generated, and according to the record information, the pictures to be uploaded in the local server are uploaded to the file server.
[0009] In one embodiment, obtaining the image to be uploaded and performing a pre-upload operation to determine the upload time includes:
[0010] Get the pictures captured by the camera;
[0011] The image is processed by the AI big model to obtain the image to be uploaded;
[0012] When the picture to be uploaded is determined, a pre-upload operation is performed, and a request upload information is sent to a queue to determine an upload time; wherein the queue is used to transfer the picture to be uploaded to the file server.
[0013] In one implementation, when the upload time is greater than a time threshold, determining the storage address corresponding to the local server according to the region code corresponding to the image to be uploaded includes:
[0014] When the upload time is greater than the time threshold, determining the area code configured by the camera that captures the image to be uploaded;
[0015] The area code is used to perform an addressing operation to determine a storage address corresponding to the area code in the local server.
[0016] In one implementation, uploading the to-be-uploaded picture to the storage address and generating the unuploaded record information includes:
[0017] Upload the image to be uploaded to the storage address, and determine the UUID corresponding to the image to be uploaded;
[0018] Using the UUID as a keyword and the storage address as a value, constructing map data, and storing the map data in the redis middleware;
[0019] The state of the to-be-uploaded image is set to a not-uploaded state, and the not-uploaded state and the UUID are uploaded to the Minio image association table to obtain the not-uploaded record information recorded in the Minio image association table.
[0020] In one implementation, uploading the to-be-uploaded pictures in the local server to the file server according to the record information includes:
[0021] When the record information is determined, request information for the image to be uploaded is sent to the queue;
[0022] In response to the request information, determine the UUID corresponding to the not uploaded state according to the Minio image association table;
[0023] Query the map data in the redis middleware according to the UUID to determine the corresponding storage address;
[0024] The image to be uploaded in the local server is obtained from the storage address, and the image to be uploaded is uploaded to the file server through the queue.
[0025] In one embodiment, the method further comprises:
[0026] When the image to be uploaded is uploaded to the file server, setting the state of the image to be uploaded to the uploaded state;
[0027] Addressing is performed according to the UUID, and the storage address is determined in the map data of the redis middleware;
[0028] Delete the Minio picture association table and the picture to be uploaded in the storage address.
[0029] In one embodiment, the method further comprises:
[0030] Detecting the upload status of the image to be uploaded to the local server or the file server, and when the upload status indicates failure and the number of failures is greater than a threshold, setting the state of the image to be uploaded to abnormal and stopping the upload;
[0031] or,
[0032] When the pictures to be uploaded are uploaded to the file server through the queue, a unique batch number is generated according to the timestamp and random number of the pictures to be uploaded, and the batch number of the upload task is updated using the unique batch number corresponding to the pictures to be uploaded in the non-uploaded state. According to the batch number update result, the corresponding pictures to be uploaded are uploaded.
[0033] In a second aspect, an embodiment of the present application provides a device for uploading a picture, including:
[0034] The acquisition module is used to acquire the image to be uploaded and perform a pre-upload operation to determine the upload time;
[0035] A comparison module, used for comparing the upload time with a time threshold, and uploading the image to be uploaded to a file server when the upload time is less than or equal to the time threshold;
[0036] A determination module, configured to determine a storage address corresponding to a local server according to a region code corresponding to the image to be uploaded when the upload time is greater than a time threshold;
[0037] The uploading module is used to upload the to-be-uploaded pictures to the storage address, generate unuploaded record information, and upload the to-be-uploaded pictures in the local server to the file server according to the record information.
[0038] In one embodiment, the upload module is further used for:
[0039] When the image to be uploaded is uploaded to the file server, setting the state of the image to be uploaded to the uploaded state;
[0040] Addressing is performed according to the UUID, and the storage address is determined in the map data of the redis middleware;
[0041] Delete the Minio picture association table and the picture to be uploaded in the storage address.
[0042] In one embodiment, the upload module is further used for:
[0043] Detecting the upload status of the image to be uploaded to the local server or the file server, and when the upload status indicates failure and the number of failures is greater than a threshold, setting the state of the image to be uploaded to abnormal and stopping the upload;
[0044] or,
[0045] When the images to be uploaded are uploaded to the file server through the queue, a unique batch number is generated according to the timestamp and random number of the images to be uploaded, and the unique batch number corresponding to the images to be uploaded that have not been uploaded is used as the target batch number to be executed and added to the upload task, and the images to be uploaded corresponding to the target batch number involved in the upload task are uploaded.
[0046] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores instructions, and the instructions are loaded and executed by the processor to implement a method in any one of the above-mentioned embodiments.
[0047] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, the method in any one of the above-mentioned embodiments is implemented.
[0048] The beneficial effects of the above technical solution include at least:
[0049] By obtaining the image to be uploaded, performing a pre-upload operation to determine the upload time, and comparing the upload time with the time threshold, when the upload time is less than or equal to the time threshold, the image to be uploaded is uploaded to the file server, that is, under normal circumstances, the image to be uploaded is directly uploaded to the file server to complete the upload of the image; when the upload time is greater than the time threshold, the storage address corresponding to the local server is determined according to the area code corresponding to the image to be uploaded, the image to be uploaded is uploaded to the storage address, and the unuploaded record information is generated. According to the record information, the image to be uploaded in the local server is uploaded to the file server. When the upload times out, the image to be uploaded is automatically uploaded to the storage address corresponding to the local server, and then the image to be uploaded in the local server is uploaded to the file server, which is conducive to avoiding upload timeouts and image losses as much as possible and ensuring the integrity of the uploaded data.
[0050] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present application will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.
[0052] Figure 1 This is a schematic diagram of the steps of a method for uploading pictures according to an embodiment of the present application;
[0053] Figure 2 This is a structural block diagram of a picture uploading device according to an embodiment of the present application;
[0054] Figure 3 This is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0055] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0056] AI big model: refers to an AI model with a large number of parameters and complex structure. Based on deep learning technology, it can process large amounts of data and learn complex patterns and relationships from it. AI big models are usually composed of millions to billions of parameters. These parameters and complex computing structures enable the model to process massive amounts of data and complete various complex tasks, such as natural language processing and image recognition. The development of AI big models has benefited from the continuous improvement of computer hardware performance and the rapid optimization of deep learning algorithms, which has led to the emergence of a series of AI applications based on big models, which have had a wide impact on social production and life.
[0057] Massive images: A collection of images with a very large amount of data. The scale of massive images is large enough to affect the way images are stored, processed, and retrieved. Traditional storage and management methods are often unable to cope with massive images.
[0058] Distributed storage: It is a data storage virtualization technology that stores data in multiple servers or storage devices in multiple physical locations. This storage method provides many advantages, including scalability, high availability, fault tolerance and better performance.
[0059] High availability: Through data replication and redundancy, data is still available even if some nodes fail.
[0060] Idempotence: In programming, an idempotent operation is one that changes the state of the system the same way no matter how many times it is executed. For example, if a function is called multiple times and changes the data in the same way as if it were called only once, then the function is idempotent.
[0061] Reference Figure 1 , showing a flow chart of a method for uploading a picture according to an embodiment of the present application, the method for uploading a picture may at least include steps S100-S400:
[0062] S100, obtaining a picture to be uploaded, and performing a pre-upload operation to determine an upload time.
[0063] S200: Compare the upload time with the time threshold, and when the upload time is less than or equal to the time threshold, upload the image to be uploaded to the file server.
[0064] S300: When the upload time is greater than the time threshold, determine the storage address corresponding to the local server according to the area code corresponding to the image to be uploaded.
[0065] S400, uploading the pictures to be uploaded to the storage address, generating the unuploaded record information, and uploading the pictures to be uploaded in the local server to the file server according to the record information.
[0066] The technical solution of the embodiment of the present application obtains the picture to be uploaded, performs a pre-upload operation to determine the upload time, compares the upload time with the time threshold, and uploads the picture to be uploaded to the file server when the upload time is less than or equal to the time threshold, that is, under normal circumstances, the picture to be uploaded is directly uploaded to the file server to complete the upload of the picture; when the upload time is greater than the time threshold, the storage address corresponding to the local server is determined according to the area code corresponding to the picture to be uploaded, the picture to be uploaded is uploaded to the storage address, and the unuploaded record information is generated. According to the record information, the picture to be uploaded in the local server is uploaded to the file server; when the upload times out, the picture to be uploaded is automatically uploaded to the storage address corresponding to the local server, and then the picture to be uploaded in the local server is uploaded to the file server, which is conducive to avoiding upload timeout and picture loss as much as possible and ensuring the integrity of the uploaded data.
[0067] In one embodiment, step S100 includes steps S110-S130:
[0068] S110: Obtaining pictures captured by the camera.
[0069] Optionally, multiple cameras will take pictures according to a preset collection interval or take pictures in real time, so that the pictures captured by the camera can be obtained through the network; since there are multiple cameras, they ultimately capture a large number of pictures, and the same operation is performed on each picture. The following description takes the processing of one of the pictures as an example.
[0070] S120: Process the image through the AI big model to obtain the image to be uploaded.
[0071] Optionally, the images are processed through AI big models, including but not limited to Proofig, GLM-4V, and AIGCDetectBenchmark, including but not limited to intelligent data cleaning, filtering of duplicate, distorted, and damaged images. For example, the collected duplicate images, and unclear images due to distorted screens, damage, etc. will be filtered out, and the images that actually need to be uploaded are left. At the same time, the AI big model can also identify the content of the image, and then classify and index the image according to the content of the image. For example, different contents such as portraits and vehicles can be classified and corresponding indexes can be established with portrait and vehicle labels.
[0072] S130: When it is determined that there are pictures to be uploaded, a pre-upload operation is performed, and an upload request message is sent to a queue to determine an upload time.
[0073] Optionally, the AI big model can be installed in the processing system in the area where the camera is located, such as an edge server or edge node, etc., to communicate with the camera, local server and file server. The processing system determines the pictures to be uploaded through the AI big model, and then performs a pre-upload operation when the pictures to be uploaded are determined, thereby sending a request to upload information to the queue, which is used to transfer the pictures to be uploaded to the file server to complete the final upload. It should be noted that after sending the request to upload information to the queue, since a large number of pictures need to be uploaded through the queue, and each picture upload takes time, the queue can determine the position of the current picture in the queue, thereby determining the upload time required for the picture.
[0074] In one embodiment, in step S200, the time threshold is pre-set based on actual conditions, for example, 10ms; the upload time is compared with the time threshold. When the upload time is less than or equal to the time threshold, it means that the upload situation is good at this time and the image can be uploaded to the file server in time. Therefore, the image to be uploaded is directly uploaded to the file server.
[0075] In one implementation, step S300 includes steps S310-S320:
[0076] S310: When the upload time is greater than the time threshold, determine the area code configured by the camera that captures the image to be uploaded.
[0077] Optionally, when the upload time is greater than the time threshold, it means that there are too many pictures to be uploaded in the queue at this time, and the current pictures cannot be uploaded to the file server in time. For example, during some peak capture periods, the number of pictures may increase, resulting in transmission difficulties and requiring timely processing. For example, this application uploads pictures to a local server, and then uploads the pictures in the local server to the file server, which is conducive to ensuring data integrity. In the embodiment of the present application, the area where each camera is located has a preset area code. For example, if the upload time of picture A is greater than the time threshold, the area code configured for the area where the camera of the corresponding picture A is located is obtained.
[0078] S320: Perform an addressing operation using the area code to determine a storage address corresponding to the area code in the local server.
[0079] In the embodiment of the present application, for the convenience of management, different storage addresses corresponding to different regions are configured in advance in the local server for partitioned storage of pictures. Therefore, the regional code is used to perform addressing operations in the local server, so as to determine the storage address (Url) corresponding to the regional code in the local server. Optionally, if the storage address cannot be found, an error is reported to prompt the personnel to manually configure it.
[0080] In an embodiment of the present application, the file server uses the Minio service as the middleware. The file server has multiple distributed nodes, and each node is split into an independent upload Minio service, that is, the load is carried out through Nginx to build a highly available, multi-node distributed service to improve the upload speed. This is because during peak hours, tens of thousands of pictures may be generated per second. Since the upload efficiency of the Minio service is approximately 0.01s / picture per second, the scheduled task will not be processed in time when processing the pictures uploaded to Minio, resulting in picture accumulation, which will cause the server's disk capacity to be used up over time.
[0081] In one implementation, during a pre-upload operation, the distributed Minio service may generate a corresponding UUID (Universally Unique Identifier) for the corresponding image to be uploaded.
[0082] In one implementation, in step S400, uploading the image to be uploaded to the storage address and generating the unuploaded record information includes steps S410-S430:
[0083] S410: Upload the image to be uploaded to the storage address, and determine the UUID corresponding to the image to be uploaded.
[0084] In the embodiment of the present application, after the storage address is determined, the image to be uploaded is uploaded to the storage address of the local server to complete the uploading of the image to be uploaded to the local server; at the same time, the UUID corresponding to the image to be uploaded is determined.
[0085] S420, using UUID as a keyword and the storage address as a value, constructing map data, and storing the map data in the redis middleware.
[0086] Then, the UUID is used as the key and the storage address is used as the value to construct the map data, and the map data is stored in the redis middleware.
[0087] S430, setting the status of the image to be uploaded to the not-uploaded status, uploading the not-uploaded status and the UUID to the Minio image association table, and obtaining the not-uploaded record information recorded in the Minio image association table.
[0088] Optionally, after the image to be uploaded is uploaded to the storage address, the status of the image to be uploaded is set to the not uploaded status, which means that it has been transferred and stored in the local server, but has not actually been uploaded to the file server. Then, the not uploaded status of the image to be uploaded and the UUID of the image to be uploaded are uploaded to the Minio image association table of the Minio service for storage. The information stored in the Minio image association table is recorded as the not uploaded record information, including the not uploaded status of the image to be uploaded and the UUID of the image to be uploaded.
[0089] In one implementation, in step S400, uploading the to-be-uploaded pictures in the local server to the file server according to the recorded information includes steps S440-S470:
[0090] S440: When the record information is determined, request information for the image to be uploaded is sent to the queue.
[0091] Optionally, when the record information is stored and determined in the Minio image association table, the local server can send request information of the image to be uploaded to the queue, and wait for the queue to upload the image to be uploaded from the local server to the file server. In one embodiment, when the record information is determined, the priority of the request information sent is higher than the upload message sent by the pre-upload operation, so it can be uploaded first; or, the queue corresponding to the pre-upload operation and the queue corresponding to the case of determining the record information can be different queues, so as to avoid the inability of the local server to upload to the file server.
[0092] S450. In response to the request information, determine the UUID corresponding to the not uploaded state according to the Minio image association table.
[0093] S460. Query the map data in the redis middleware according to the UUID to determine the corresponding storage address.
[0094] Optionally, the Minio service of the file server responds to the request information, determines the image to be uploaded that is in the not-uploaded state according to the record information recorded in the Minio image association table, and determines the UUID corresponding to the image to be uploaded, and determines the storage address corresponding to the UUID by querying the map data in the redis middleware according to the UUID.
[0095] S470: Obtain the image to be uploaded in the local server from the storage address, and upload the image to be uploaded to the file server through the queue.
[0096] Then, the Minio service of the file server obtains the images to be uploaded in the local server from the storage address, and then uses the queue to upload the images to be uploaded to the file server to complete the final upload.
[0097] It should be noted that the above embodiments are explained by taking a single picture to be sent as an example. In actual processing, Minio picture association tables, queues, etc. can record and store in batches. In addition, when uploading pictures through queues, some scenes are rushed, and the processing speed is slow due to the small network bandwidth, which can easily cause picture accumulation and disk capacity consumption too quickly. Therefore, the bandwidth can be upgraded in advance, a dedicated network can be enabled, or, as in the embodiments of the present application, multiple nodes can be deployed to achieve acceleration; at the same time, the interfaces for mutual communication between the local server, file server, and processing system in the embodiments of the present application realize idempotence, because in a distributed system, idempotent operations are crucial to ensuring the consistency and fault tolerance of the system.
[0098] In one implementation, the image uploading method of the embodiment of the present application may further include steps S510-S530:
[0099] S510: When the image to be uploaded is uploaded to the file server, the status of the image to be uploaded is set to an uploaded status.
[0100] Optionally, when the image to be uploaded is uploaded to the file server, the Minio service of the file server will set the status of the image to be uploaded in the Minio image association table to the uploaded status, indicating that the image to be uploaded has been finally uploaded.
[0101] S520. Addressing is performed according to the UUID, and a storage address is determined in the map data of the redis middleware.
[0102] Optionally, the Minio service of the file server sends a processing message to the queue indicating that the image to be uploaded has been processed, so that the file server or the local server consumes the processing message, performs addressing according to the UUID, and determines the storage address in the map data of the redis middleware.
[0103] S530, deleting the Minio image association table and the image to be uploaded in the storage address.
[0104] Optionally, the file server or local server can generate a delete instruction to delete the locally uploaded Minio image association table and other related records and the images to be uploaded in the storage address, thereby freeing up disk space for the local server and sending a message of processing completion to the queue.
[0105] In one implementation, the image uploading method of the embodiment of the present application may further include step S610 or S620:
[0106] S610, detecting the upload status of the image to be uploaded to the local server or the file server, and when the upload status indicates failure and the number of failures is greater than the number threshold, setting the state of the image to be uploaded to abnormal, and stopping the upload.
[0107] Optionally, a compensation mechanism is introduced. When the queue uploads the images to be uploaded to the file server or uploads the images to be uploaded to the local server, the upload status of the images to be uploaded to the file server is continuously detected. If the upload status indicates failure and the number of failures is greater than a threshold value n (n can be dynamically adjusted according to the business), the status of the images to be uploaded is set to abnormal and the upload is stopped to avoid repeated scanning of tasks and waste of resources. An alarm message is issued to notify manual intervention, such as locating specific problems through log troubleshooting.
[0108] S620. When uploading the images to be uploaded to the file server through the queue, a unique batch number is generated according to the timestamp and random number of the images to be uploaded, and the batch number of the upload task is updated using the unique batch number corresponding to the images to be uploaded that have not been uploaded. According to the batch number update result, the corresponding images to be uploaded are uploaded.
[0109] Optionally, because the queue processes multiple request messages, message duplication may occur in some cases. For example, concurrent execution of multiple nodes will cause repeated processing of the same image, resulting in data errors. Therefore, in the embodiment of the present application, a batch number verification algorithm designed by itself is introduced to perform a second verification on the data to ensure that the data is not executed repeatedly each time it is executed. Specifically: when uploading the image to be uploaded to the file server through the queue, a unique batch number will be generated in advance based on the timestamp of the image to be uploaded (for example, the acquisition time of the image to be uploaded) and a random number, and then the batch number is updated using the unique batch number corresponding to the image to be uploaded in the queue that is not uploaded, and the batch number update result is obtained. It should be noted that if there are identical images to be uploaded during the update, the unique batch number will be repeated at this time, and only one of the unique batch numbers after deduplication will be retained in the batch number update result, and then the corresponding image to be uploaded will be uploaded according to the batch number update result to avoid duplication.
[0110] The following is an explanation with a specific embodiment: it is assumed that a capture module (camera), a processing system (including an algorithm center module with an AI large model), ai_pa_police_warn_server (alarm service), ai_pa_police_capture_server (1400 capture service)), ai_pa_police_minio_server (minio upload service), order service, ai_pa_police_push_server are deployed, and the middleware used is Minio, rabbitmq, redis, etc.
[0111] S1: ai_pa_police_warn_server (warning service) and ai_pa_police_capture_server (capture service) call the interface of the AI big model to filter out duplicate, distorted, and damaged images, obtain the images to be uploaded, classify and index the images according to the content, and send a message requesting upload to the queue;
[0112] S2, the pictures to be uploaded generated by the alarm service in the algorithm center module are pushed to ai_pa_police_warn_server (alarm service) and ai_pa_police_capture_server (1400 capture service), and the pictures to be uploaded corresponding to the 1400 capture service are pushed to ai_pa_police_capture_server (1400 capture service). The alarm service and capture service then push the pictures to be uploaded to ai_pa_police_minio_server (minio upload service) for pre-upload operation, determine the upload time, and directly upload to the file server if the upload time is within the time threshold. At the same time, when an alarm is generated, an alarm push can also be sent to rabbitmq to trigger the push alarm to ai_pa_police_capture_server, push it to the communication software, and push text or voice.
[0113] If the upload time is outside the time threshold, the upload is interrupted, the status is set to not uploaded, and the following steps are continued:
[0114] S3, the ai_pa_police_minio_server (minio upload service) service is designed as a distributed deployment architecture, 4 nodes are deployed, and Nginx is used for load balancing to support high availability and dynamic expansion;
[0115] S4, when ai_pa_police_minio_server (minio upload service) uploads the image to be uploaded, it will store the upload record in the alarm_local_minio_rel table (i.e., the Minio image association table), record the corresponding type, associated id, UUID, upload status, whether the upload to Minio is successful, time and return the corresponding Url.
[0116] S5, monitors the queue, consumes the messages to be uploaded, processes and uploads Minio according to the data in the alarm_local_minio_rel library table, modifies the upload status to uploaded after the upload of the pictures to be uploaded is completed, and generates a message to be pushed to rabbitmq;
[0117] S6, monitor the queue, consume the uploaded message, consume the queue message and delete the to-be-uploaded pictures generated in the local server, thereby freeing up disk space. In some implementations, pictures of a specified number of days can be retained, such as 30 days of pictures.
[0118] In the embodiment of the present application, after the upload is successful, the records uploaded locally to the Minio image association table and other records will be deleted to free up disk space, thereby achieving the purpose of reducing storage costs, improving the concurrent reading performance of image processing, and enhancing capacity scalability.
[0119] Reference Figure 2 , shows a structural block diagram of a picture uploading device according to an embodiment of the present application, the device may include:
[0120] The acquisition module is used to acquire the image to be uploaded and perform a pre-upload operation to determine the upload time;
[0121] A comparison module is used to compare the upload time with the time threshold. When the upload time is less than or equal to the time threshold, the image to be uploaded is uploaded to the file server.
[0122] A determination module, used to determine the storage address corresponding to the local server according to the area code corresponding to the image to be uploaded when the upload time is greater than the time threshold;
[0123] The upload module is used to upload the images to be uploaded to the storage address, generate the record information that has not been uploaded, and upload the images to be uploaded in the local server to the file server according to the record information.
[0124] In one embodiment, the upload module is further used to:
[0125] When the image to be uploaded is uploaded to the file server, the state of the image to be uploaded is set to the uploaded state;
[0126] Addressing is performed based on UUID, and the storage address is determined in the map data of the redis middleware;
[0127] Delete the Minio image association table and the images to be uploaded in the storage address.
[0128] In one embodiment, the upload module is further used to:
[0129] Detect the upload status of the image to be uploaded to the file server. When the upload status indicates failure and the number of failures is greater than the number threshold, set the state of the image to be uploaded to abnormal and stop uploading;
[0130] or,
[0131] When uploading the images to be uploaded to the file server through the queue, a unique batch number is generated based on the timestamp and random number of the images to be uploaded. The unique batch number corresponding to the images to be uploaded that have not been uploaded is used as the target batch number to be executed and added to the upload task. The images to be uploaded corresponding to the target batch number involved in the upload task are uploaded.
[0132] The functions of each module in the device of the embodiment of the present application can be found in the corresponding description in the above method, and will not be repeated here.
[0133] Reference Figure 3 , shows a structural block diagram of an electronic device according to an embodiment of the present application, the electronic device includes: a memory 310 and a processor 320, the memory 310 stores instructions that can be run on the processor 320, and the processor 320 loads and executes the instructions to implement the image uploading method in the above embodiment. The number of the memory 310 and the processor 320 can be one or more.
[0134] In one embodiment, the electronic device also includes a communication interface 330 for communicating with external devices and performing data exchange transmission. If the memory 310, the processor 320 and the communication interface 330 are implemented independently, the memory 310, the processor 320 and the communication interface 330 can be interconnected through a bus and complete mutual communication. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0135] Optionally, in a specific implementation, if the memory 310, the processor 320 and the communication interface 330 are integrated on a chip, the memory 310, the processor 320 and the communication interface 330 can communicate with each other through an internal interface.
[0136] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the image uploading method provided in the above embodiment.
[0137] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in the memory from the memory, so that a communication device equipped with the chip executes the method provided by the embodiment of the present application.
[0138] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.
[0139] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.
[0140] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, 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).
[0141] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it 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. When the computer program instructions are loaded and executed on a computer, the process or function according to 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.
[0142] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example" or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the described specific features, structures, materials or characteristics may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.
[0143] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0144] Any process or method description in the flow chart or otherwise described herein can be understood to represent a module, fragment or portion of a code including one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.
[0145] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processor or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.
[0146] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.
[0147] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.
[0148] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for uploading a picture, characterized in that: include: Get the image to be uploaded and perform pre-upload operation to determine the upload time; Compare the upload time with the time threshold, and when the upload time is less than or equal to the time threshold, upload the image to be uploaded to the file server; When the upload time is greater than the time threshold, determining the storage address corresponding to the local server according to the area code corresponding to the image to be uploaded; The pictures to be uploaded are uploaded to the storage address, unuploaded record information is generated, and according to the record information, the pictures to be uploaded in the local server are uploaded to the file server.
2. The method for uploading pictures according to claim 1, characterized in that: The obtaining of the image to be uploaded and performing a pre-upload operation to determine the upload time includes: Get the pictures captured by the camera; The image is processed by the AI big model to obtain the image to be uploaded; When the picture to be uploaded is determined, a pre-upload operation is performed, and a request upload information is sent to a queue to determine an upload time; wherein the queue is used to transfer the picture to be uploaded to the file server.
3. The method for uploading pictures according to claim 1, characterized in that: When the upload time is greater than the time threshold, determining the storage address corresponding to the local server according to the area code corresponding to the image to be uploaded includes: When the upload time is greater than the time threshold, determining the area code configured by the camera that captures the image to be uploaded; The area code is used to perform an addressing operation to determine a storage address corresponding to the area code in the local server.
4. The method for uploading a picture according to any one of claims 1 to 3, characterized in that: The step of uploading the to-be-uploaded picture to the storage address and generating the unuploaded record information includes: Upload the image to be uploaded to the storage address, and determine the UUID corresponding to the image to be uploaded; Using the UUID as a keyword and the storage address as a value, constructing map data, and storing the map data in the redis middleware; The state of the to-be-uploaded image is set to a not-uploaded state, and the not-uploaded state and the UUID are uploaded to the Minio image association table to obtain the not-uploaded record information recorded in the Minio image association table.
5. The method for uploading pictures according to claim 4, characterized in that: The uploading of the to-be-uploaded pictures in the local server to the file server according to the record information comprises: When the record information is determined, request information for the image to be uploaded is sent to the queue; In response to the request information, determine the UUID corresponding to the not uploaded state according to the Minio image association table; Query the map data in the redis middleware according to the UUID to determine the corresponding storage address; The image to be uploaded in the local server is obtained from the storage address, and the image to be uploaded is uploaded to the file server through the queue.
6. The method for uploading pictures according to claim 5, characterized in that: The method further comprises: When the image to be uploaded is uploaded to the file server, setting the state of the image to be uploaded to the uploaded state; Addressing is performed according to the UUID, and the storage address is determined in the map data of the redis middleware; Delete the Minio picture association table and the picture to be uploaded in the storage address.
7. The method for uploading pictures according to claim 5, characterized in that: The method further comprises: Detecting the upload status of the image to be uploaded to the local server or the file server, and when the upload status indicates failure and the number of failures is greater than a threshold, setting the state of the image to be uploaded to abnormal and stopping the upload; or, When the pictures to be uploaded are uploaded to the file server through the queue, a unique batch number is generated according to the timestamp and random number of the pictures to be uploaded, and the batch number of the upload task is updated using the unique batch number corresponding to the pictures to be uploaded in the non-uploaded state. According to the batch number update result, the corresponding pictures to be uploaded are uploaded.
8. A picture uploading device, characterized in that: include: The acquisition module is used to acquire the image to be uploaded and perform a pre-upload operation to determine the upload time; A comparison module, used for comparing the upload time with a time threshold, and uploading the image to be uploaded to a file server when the upload time is less than or equal to the time threshold; A determination module, configured to determine a storage address corresponding to a local server according to a region code corresponding to the image to be uploaded when the upload time is greater than a time threshold; The uploading module is used to upload the to-be-uploaded pictures to the storage address, generate unuploaded record information, and upload the to-be-uploaded pictures in the local server to the file server according to the record information.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores instructions, and the instructions are loaded and executed by the processor to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.