Video processing method and system based on microcontroller and programmable logic device

The integration of microcontrollers and programmable logic devices in video processing systems addresses the inefficiencies of existing solutions by breaking down the process into modular stages and employing advanced algorithms for efficient and adaptive video enhancement.

CN120321430AInactive Publication Date: 2025-07-15张金奕
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510504243.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-07-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing video processing systems have problems such as large power consumption and poor real-time performance in battery-powered devices, and the integrated system-on-chip cost is high and the development complexity is high, making it difficult to meet the deterministic requirements of industrial control scenarios. Pure programmable logic devices lack flexible task scheduling capabilities.

Method used

The video processing method based on microcontroller and programmable logic devices is adopted to obtain parameters by analyzing video files, extract and repair fuzzy areas, combine grayscale world algorithm and gamma correction algorithm to achieve white balance and correct images, and use bilinear interpolation algorithm to repair fuzzy areas, and multiplex the calculation unit through the resource sharing mechanism to save BRAM resources.

Benefits of technology

It achieves improving image quality and feature enhancement under low complexity, meeting the image processing needs of different scenarios, reducing system power consumption, improving processing efficiency and stability, supporting multiple encoding formats, ensuring smooth video playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120321430A_ABST
    Figure CN120321430A_ABST
Patent Text Reader

Abstract

The invention discloses a video processing method and system based on a microcontroller and a programmable logic device, and relates to the technical field of video processing, and the method comprises the steps: obtaining a to-be-processed video file; analyzing the video file to obtain video parameters; extracting an image of each frame, scanning the image, obtaining a fuzzy region, repairing the fuzzy region, and obtaining a repaired image; extracting a repaired image and an unrepaired image, and obtaining a white balance image in combination with a gray world algorithm; according to the white balance image, a gamma correction algorithm is combined to obtain a corrected image; according to the method, the time sequence of each corrected image is obtained, arrangement is carried out along the time sequence, the processed video file is obtained, the system performance required by a gray world algorithm and a gray value mapping table mechanism is low, and the effect is high, so that the requirements for image quality improvement and feature enhancement in different scenes are met; by multiplexing the computing unit, BRAM resources are saved, high-quality requirements are met, and dynamic balance between performance and energy efficiency is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video processing, and specifically to a video processing method and system based on a microcontroller and a programmable logic device. Background Art

[0002] Video generally refers to various technologies that capture, record, process, store, transmit, and reproduce a series of static images in the form of electrical signals. When the continuous image change exceeds 24 frames per second, according to the principle of persistence of vision, the human eye cannot distinguish a single static image; it appears as a smooth and continuous visual effect, and such continuous pictures are called videos. Video technology was originally developed for television systems, but now it has developed into various different formats to facilitate consumers to record videos. The development of network technology has also promoted video clips to exist in the form of streaming media on the Internet and can be received and played by computers. Video and film belong to different technologies. The latter uses photography to capture dynamic images as a series of static photos.

[0003] Current video processing systems mainly adopt the following technical solutions: The pure processor solution: relying on a high-performance processor to run software algorithms, although it has high flexibility, it has problems such as high power consumption and poor real-time performance, and it is difficult to be deployed in battery-powered devices. And the integrated system-on-chip solution: using heterogeneous chips, although it can achieve hardware acceleration, the chip cost is high, and the development complexity is high. It needs to rely on an operating system and is difficult to meet the deterministic requirements of industrial control scenarios. And the pure programmable logic device solution: realizing the full-process processing through hardware logic, although it has low latency, it lacks flexible task scheduling capabilities. Functions such as file system parsing and user interaction need to add a soft-core processor additionally, resulting in waste of logic resources. Therefore, the present invention proposes a video processing method and system based on a microcontroller and a programmable logic device. Summary of the Invention

[0004] To solve the above technical problems, a video processing method and system based on a microcontroller and a programmable logic device are provided, which solve the problem of being unable to balance performance and energy efficiency.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A video processing method based on a microcontroller and a programmable logic device, including: S100. Obtain a video file to be processed; S200. Analyze the video file to obtain video parameters; S300. Extract each frame of the image and perform scanning, obtain a blurred area and perform repair, and obtain a repaired image; S400. Extract the repaired image and the unrepaired image, and combine with the gray world algorithm to obtain a white balance image; S500. Obtain a corrected image based on the white balance image and in combination with the gamma correction algorithm; S600. Obtain the timing of each corrected image and arrange them along the timing to obtain a processed video file.

