Video data shooting method and device, vehicle and storage medium
By creating a background preview window during video shooting, configuring standard graphics libraries and texture identifiers, monitoring and synchronizing camera data flow, the problem of not being able to add watermarks during video shooting is solved, and efficient video data processing and system resource optimization is achieved.
Patent Information
- Application Number
- CN202510160832.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-05-13
AI Technical Summary
During video shooting, it is impossible to add watermark information to the original picture in the video through the media shooter, and in related technologies, it is necessary to add layers to the Android system layer, resulting in increased system overhead and affected user operations.
By creating a preview window running in the background and not being displayed, the standard graphics library is configured to obtain the first texture identity of the camera, and map it with the second texture identity of the preview window, start the camera, listen to the data flow, synchronize the target data flow to the preview window, and render the data flow through the standard graphics library to obtain the captured video data.
Reduces system consumption, optimizes system resources, avoids affecting the operation of the foreground interface, ensures real-time and integrity of camera data flow, and improves the speed and efficiency of image processing.
Smart Images

Figure CN119996824A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing, and in particular to a method, device, vehicle and storage medium for capturing video data. Background Art
[0002] At present, during the video shooting process, a terminal equipped with an Android operating system uses MediaRecorder to shoot based on a video shooting instruction. The original data of the Camera can be collected through MediaRecorder and saved in a file to obtain a video.
[0003] However, when it is necessary to add watermark information to the original picture in the video, this requirement cannot be achieved through the media camera; in the related technology, although watermark information can be added to the original picture when shooting videos by other means, it is necessary to add a layer on the Android system layer to always display the shot video, which not only increases the system overhead, but also easily affects the normal operation of the user. Summary of the invention
[0004] The embodiments of the present application provide a video data shooting method, device, vehicle and storage medium to solve the technical problem in the related art that a display interface at the front end is required to be always displayed during video shooting.
[0005] An embodiment of the present application provides a method for shooting video data, which includes: creating a preview window that runs in the background and is not displayed; configuring a standard graphics library to obtain a first texture identifier of a camera, and associating and mapping the first texture identifier with a second texture identifier of the preview window; starting the camera to obtain a data stream called back by the camera; monitoring the data stream based on the first texture identifier, obtaining a target data stream of a target camera and synchronizing it to the preview window, wherein the data stream carries the first texture identifier of the camera; calling the configured standard graphics library to render the target data stream to obtain the shot video data.
[0006] In one embodiment of the present application, a standard graphics library is configured to obtain a first texture identifier of the camera, and the first texture identifier is associated and mapped with a second texture identifier of the preview window, including: pre-configuring a standard graphics library, calling the standard graphics library to create the first texture identifier of the camera; associating and mapping the first texture identifier with the second texture identifier, and saving them, wherein the preview window created by the image reader carries the second texture identifier.
[0007] In one embodiment of the present application, the camera is started and the data stream callback by the camera is obtained, including: in response to the start-up instruction of the camera, calling the camera API to open the corresponding camera, the start-up instruction carries the first texture identifier of the camera; configuring the preview file of the preview window so that the preview window generates a display window of preset specifications; using the display window to receive the data stream callback by the camera until the shutdown instruction of the camera is received, and then releasing the current camera resources.
[0008] In one embodiment of the present application, the data stream is monitored based on the first texture identifier, a target data stream of a target camera is obtained and synchronized to the preview window, including: creating a callback function for monitoring the data stream, and configuring the first texture identifier as a target object monitored by the callback function; monitoring the data stream called back by the camera to determine the target data stream of the target camera; encoding the target data stream according to a preset image conversion algorithm to obtain target image data, and synchronizing the target image data to the second texture of the preview window for caching.
[0009] In one embodiment of the present application, a standard graphics library is called to perform rendering processing on the target data stream to obtain captured video data, including: based on the embedded system image library, calling the standard graphics library application programming interface to perform texture rendering on the target image data to obtain a rendered image; merging the rendered image with the second texture in layers to obtain the captured video data, and the video data is not displayed.
[0010] In one embodiment of the present application, it also includes: dividing the preview window into a first sub-window and a second sub-window; using the first sub-window to preview and display the target image data in the background; using the second sub-window to record the captured video data in the background.
[0011] In one embodiment of the present application, before starting the camera, it also includes: using the first texture identifier as the camera handle of the target camera; calling a first setting function based on the camera handle, setting a listening event, and defining a callback function for processing the listening event to obtain the callback function address; setting the listening event and the callback function address to the camera handle, calling a second setting function based on the camera handle, creating a memory space for the target camera to store the data frame, and obtaining a direct memory access address; creating a structure for storing the direct memory access address, and configuring the structure in the camera handle; wherein the number of buffers for storing the data frames is set in the structure, and the buffer address corresponding to each buffer is divided according to the number of buffers and the direct memory access address, so that each of the buffer addresses is set to the structure.
[0012] An embodiment of the present application also provides a video data shooting device, which includes: a window creation module, configured to create a preview window that runs in the background and is not displayed; a texture determination module, configured to configure a standard graphics library, obtain a first texture identifier of the camera, and associate and map the first texture identifier with a second texture identifier of the preview window; a data stream acquisition module, configured to start the camera and obtain a data stream called back by the camera; a data stream determination module, configured to monitor the data stream based on the first texture identifier, obtain a target data stream of a target camera and synchronize it to the preview window, wherein the data stream carries the first texture identifier of the camera; and a data shooting module, configured to call the configured standard graphics library to render the target data stream to obtain the shot video data.
[0013] An embodiment of the present application also provides a vehicle, which includes a video data shooting device as described in any of the above embodiments.
[0014] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method described in any one of the above embodiments is implemented.
[0015] In the scheme implemented by the video data shooting method, device, vehicle and storage medium provided above, the video data shooting method reduces system consumption and optimizes system resources by creating a preview window that runs in the background and is not displayed, avoiding affecting the operation of the foreground interface; configuring a standard graphics library, obtaining the first texture identifier of the camera, and associating and mapping the first texture identifier with the second texture identifier of the preview window, which can not only accurately display the captured data stream in the preview window, but also facilitate the addition of watermarks; starting the camera, obtaining the data stream called back by the camera; monitoring the data stream based on the first texture identifier, obtaining the target data stream of the target camera and synchronizing it to the preview window, calling the configured standard graphics library to render the target data stream to obtain the shot video data. On the one hand, only the data stream of a specific camera is processed, avoiding data confusion and errors; on the other hand, the real-time and integrity of the camera data stream are ensured, and the accurate capture and processing capabilities of the camera data stream are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor.
[0017] Figure 1 An exemplary system architecture diagram of a method for capturing video data provided in an embodiment of the present application;
[0018] Figure 2 A schematic diagram of a flow chart of a video data shooting method provided in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of a flow chart of a video data shooting method provided in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the structure of a video data shooting device provided in an embodiment of the present application;
[0021] Figure 5 A structural schematic diagram of an electronic device in an embodiment of the present application;
[0022] Figure 6 Another structural schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] In order to enable those skilled in the art to better understand the improvements of the technical solution provided by the present disclosure, the present disclosure briefly introduces the implementation scenarios and related information of the video data shooting method in the related technology.
[0025] See also Figure 1 , showing a schematic diagram of an implementation environment provided by an embodiment of the present application. The implementation environment includes a terminal, wherein the terminal integrates a camera and corresponding drivers and a graphics card, and the terminal can be a vehicle 101, a smart phone 102, a tablet computer 103, a laptop computer 104, a desktop computer 105, a smart TV, a wearable device or a vehicle-mounted terminal, etc., Figure 2 In the description, the terminal is described using a vehicle as an example, but this is not a limitation.
[0026] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.
[0027] OpenGl (Open Graphics Library, referred to as: OpenGl) is a cross-programming language, cross-platform application programming interface API (Application Programming Interface, referred to as: API) for generating two-dimensional and three-dimensional images. OpenGl consists of 350 different function calls, which are used to draw complex three-dimensional scenes from simple graphics bits. OpenGl is used in CAD, virtual reality, scientific visualization programs and video game development.
[0028] OpenGl-ES is a cross-platform, full-featured 2D and 3D graphics API designed specifically for a variety of embedded systems, including consoles, mobile phones, handheld devices, home appliances and automobiles.
[0029] Texture is a container for storing image feature data, used to save each pixel value output by OpenGl-ES.
[0030] As mentioned earlier, in order to collect the original video data of the Camera and add watermark information, the video can only be recorded through OpenGl technology. Getting the Camera data through OpenGl requires binding a valid Surface, which will not only increase the layer consumption and consume system performance, but also be detrimental to the normal use of other software on the front end.
[0031] In view of this, the embodiments of the present application provide a method, device, vehicle and storage medium for capturing video data. The vehicle can be combined with a vehicle-mounted camera, a driving recorder or a vehicle-mounted terminal as an example to illustrate the photography. Figure 2 , Figure 2 A schematic diagram of a flow chart of a video data shooting method provided in an embodiment of the present application, the method comprising the following steps:
[0032] Step S201, creating a preview window that runs in the background and is not displayed;
[0033] Among them, by creating a preview window running in the background, the image data from the camera is captured and processed without interfering with the user's current interface operation.
[0034] Exemplarily, the preview window is created by an image reader ImageReader.
[0035] Exemplarily, using the graphical interface library provided by the operating system, such as GDI / GDI+ (Graphics Device Interface) of Windows, Android can use SurfaceView to create a window or view object, but the Surface (display window) is visible.
[0036] For example, on some platforms, an image buffer in memory can be used instead of an actual window object, and the data in the buffer can be directly accessed and operated through a programming interface. Or for mobile applications, a Service (Android) or Background Task (iOS) can be used instead of a background window to process camera data in the background.
[0037] Step S202, configuring a standard graphics library, obtaining a first texture identifier of a camera, and associating and mapping the first texture identifier with a second texture identifier of the preview window;
[0038] Among them, a standard graphics library is pre-configured, and the standard graphics library is called to create a first texture identifier of the camera; the first texture identifier and the second texture identifier are associated and mapped and saved, wherein the preview window created by the image reader carries the second texture identifier.
[0039] Exemplarily, the texture mapping function of the graphics library is used to directly map the output data of the camera to a texture object in the memory, so that the image data can be efficiently processed without displaying the screen pixels. For example, the texture identifier (i.e., texture ID or handle) of the camera is obtained through the graphics library (i.e., OpenGl, DirectX repair tool), and the texture identifier represents the image data output by the camera in real time; by creating a second texture identifier associated with the preview window, and by associating and mapping the two textures through the API (application programming interface) of the graphics library, the image data captured by the camera can be directly written into the texture of the preview window, and the preview window is invisible and runs in the background.
[0040] Step S203, starting the camera and obtaining the data stream called back by the camera;
[0041] Exemplarily, the camera API is responsible for capturing image data and passing this data to the application in real time through a callback mechanism. The application can access and use the image data by processing these callbacks, starting the camera by calling the camera API (e.g., Android's Camera2 API, iOS's AVFoundation framework), and setting a callback function or listener to receive the image data captured by the camera. It is usually provided in the form of frames, each frame containing image data and related timestamps, formats, and other information.
[0042] Step S204, monitoring the data stream based on the first texture identifier, obtaining a target data stream of a target camera and synchronizing the data stream to the preview window, wherein the data stream carries the first texture identifier of the camera;
[0043] Exemplarily, by monitoring the first texture identifier in the data stream, only the data from the target camera is processed, and the extracted data is synchronized to the texture of the preview window, ensuring the continuity and availability of the image data in the background, even if the target data stream is not displayed on the screen. For example, in the camera data stream, a specific first texture identifier is monitored, and when the first texture identifier is detected, the corresponding target data stream is extracted from the data stream, and the data is synchronized to the texture of the preview window created previously.
[0044] Step S205: calling a configured standard graphics library to perform rendering processing on the target data stream to obtain the captured video data.
[0045] Exemplarily, the standard graphics library provides powerful rendering and image processing functions, which are used to perform various processing on the image data captured by the camera, namely, converting it into a video file or data stream through a video encoder, rendering the target data extracted from the camera data stream, performing various renderings, including but not limited to processing of geometry, viewpoint, texture and lighting information, and encoding the processed data into a video format.
[0046] It should be noted that the vehicle (sometimes referred to as a vehicle) in this application is a vehicle in a broad sense, which can be a means of transportation (such as: cars, trucks, motorcycles, trains, airplanes, ships, etc.), industrial vehicles (such as: forklifts, trailers, tractors, etc.), engineering vehicles (such as: excavators, bulldozers, cranes, etc.), agricultural equipment (such as mowers, harvesters, etc.), amusement equipment, toy vehicles, etc. The vehicles in this application include fuel vehicles and new energy vehicles, and there is no limitation on the type of vehicle.
[0047] In the above way, because the user will not see unnecessary preview interface, not only the resource consumption is reduced, because there is no need to render to the screen, but also the system consumption is reduced, and the speed and efficiency of image processing are improved; the data processing process is simplified through the standard graphics library, and the data copying and conversion process is reduced because the camera output is directly mapped to the memory texture. Through the callback mechanism, the camera data can be flexibly processed without blocking the main thread, ensuring that only data from the target camera is processed, avoiding data confusion and errors. By synchronizing the image data to the texture of the preview window, a convenient data access method is provided for subsequent image processing or video recording.
[0048] Optionally, in one embodiment, starting the camera and obtaining the data stream called back by the camera includes:
[0049] In response to a start instruction of the camera, calling a camera API to open the corresponding camera, wherein the start instruction carries a first texture identifier of the camera;
[0050] Configuring a preview file of the preview window so that the preview window generates a display window with preset specifications;
[0051] The display window is used to receive the data stream callback by the camera until a closing instruction of the camera is received, and then the current camera resources are released.
[0052] Exemplarily, when the application receives a camera start instruction triggered by the user, the instruction is parsed to obtain the first texture identifier of the camera. According to the first texture identifier, the camera API provided by the operating system is called to request to open the corresponding camera hardware; after opening the camera, the application needs to configure a preview window to display the real-time picture captured by the camera, which involves setting the size, resolution, frame rate and other parameters of the preview window to ensure that the picture is displayed in preset specifications. After the configuration is completed, the preview window is associated with the camera output so that the data captured by the camera can be rendered into the preview window in real time; after the preview window is configured, the camera will start to capture data and send the data to the preview window for display through the callback mechanism. The application needs to continuously monitor the callback data stream of the camera and render it into the preview window; at the same time, the application also needs to monitor the camera's shutdown instruction. If the instruction is received, it will immediately stop receiving the camera callback and release the camera resources, such as closing the camera session and releasing the preview window.
[0053] In the above manner, through texture identification, the selection of multiple camera devices can be supported, and the API provided by the operating system can be used to ensure the compatibility of the application on different devices. A consistent and high-quality camera preview experience can be provided through a preview window with preset specifications. Through the callback mechanism, real-time processing and display of camera data can be achieved, ensuring that camera resources are correctly released when no longer needed, avoiding potential resource leakage problems.
[0054] Optionally, in one embodiment, monitoring the data stream based on the first texture identifier, obtaining a target data stream of a target camera and synchronizing it to the preview window includes:
[0055] Creating a callback function for monitoring the data stream, and configuring the first texture identifier as a target object monitored by the callback function;
[0056] Monitor the data stream called back by the camera to determine the target data stream of the target camera;
[0057] The target data stream is encoded according to a preset image conversion algorithm to obtain target image data, and the target image data is synchronized to the second texture of the preview window for caching.
[0058] Among them, the callback function is a programming mode that allows the code to be automatically executed when a specific event occurs, without active calling, and the texture ID is used as a parameter of the callback function, so that the data stream is ensured to act on the target texture. By checking the metadata or header information of the data stream, the source and type of the data stream are identified based on the texture ID or the camera identifier specified in the configuration file. Image conversion algorithm is a basic technology in image processing, which is used to adjust the appearance or format of the image. Since the texture is the structure of the graphics processor to store image data, by binding the texture to the rendered preview window, the real-time display of the image can be achieved.
[0059] Exemplarily, define a callback function that is called when the camera data stream arrives. Inside the function, set logic to process or pass the received data stream. Use the camera API or framework to obtain or create a first texture for rendering, and obtain its unique identifier. Pass this first texture as the target object to the callback function to ensure that the callback function knows where to render the data. In the callback function, check the incoming data stream information, such as camera ID, data stream type, etc., and determine which data streams are target data streams from the target camera according to preset rules or conditions, and extract or retain these target data streams. Select or implement an image conversion algorithm, such as color space conversion, image scaling, compression, etc., process the target data stream, obtain the processed target image data, upload the target image data to the graphics processor, and bind it to the second texture of the preview window, ensuring that the update of the texture is synchronized with the refresh of the preview window to avoid image tearing or delay.
[0060] In the above manner, the callback function can immediately process the arriving data, realize direct rendering of the data stream, reduce intermediate processing steps, and improve the responsiveness and real-time performance of the program; at the same time, only the data stream from the target camera is processed, avoiding unnecessary resource consumption and improving the flexibility and scalability of the system; in the background operation, the graphics processor is used for caching and rendering, which reduces repeated processing and improves the overall performance.
[0061] Optionally, in one embodiment, calling a configured standard graphics library to perform rendering processing on the target data stream to obtain the captured video data includes:
[0062] Based on the embedded system image library, calling the standard graphics library application programming interface to perform texture rendering on the target image data to obtain a rendered image;
[0063] The rendered image and the second texture are layer-merged to obtain captured video data, and the video data is not displayed.
[0064] Dividing the preview window into a first sub-window and a second sub-window;
[0065] Using the first sub-window, previewing and displaying the target image data in the background;
[0066] The captured video data is recorded in the background using the second sub-window.
[0067] Exemplarily, in an embedded system, an image library supporting texture rendering is selected and integrated, an API provided by the image library is called, a rendering context is created, and a rendering target, such as a frame buffer, is configured; the target image data is input as a texture into a rendering pipeline, a rendering operation is performed, and a rendered image is generated. After the rendered image is generated, it is layer-merged with a second texture, such as, but not limited to, a background image, a watermark, or other image elements.
[0068] Exemplarily, the layer merging function or custom algorithm provided by the image library is used to merge two layers according to specified parameters such as transparency and position. The merged image data is stored in the video buffer as part of the video frame and is not displayed.
[0069] In an embedded system, create a preview window as a display area for camera preview and video recording (runs only in the background and is not displayed). Use the window management API or the function provided by the graphics library to divide the preview window into two sub-windows; the first sub-window is used to display the target image data, and the second sub-window is used to record the video data. That is, in the first sub-window, use the API provided by the image library or the camera driver to render the target image data into the window in real time for preview. In the second sub-window, use the video encoding library or the API provided by the camera driver to encode the captured camera image data into video data, and save the encoded video data to the storage medium. The recording process is carried out in the background and does not affect the user's operation of other functions.
[0070] Through the above method, the preview window is flexibly divided, and independent display areas are provided for camera preview and video recording, which improves the utilization rate and user experience of the display screen that is not displayed in the background. If the resources of the embedded system are limited or the display screen is small, a smaller preview window can be used or the resolution of the preview image can be reduced to reduce resource consumption; at the same time, the background recording and saving of video data is realized, providing users with convenient shooting and storage functions; by recording in the background, the recording process is avoided from interfering with user operations, and the flexibility and user experience of the video data shooting system are improved.
[0071] Optionally, in one embodiment, before starting the camera, the method further includes:
[0072] Using the first texture identifier as the camera handle of the target camera;
[0073] Based on the camera handle, a first setting function is called to set a monitoring event, and a callback function for processing the monitoring event is defined to obtain the callback function address;
[0074] Set the monitoring event and the callback function address to the camera handle,
[0075] Calling a second setting function based on the camera handle, creating a memory space of the target camera for storing the data frame, and obtaining a direct memory access address;
[0076] Creating a structure to store the direct memory access address, and configuring the structure in the camera handle;
[0077] The structure is provided with a number of buffers for storing the data frames, and a buffer address corresponding to each buffer is divided according to the number of buffers and the direct memory access address, so that each buffer address is set to the structure.
[0078] Specifically, the corresponding camera channel is opened according to the camera identifier of the target camera, each camera corresponds to a unique camera channel, and the camera handle of the target camera is obtained based on the camera channel to configure the target camera according to the camera handle of the target camera.
[0079] Exemplarily, the first parameter setting function corresponding to the target camera can be called through the camera handle to set the listening event and the callback function address, and the listening event and the callback function address are set in the camera handle to notify the driver service of the listening event and the callback function address. In this way, after the set listening event occurs, the driver service can execute the callback function through the callback function address to provide feedback to the application.
[0080] It should also be noted that the frame ready event refers to an event triggered when the data frame is written and can be read by the application; after the set listening event occurs, the driver service executes the callback function based on the callback function address to provide feedback to the application.
[0081] The application opens the corresponding camera channel according to the camera ID of the target camera, and obtains the camera handle of the target camera based on the camera channel.
[0082] Exemplarily, the second parameter setting function corresponding to the target camera can be called through the camera handle to set the memory handle corresponding to the current stream fetching operation. Specifically, the second parameter setting function is called to create a data stream storage space corresponding to the target camera in the shared memory between processes, namely, the DMA (Direct Memory Access) memory, and the DMA memory address corresponding to the target camera is described in the form of a constructed structure and set to the camera handle to notify the driver service of the DMA memory address. In this way, the driver service can control the target camera to write the data frame into the memory corresponding to the DMA memory address so that the application can read it directly.
[0083] For example, considering the problem that after the data frame is written, the application fails to read the data frame in time, causing the current data frame to be overwritten by the next data frame, the DMA memory corresponding to the target camera is divided into multiple buffers, each buffer has its own buffer address, so that the previous data frame will not be discarded if it is not read, ensuring that the application can read a continuous and complete camera data stream.
[0084] Through the above method, the memory of direct memory access is used as the camera data stream carrier, and the stream acquisition link is directly constructed through the stream acquisition configuration parameters and the direct memory access interface, so that the application as the client can directly read the data frame written by the camera from the shared memory between processes according to the stream acquisition link, thereby reducing the complexity of the application's stream acquisition business, avoiding the overhead of data transmission and copying between multiple levels and the conversion of image formats, and improving system performance.
[0085] See also Figure 3 , is a flow chart of a video data shooting method provided in an embodiment of the present application, which is described in detail as follows:
[0086] Use ImageReader to create a Surface that can run in the background and not be displayed on the front end;
[0087] Draw the Camera data through OpenGLES and add watermarks;
[0088] Connect Camera, OpenGLES, and Surface through SurfaceTexture;
[0089] Open the Camera through the system Camera2 API and receive the camera data stream;
[0090] Specifically, SurfaceTexture receives the camera data stream, and synchronizes the target data stream of the target camera to the background Surface according to the first texture identifier, renders the target data stream using OpenGl (ie, OpenGLES) in the background Surface, and adds a watermark effect to obtain a recorded video.
[0091] In this embodiment, an effective Surface that can run in the background is created by ImageReader to replace the Camera stream acquisition solution using SurfaceView, so as to realize background video recording and add watermark effect, effectively reducing the number of system windows and reducing the performance consumption and overhead of the system.
[0092] The video data shooting method provided in the above embodiment reduces system consumption and optimizes system resources by creating a preview window that runs in the background and is not displayed, thereby avoiding operations that affect the foreground interface; configuring a standard graphics library, obtaining a first texture identifier of the camera, and associating and mapping the first texture identifier with the second texture identifier of the preview window, which can not only accurately display the captured data stream in the preview window, but also facilitate the addition of watermarks; starting the camera, obtaining the data stream called back by the camera; monitoring the data stream based on the first texture identifier, obtaining the target data stream of the target camera and synchronizing it to the preview window, calling the configured standard graphics library to render the target data stream to obtain the shot video data. On the one hand, only the data stream of a specific camera is processed, avoiding data confusion and errors; on the other hand, the real-time and integrity of the camera data stream are ensured, and the accurate capture and processing capabilities of the camera data stream are improved.
[0093] In one embodiment, a video data shooting device is provided, and the video data shooting device is used to execute the video data shooting method provided in any of the above embodiments. Figure 4 , Figure 4 A schematic diagram of the structure of a video data shooting device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the video data shooting device includes a window creation module 401, a texture determination module 402, a data stream acquisition module 403, a data stream determination module 404 and a data shooting module 405, wherein:
[0094] The window creation module 401 is configured to create a preview window that runs in the background and is not displayed;
[0095] The texture determination module 402 is configured to configure a standard graphics library, obtain a first texture identifier of a camera, and associate and map the first texture identifier with a second texture identifier of the preview window;
[0096] The data stream acquisition module 403 is configured to start the camera and obtain the data stream called back by the camera;
[0097] A data stream determining module 404 is configured to monitor the data stream based on the first texture identifier, obtain a target data stream of a target camera and synchronize it to the preview window, wherein the data stream carries the first texture identifier of the camera;
[0098] The data shooting module 405 is configured to call a configured standard graphics library to perform rendering processing on the target data stream to obtain shot video data.
[0099] For the specific definition of the video data shooting device, please refer to the definition of the video data shooting method above, which will not be repeated here. Each module in the above-mentioned video data shooting device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0100] In this embodiment, the video data shooting device is substantially provided with multiple modules for executing the video data shooting method in any of the above embodiments. The specific functions and technical effects can be referred to the above embodiments and will not be described in detail here.
[0101] In one embodiment, a vehicle is provided, the vehicle comprising the video data shooting device provided by any one of the above embodiments.
[0102] For the specific definition of the vehicle, please refer to the definition of the video data shooting method above, which will not be repeated here. Each module in the above-mentioned vehicle can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0103] In one embodiment, an electronic device is provided. The electronic device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5As shown. The electronic device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, the functions or steps on the server side of the above method are implemented.
[0104] In one embodiment, an electronic device is provided. The electronic device may be a client, and its internal structure diagram may be as follows: Figure 6 As shown. The electronic device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, the functions or steps of the client side of the above method are implemented.
[0105] In one embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0106] Create a preview window that runs in the background and is not displayed; configure a standard graphics library, obtain a first texture identifier of the camera, and associate and map the first texture identifier with a second texture identifier of the preview window; start the camera and obtain a data stream called back by the camera; monitor the data stream based on the first texture identifier, obtain a target data stream of the target camera and synchronize it to the preview window, wherein the data stream carries the first texture identifier of the camera; call the configured standard graphics library to render the target data stream to obtain the captured video data.
[0107] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0108] Create a preview window that runs in the background and is not displayed; configure a standard graphics library, obtain a first texture identifier of the camera, and associate and map the first texture identifier with a second texture identifier of the preview window; start the camera and obtain a data stream called back by the camera; monitor the data stream based on the first texture identifier, obtain a target data stream of the target camera and synchronize it to the preview window, wherein the data stream carries the first texture identifier of the camera; call the configured standard graphics library to render the target data stream to obtain the captured video data.
[0109] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or electronic device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0110] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the above-mentioned computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0111] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device or system can be divided into different functional units or modules to complete all or part of the functions described above.
[0112] The embodiments provided above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for capturing video data, characterized in that: The method comprises: Create a preview window that runs in the background and does not display; Configure a standard graphics library, obtain a first texture identifier of a camera, and associate and map the first texture identifier with a second texture identifier of the preview window; Start the camera and obtain the data stream called back by the camera; Based on the first texture identifier, the data stream is monitored to obtain a target data stream of a target camera and synchronize the data stream to the preview window, wherein the data stream carries the first texture identifier of the camera; The configured standard graphics library is called to perform rendering processing on the target data stream to obtain the captured video data.
2. The video data shooting method according to claim 1, characterized in that: Configuring a standard graphics library, obtaining a first texture identifier of a camera, and associating and mapping the first texture identifier with a second texture identifier of the preview window, including: Preconfigure a standard graphics library, and call the standard graphics library to create a first texture identifier of the camera; The first texture identifier and the second texture identifier are associated and mapped and saved, wherein the preview window created by the image reader carries the second texture identifier.
3. The video data shooting method according to claim 1, characterized in that: Start the camera and obtain the data stream of the camera callback, including: In response to a start instruction of the camera, calling a camera API to open the corresponding camera, wherein the start instruction carries a first texture identifier of the camera; Configuring a preview file of the preview window so that the preview window generates a display window with preset specifications; The display window is used to receive the data stream callback by the camera until a closing instruction of the camera is received, and then the current camera resources are released.
4. The video data shooting method according to claim 1, characterized in that: Monitoring the data stream based on the first texture identifier, obtaining a target data stream of a target camera and synchronizing the data stream to the preview window, includes: Creating a callback function for monitoring the data stream, and configuring the first texture identifier as a target object monitored by the callback function; Monitor the data stream called back by the camera to determine the target data stream of the target camera; The target data stream is encoded according to a preset image conversion algorithm to obtain target image data, and the target image data is synchronized to the second texture of the preview window for caching.
5. The video data shooting method according to claim 4, characterized in that: Calling and configuring a standard graphics library to render the target data stream to obtain the captured video data, including: Based on the embedded system image library, calling the standard graphics library application programming interface to perform texture rendering on the target image data to obtain a rendered image; The rendered image and the second texture are layer-merged to obtain captured video data, and the video data is not displayed.
6. The video data shooting method according to claim 5, characterized in that: Also includes: Dividing the preview window into a first sub-window and a second sub-window; Using the first sub-window, previewing and displaying the target image data in the background; The captured video data is recorded in the background using the second sub-window.
7. The video data shooting method according to any one of claims 1 to 3, characterized in that: Before starting the camera, it also includes: Using the first texture identifier as the camera handle of the target camera; Based on the camera handle, a first setting function is called to set a monitoring event, and a callback function for processing the monitoring event is defined to obtain the callback function address; Set the monitoring event and the callback function address to the camera handle, Calling a second setting function based on the camera handle, creating a memory space of the target camera for storing the data frame, and obtaining a direct memory access address; Creating a structure to store the direct memory access address, and configuring the structure in the camera handle; The structure is provided with a number of buffers for storing the data frames, and a buffer address corresponding to each buffer is divided according to the number of buffers and the direct memory access address, so that each buffer address is set to the structure.
8. A video data shooting device, characterized in that: The video data shooting device comprises: A window creation module is configured to create a preview window that runs in the background and is not displayed; A texture determination module is configured to configure a standard graphics library, obtain a first texture identifier of a camera, and associate and map the first texture identifier with a second texture identifier of the preview window; A data stream acquisition module is configured to start the camera and obtain the data stream called back by the camera; a data stream determination module, configured to monitor the data stream based on the first texture identifier, obtain a target data stream of a target camera and synchronize it to the preview window, wherein the data stream carries the first texture identifier of the camera; The data shooting module is configured to call a configuration standard graphics library to perform rendering processing on the target data stream to obtain shot video data.
9. A vehicle, characterized in that: The vehicle includes the video data capturing device according to claim 8.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.