[0006] Preferably, the steps for parsing the video file to obtain video parameters include the following: S201. Obtain the file format; S202. If the file format is a compressed format, convert the video file into raw data; S203. If the file format is not a compressed format, scan the video file; S204. Obtain the frame rate based on the timestamp of each frame in the video file; S205. Obtain the resolution based on the edge detection algorithm; S206. Obtain the video bit rate based on the size and total duration of the video file.

[0007] Preferably, the steps for converting the video file into raw data if the file format is a compressed format include the following: S2021. Obtain the video file compression algorithm; S2022. Convert the video file according to the compression algorithm to obtain raw data; S2023. Based on the raw data, repeat steps S204 - S206.

[0008] Preferably, the steps for extracting the image of each frame, scanning it, obtaining the blurred area, and repairing it include the following: S301. Extract the image of each frame and scan it to obtain the pixel values of multiple images; S302. Construct a pixel matrix based on the pixel points of the image; S303. Based on the pixel matrix and in combination with the Sobel operator, obtain the edge features of multiple images; S304. Obtain the edge gradient of each image edge feature, and obtain the blurred area based on the edge gradient; S305. Based on the blurred area and in combination with the bilinear interpolation algorithm, repair the blurred area.

[0009] Preferably, the steps for obtaining the edge gradient of each image edge feature and obtaining the blurred area based on the edge gradient include the following: S3041. Based on the pixel matrix, obtain the edge gradient amplitude and gradient direction of each image edge feature; S3042. Match according to the area where the image edge feature is located, the edge gradient amplitude, and the gradient direction; S3043. Judge the image according to the edge gradient magnitude and gradient direction; S3044. If the edge gradient magnitude is small or the gradient direction is random, then this area is a blurred area; S3045. If the edge gradient magnitude is large and the gradient direction is not random, then this area is not a blurred area.

[0010] Preferably, the repairing the blurred area by combining the bilinear interpolation algorithm according to the blurred area includes the following steps: S3051. Obtain the surrounding pixel values of the pixel points around the blurred area; S3052. Obtain the processing order of the pixel points according to the coordinate positions of the pixel points within the blurred area; S3053. Extract the current pixel point, mark it as a pixel point to be repaired, and cache the next pixel point according to the processing order; S3054. Select multiple surrounding pixel points according to the coordinate values, and obtain the corresponding interpolation weights between the surrounding pixel points and this pixel point; S3055. Obtain the pixel value of the pixel point to be repaired according to the interpolation weights and combine with the corresponding surrounding pixel values, and perform replacement and marking.

[0011] Preferably, the obtaining the white balance image by combining the gray world algorithm for the repaired image and the unrepaired image includes the following steps: S401. Extract the repaired image and the unrepaired image, and combine with the pixel matrix to obtain the red, green, and blue channel values of each pixel point in each image; S403. Calculate the average values of the red, green, and blue channels within each image respectively; S403. Obtain a reference value according to the channel average values, where the reference value is the average value of the three color channel average values; S404. Obtain the gain coefficient of each color channel according to the reference value; S405. Adjust each pixel point according to the gain coefficient to obtain the adjusted pixel value, where the adjusted pixel value is the value of the red, green, and blue channels of each pixel point multiplied by the gain coefficient corresponding to each color channel; S406. Replace the corresponding pixel points with the adjusted pixel values to obtain the white balance image.

[0012] Preferably, the obtaining the corrected image by combining the gamma correction algorithm according to the white balance image includes the following steps: S501. Obtain the corresponding adjustment value according to the magnitude of the gray value by combining the gamma correction algorithm, where the range of the gray value is 0-255; S502. Construct an adjustment chart according to multiple adjustment values; S503. Obtain the pixel gray value of each pixel in the white balance image according to each white balance image; S504. Match the pixel gray value with the adjustment chart, obtain the corrected pixel value corresponding to each pixel, and replace the corresponding pixel.

[0013] Preferably, a video processing system based on a microcontroller and a programmable logic device is proposed, which is used to implement the above-mentioned video processing method based on a microcontroller and a programmable logic device, including: Control module: The control module is used to control the data transmission within the system; Storage module: The storage module is used to store system data and facilitate system reading; Demosaicing module: The demosaicing module is used to repair video files; Automatic white balance module: The automatic white balance module is used to adjust the brightness of the repaired video file; Color correction module: The color correction module is used to perform color correction on the adjusted video file; Timing control module: The timing control module is used to design a video timing generation circuit.

[0014] Compared with the prior art, the advantages of the present invention are as follows: By splitting the video processing process into independent modules such as parameter parsing, blur repair, white balance correction, and gamma correction, the video processing is divided into two-level pipelines with low complexity (such as parameter parsing, gray world algorithm) and high complexity (such as blur repair, gamma correction). At the same time, the computing unit is reused through a resource sharing mechanism, the blurred area is accurately located by dynamically evaluating the image edge features, and the bilinear interpolation algorithm is used to repair based on the weights of surrounding pixels. The row buffer structure is adopted to cache only two rows of pixels to save BRAM resources. The global gain coefficient is calculated by the gray world algorithm and adaptively adjusted according to the dynamic range of different color channels. The gray value mapping table mechanism is introduced, and by pre-establishing the correspondence between gray values and corrected values, fast lookup and replacement of pixel-level correction are realized, greatly shortening the processing time, and at the same time improving the stability of the correction result. The gray world algorithm and the gray value mapping table mechanism require low system performance and have high effects to meet the requirements of image quality improvement and feature enhancement in different scenarios, and achieve a dynamic balance between performance and energy efficiency by reusing the computing unit, saving BRAM resources and meeting high-quality requirements. Description of the Drawings

[0015] Figure 1 It is a schematic flowchart of steps S100 - S600 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 2Schematic flowchart of steps S201 - S206 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 3 Schematic flowchart of steps S2021 - S2023 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 4 Schematic flowchart of steps S301 - S305 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 5 Schematic flowchart of steps S3041 - S3045 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 6 Schematic flowchart of steps S3051 - S3055 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 7 Schematic flowchart of steps S401 - S406 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 8 Schematic flowchart of steps S501 - S504 in the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention; Figure 9 Block diagram of the video processing method and system based on a microcontroller and a programmable logic device proposed by the present invention. Detailed implementation

[0016] The following description is used to disclose the present invention so that those skilled in the art can implement the present invention. The preferred embodiments in the following description are only examples, and those skilled in the art can think of other obvious variations.

[0017] Refer to Figures 1-9 As shown, the video processing method based on a microcontroller and a programmable logic device includes: S100. Obtain the video file to be processed; S200. Analyze the video file to obtain video parameters; S300. Extract each frame of the image and perform scanning, obtain the blurred area and perform repair, and obtain the repaired image; S400. Extract the repaired image and the unrepaired image, and combine with the gray world algorithm to obtain the white balance image; S500. Based on the white balance image, combine with the gamma correction algorithm to obtain the corrected image; S600. Obtain the timing of each calibrated image, arrange them along the timing, and obtain the processed video file; Those skilled in the art can understand that video parameters include resolution, frame rate, and video bit rate. The resolution determines the width and height dimensions of the video, affecting the accuracy of subsequent blur detection and repair. The frame rate can obtain the number of frames per second, which is used for timing arrangement and real-time analysis. The video bit rate reflects the compression quality of the video, providing a reference for optimization processing. Dynamically adjust the subsequent processing strategy according to the video parameters. Through edge gradient analysis, locate the blurred area, adopt the bilinear interpolation algorithm, and use the surrounding pixel information to repair the blurred area to improve the image clarity. Based on the gray world assumption (the average reflectance of the scene is neutral gray), adjust the gain coefficients of the red, green, and blue channels to achieve automatic white balance. The gray world algorithm is simple to calculate and suitable for parallel processing of microcontrollers and programmable logic devices. The gamma correction algorithm adjusts the gray value and brightness of the image, enhancing the layering and detail performance of the picture, enhancing the details of highlights and shadows, avoiding overexposure or underexposure, ensuring the unity of the color style of different frames, avoiding jumps in the picture after timing arrangement, arranging precisely according to the frame timestamp, ensuring smooth video playback, avoiding frame loss or timing disorder, supporting multiple coding formats (H.264, H.265), and ensuring compatibility with mainstream playback devices.

[0018] Such as Figure 2 As shown, parsing the video file to obtain video parameters includes the following steps: S201. Obtain the file format; S202. If the file format is a compressed format, convert the video file into raw data; S203. If the file format is not a compressed format, scan the video file; S204. Obtain the frame rate according to the timestamp of each frame in the video file; S205. Obtain the resolution according to the edge detection algorithm; S206. Obtain the video bit rate according to the size and total duration of the video file.

[0019] Such as Figure 3 As shown, if the file format is a compressed format, converting the video file into raw data includes the following steps: S2021. Obtain the video file compression algorithm; S2022. Convert the video file according to the compression algorithm to obtain raw data; S2023. According to the raw data, repeat steps S204 - S206; Those skilled in the art can understand that by determining the encoding format of the video file (such as MP4, AVI, MKV, RAW, etc.), a suitable parsing path can be selected for subsequent processing. Since the compressed format cannot directly access frame-level information (such as timestamps, pixel values), it needs to be decoded for subsequent analysis. By parsing the video file header (such as the ftyp box in MP4, the RIFF header in AVI) or the streaming media protocol (such as the SDP information in RTSP), the compression algorithm of the video can be determined, and the corresponding decoder (such as libx264, libx265 in FFmpeg) can be called to restore the compressed video stream to the original frame data. For non-compressed formats (such as YUV, RAW), no decoding is required. The timestamp of each frame is parsed from the video stream, and the time interval between adjacent frames is calculated to achieve the calculation of the frame rate. The Sobel algorithm is used to perform edge detection on the video frames, the number of width and height pixels of the image is analyzed, and the resolution of the video frame is determined based on the edge pixel distribution range. Cross-verification is performed in combination with the file header parameters to improve the accuracy of resolution extraction. The video bitrate reflects the compression degree of the video. A high bitrate usually corresponds to high image quality, and a low bitrate may have compression artifacts.

[0020] As Figure 4 shown, extracting the image of each frame and performing scanning to obtain the blurred area and performing restoration includes the following steps: S301: Extract the image of each frame and perform scanning to obtain the pixel values of multiple images; S302: Construct a pixel matrix based on the pixel points of the image; S303: Based on the pixel matrix and in combination with the Sobel operator, obtain the edge features of multiple images; S304: Obtain the edge gradient of each image edge feature, and obtain the blurred area based on the edge gradient; S305: Based on the blurred area and in combination with the bilinear interpolation algorithm, repair the blurred area; Those skilled in the art can understand that video frames are a sequence of dynamic images and need to be processed frame by frame. The image data is extracted frame by frame from the video stream, and each pixel point is scanned to obtain its RGB value. The pixel values of the image are arranged in a two-dimensional matrix by row and column. If the image resolution is 1920x1080, a pixel matrix of 1920 rows × 1080 columns is constructed. The Sobel operator is used to perform convolution on the pixel matrix to calculate the gradient magnitude and direction of each pixel point, extract the image edge features, extract the gradient magnitude from the edge features, analyze the local change intensity of the image, and use the bilinear interpolation algorithm to perform pixel value interpolation on the blurred area to restore the clarity.

[0021] As Figure 5 shown, obtaining the edge gradient of each image edge feature and obtaining the blurred area based on the edge gradient includes the following steps: S3041. Obtain the edge gradient magnitude and gradient direction of each image edge feature based on the pixel matrix; S3042. Match according to the area where the image edge feature is located, the edge gradient magnitude, and the gradient direction; S3043. Judge the image according to the magnitude of the edge gradient and the gradient direction; S3044. If the edge gradient magnitude is small or the gradient direction is random, then this area is a blurred area; S3045. If the edge gradient magnitude is large and the gradient direction is not random, then this area is not a blurred area; Those skilled in the art can understand that the Sobel operator is used to calculate the gradient of the pixel matrix, extract the gradient magnitude and gradient direction of each pixel point in the image. The gradient magnitude reflects the edge strength, and the gradient direction represents the edge orientation. The position of the edge feature is associated with its gradient magnitude and direction to construct a gradient distribution model. By analyzing the statistical characteristics of the edge gradient magnitude and direction, it is judged whether the image area is a blurred area. A small edge gradient magnitude indicates weak edge strength caused by blurring, and a random gradient direction indicates inconsistent edge orientation caused by defocus or motion blur. A large edge gradient magnitude indicates high edge strength, which is a characteristic of a clear area, and a non-random gradient direction indicates consistent edge orientation, which is a characteristic of a sharp edge.

[0022] As Figure 6 shown, based on the blurred area and combined with the bilinear interpolation algorithm, the steps for repairing the blurred area are as follows: S3051. Obtain the surrounding pixel values of the pixel points around the blurred area; S3052. Obtain the processing order of the pixel points according to the coordinate positions of the pixel points within the blurred area; S3053. Extract the current pixel point, mark it as the pixel point to be repaired, and cache the next pixel point according to the processing order; S3054. Select multiple surrounding pixel points according to the coordinate values, and obtain the corresponding interpolation weights between the surrounding pixel points and this pixel point; S3055. Obtain the pixel value of the pixel point to be repaired according to the interpolation weights and in combination with the corresponding surrounding pixel values, and perform replacement and marking; Those skilled in the art can understand that the repair of the pixel points in the blurred area depends on the clear or relatively clear pixel values around them as a reference. By extracting the values of the surrounding pixel points, it provides basic data for subsequent interpolation calculations. Determining the processing order through the coordinate positions can avoid repeated calculations and improve the repair efficiency. Processing the pixel points in order can ensure that the repaired pixel points no longer participate in subsequent calculations, avoiding interference in the interpolation weight calculation. Marking the current pixel point as the state to be repaired is convenient for subsequent interpolation calculations and result updates. Caching the next pixel point can prepare the calculation data in advance and reduce the processing delay. Through the marking and caching mechanisms, the repair progress can be tracked in real time to ensure that each pixel point is only processed once. The interpolation weight reflects the contribution degree of the surrounding pixel points to the repair of the current pixel point. Calculating the weight through the coordinate values can quantify the contribution degree. By weighted summation, the final pixel value of the pixel point to be repaired is calculated. The combination of the interpolation weight and the surrounding pixel values can ensure that the repair result not only conforms to the spatial continuity but also retains the detail information, avoiding over-smoothing or distortion. At the same time, a row buffer structure is adopted, and only two rows of pixels are cached to save BRAM resources.

[0023] As Figure 7 shown, to extract the repaired image and the unrepaired image and combine with the gray world algorithm to obtain the white balance image, the following steps are included: S401: Extract the repaired image and the unrepaired image, and combine with the pixel matrix to obtain the red, green, and blue channel values of each pixel point in each image; S403: Calculate the average values of the red, green, and blue channels within each image respectively; S403: Obtain the reference value according to the channel average values, where the reference value is the average of the average values of the three color channels; S404: Obtain the gain coefficient for each color channel according to the reference value; S405: Adjust each pixel point according to the gain coefficient to obtain the adjusted pixel value, where the adjusted pixel value is the value of the red, green, and blue channels of each pixel point multiplied by the gain coefficient corresponding to each color channel; S406: Replace the corresponding pixel points with the adjusted pixel values to obtain the white balance image; Those skilled in the art can understand that the uncorrected image is an image that has not been blurred. By decomposing the RGB channel values of the image through a pixel matrix, it provides basic data for subsequent statistical analysis. The channel average value reflects the overall color tendency of the image. The reference value, as the theoretical target value of neutral gray, is used to measure the color deviation degree of the image. The reference value unifies the RGB channels to the same benchmark to ensure the gray-scale consistency of the image after white balance adjustment. The gain coefficient reflects the color deviation degree of each channel. By calculating the gain coefficient for each of the RGB channels respectively, the color deviation of each channel can be corrected independently, avoiding cross-interference. At the same time, the gain coefficient maps the image color to the neutral gray benchmark to ensure that the color distribution of the image after white balance conforms to human eye perception. By adjusting the pixel values, the color deviation is corrected pixel by pixel to achieve the consistency of global and local colors. After replacing the original pixel values, a white balance image is generated to ensure the neutrality of the overall color of the image.

[0024] As Figure 8 shown, based on the white balance image and combined with the gamma correction algorithm, obtaining the corrected image includes the following steps: S501: According to the magnitude of the gray value and combined with the gamma correction algorithm, obtain the corresponding adjustment value, where the range of the gray value is 0 to 255; S502: Construct an adjustment chart based on multiple adjustment values; S503: For each white balance image, obtain the pixel gray value of each pixel point in the white balance image; S504: Match the pixel gray value with the adjustment chart to obtain the corrected pixel value corresponding to each pixel point, and replace the corresponding pixel point; Those skilled in the art can understand that gamma correction adjusts the gray value through non-linear transformation, enhances the details in the dark part or suppresses the overexposure of the highlights, and improves the visual hierarchy of the image. By allocating dynamic adjustment values for different gray values (0 to 255), the adjustment chart establishes a mapping relationship between the gray value and the adjustment value, reducing the real-time calculation overhead and improving the processing efficiency. The adjustment chart can be reused for similar image processing tasks. Extracting the gray value from the RGB image, the gray value is used as single-channel data, simplifying the calculation complexity while retaining the image brightness information. By quickly looking up the corrected value corresponding to the gray value through the adjustment chart, the brightness is adjusted pixel by pixel to achieve the dynamic balance of global and local brightness. The corrected pixel value can highlight the texture in the dark part or suppress the noise in the highlights, improving the detail expressiveness of the image. On the basis of the white balance image, the brightness is further adjusted to ensure the unity of color and brightness, avoiding the problem of color cast but brightness imbalance.

[0025] As Figure 9 shown, a video processing system based on a microcontroller and a programmable logic device is proposed, which is used to implement the above-mentioned video processing method based on a microcontroller and a programmable logic device, including: A control module: The control module is used to control the data transmission within the system; Storage module: The storage module is used to store system data and facilitate system reading; Demosaicing module: The demosaicing module is used to repair video files; Automatic white balance module: The automatic white balance module is used to adjust the brightness of the repaired video file; Color correction module: The color correction module is used to perform color correction on the adjusted video file; Timing control module: The timing control module is used to design a video timing generation circuit.

[0026] In summary, the advantages of the present invention are as follows: By splitting the video processing process into independent modules such as parameter parsing, blur repair, white balance correction, and gamma correction, the video processing is divided into two-level pipelines of low complexity (such as parameter parsing, gray world algorithm) and high complexity (such as blur repair, gamma correction). At the same time, the computing unit is reused through a resource sharing mechanism, the blurred area is accurately located by dynamically evaluating the image edge features, and the bilinear interpolation algorithm is used to repair based on the weights of surrounding pixels. The row buffer structure is adopted, and only two rows of pixels are cached to save BRAM resources. The global gain coefficient is calculated by the gray world algorithm, and adaptive adjustment is performed for the dynamic ranges of different color channels. The gray value mapping table mechanism is introduced. By pre-constructing the correspondence between gray values and correction values, fast lookup and replacement of pixel-level correction are realized, significantly shortening the processing time and improving the stability of the correction results at the same time. The gray world algorithm and the gray value mapping table mechanism require relatively low system performance and have high effects to meet the requirements for improving image quality and enhancing features in different scenarios. Through reusing the computing unit, saving BRAM resources, and meeting high-quality requirements, a dynamic balance between performance and energy efficiency is achieved.

[0027] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments. What is described in the above embodiments and the specification is only the principle of the present invention. Without departing from the spirit and scope of the present invention, the present invention will have various changes and improvements, and these changes and improvements all fall within the scope of the present invention claimed. The scope of protection claimed by the present invention is defined by the appended claims and their equivalents.

Claims

1. A video processing method based on a microcontroller and a programmable logic device, characterized in that Including: S100. Obtain the video file to be processed; S200. Analyze the video file to obtain video parameters; S300. Extract the image of each frame and perform scanning, obtain the blurred area and repair it, and obtain the repaired image; S400. Extract the repaired image and the unrepaired image, and combine with the gray world algorithm to obtain the white balance image; S500. Based on the white balance image, combine with the gamma correction algorithm to obtain the corrected image; S600. Obtain the timing of each corrected image and arrange them along the timing to obtain the processed video file.

2. The video processing method based on a microcontroller and a programmable logic device according to claim 1, characterized in that: The step of analyzing the video file to obtain video parameters includes the following steps: S201. Obtain the file format; S202. If the file format is a compressed format, convert the video file into raw data; S203. If the file format is not a compressed format, scan the video file; S204. Based on the timestamp of each frame in the video file, obtain the frame rate; S205. Based on the edge detection algorithm, obtain the resolution; S206. Based on the size and total duration of the video file, obtain the video bit rate.

3. The video processing method based on a microcontroller and a programmable logic device according to claim 2, wherein: The step of if the file format is a compressed format, convert the video file into raw data includes the following steps: S2021. Obtain the video file compression algorithm; S2022. Convert the video file according to the compression algorithm to obtain raw data; S2023. Based on the raw data, repeat steps S204 - S206.

4. The video processing method based on a microcontroller and a programmable logic device according to claim 1, wherein: The step of extracting the image of each frame and performing scanning, obtaining the blurred area, and repairing it includes the following steps: S301. Extract the image of each frame and perform scanning to obtain the pixel values of multiple images; S302. Construct a pixel matrix based on the pixel points of the image; S303. Based on the pixel matrix, combine with the Sobel operator to obtain multiple image edge features; S304. Obtain the edge gradient of each image edge feature, and obtain the blurred area based on the edge gradient; S305. Based on the blurred area, combine with the bilinear interpolation algorithm to repair the blurred area.

5. The video processing method based on a microcontroller and a programmable logic device according to claim 4, wherein: The step of obtaining the edge gradient of each image edge feature and obtaining the blurred area based on the edge gradient includes the following steps: S3041. Based on the pixel matrix, obtain the edge gradient amplitude and gradient direction of each image edge feature; S3042. Match according to the area where the image edge feature is located and the edge gradient amplitude and gradient direction; S3043. Judge the image based on the edge gradient amplitude size and gradient direction; S3044. If the edge gradient amplitude is small, or the gradient direction is random, then this area is the blurred area; S3045. If the edge gradient amplitude is large and the gradient direction is not random, then this area is not the blurred area.

6. The video processing method based on a microcontroller and a programmable logic device according to claim 4, characterized in that: The step of based on the blurred area, combine with the bilinear interpolation algorithm to repair the blurred area includes the following steps: S3051. Obtain the surrounding pixel values of the pixel points around the blurred area; S3052. Based on the coordinate positions of the pixel points in the blurred area, obtain the processing order of the pixel points; S3053. Extract the current pixel point, mark it as the pixel point to be repaired, and cache the next pixel point according to the processing order; S3054. Select multiple surrounding pixel points according to the coordinate values, and obtain the corresponding interpolation weights between the surrounding pixel points and this pixel point; S3055. According to the interpolation weights, combined with the corresponding surrounding pixel values, obtain the pixel value of the pixel point to be repaired, and perform replacement and marking.

7. The video processing method based on a microcontroller and a programmable logic device according to claim 1, characterized in that: The steps of extracting the repaired image and the unrepaired image, and combining the gray world algorithm to obtain the white balance image are as follows: S401. Extract the repaired image and the unrepaired image, and combine the pixel matrix to obtain the red, green, and blue channel values of each pixel point in each image; S403. Calculate the average values of the red, green, and blue channels in each image respectively; S403. Obtain a reference value according to the channel average values, where the reference value is the average value of the average values of the three color channels; S404. Obtain the gain coefficient of each color channel according to the reference value; S405. Adjust each pixel point according to the gain coefficient to obtain the adjusted pixel value, where the adjusted pixel value is the value of the red, green, and blue channels of each pixel point multiplied by the gain coefficient corresponding to each color channel; S406. Replace the corresponding pixel points with the adjusted pixel values to obtain the white balance image.

8. The video processing method based on a microcontroller and a programmable logic device according to claim 1, characterized in that: The steps of obtaining the corrected image by combining the gamma correction algorithm based on the white balance image are as follows: S501. According to the size of the gray value, combined with the gamma correction algorithm, obtain the corresponding adjustment value, where the range of the gray value is 0 to 255; S502. Construct an adjustment chart according to multiple adjustment values; S503. According to each white balance image, obtain the pixel gray value of each pixel point in the white balance image; S504. Match the pixel gray value with the adjustment chart to obtain the corrected pixel value corresponding to each pixel point, and replace the corresponding pixel points.

9. A video processing system based on a microcontroller and a programmable logic device, which is used to implement the video processing method based on a microcontroller and a programmable logic device as described in claims 1-8, characterized in that, Including: Control module: The control module is used to control the data transmission within the system; Storage module: The storage module is used to store the system data and facilitate the system to read; Demosaicing module: The demosaicing module is used to repair the video file; Automatic white balance module: The automatic white balance module is used to adjust the brightness of the repaired video file; Color correction module: The color correction module is used to perform color correction on the adjusted video file; Timing control module: The timing control module is used to design the video timing generation circuit.