AR processing method and device, electronic equipment and storage medium

By acquiring the video stream on the mobile terminal and using the target processing model of the virtual application scenario for AR processing, the problems of long AR processing time and poor realism in the existing technology are solved, and an efficient and realistic AR experience is achieved.

CN118628689APending Publication Date: 2024-09-10小芒电子商务有限责任公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410666310.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the existing technology, AR processing takes a lot of time and has poor realism.

Method used

By obtaining the video stream collected by the camera on the mobile terminal, the virtual application scene corresponding to the video object is determined, and the pre-built target processing model is used to preprocess and process the video stream to generate target AR, reducing reliance on third-party platforms.

Benefits of technology

It improves the efficiency of AR processing, enhances the realism effect of AR, and provides a more immersive and seamless AR experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628689A
    Figure CN118628689A
Patent Text Reader

Abstract

The invention provides an AR processing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining an initial video stream collected based on a camera of a mobile terminal when receiving a camera authority authorization passing feedback of the mobile terminal; determining whether a virtual application scene corresponding to a video object in the initial video stream exists or not; if yes, obtaining the virtual application scene, and determining a target processing model corresponding to the virtual application scene; preprocessing the initial video stream based on the virtual application scene to obtain a target video stream; and processing the target video stream by using the target processing model to obtain a target AR. According to the method, AR processing is carried out on the target video stream through the target processing model corresponding to the virtual application scene without the help of a third-party platform, the target AR is obtained, the AR processing time can be shortened, and the reality effect of the obtained AR is better.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of AR data processing technology, and in particular to an AR processing method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of new media, the virtual world and real world scenes can be combined through virtual reality or augmented reality AR technology, so that the combined pictures or videos can achieve realism.

[0003] Currently, users often use third-party platforms to perform secondary creation on their uploaded images, such as constructing virtual objects and performing AR processing. This method takes a lot of time and the resulting AR is prone to poor realism. Summary of the invention

[0004] In view of this, the embodiments of the present invention provide an AR processing method, device, electronic device and storage medium to solve the problems in the prior art that a lot of time is consumed and the obtained AR is prone to poor realism effect.

[0005] To achieve the above objectives, the embodiments of the present invention provide the following technical solutions:

[0006] An embodiment of the present invention shows an AR processing method, which includes:

[0007] When receiving feedback that the camera permission of the mobile terminal is authorized, obtaining an initial video stream collected by the camera of the mobile terminal;

[0008] Determining whether there is a virtual application scene corresponding to the video object in the initial video stream;

[0009] If so, obtaining the virtual application scenario and determining a target processing model corresponding to the virtual application scenario;

[0010] Preprocessing the initial video stream based on the virtual application scenario to obtain a target video stream;

[0011] The target video stream is processed using the target processing model to obtain a target AR.

[0012] Optionally, determining whether there is a virtual application scene corresponding to the video object in the initial video stream includes:

[0013] Inputting the video object in the initial video stream into a pre-built AR recognition engine, the pre-built AR recognition engine recognizes the video object and outputs a recognition result, wherein the AR recognition engine is pre-built based on historical AR materials uploaded by multiple users;

[0014] If the recognition result shows that the recognition is successful, it is determined that there is a virtual application scene corresponding to the video object in the initial video stream.

[0015] Optionally, determining a target processing model corresponding to the virtual application scenario includes:

[0016] The virtual application scenario is used to search for a plurality of pre-constructed processing models, and a target processing model corresponding to the virtual application scenario is determined, wherein the processing model is pre-constructed.

[0017] Optionally, preprocessing the initial video stream based on the virtual application scenario to obtain a target video stream includes:

[0018] Determining corresponding scenario requirements based on the virtual application scenario;

[0019] The video objects in the initial video stream are adjusted according to the scene requirements to obtain a target video stream.

[0020] Optionally, using the target processing model to process the target video stream to obtain a target AR includes:

[0021] Extracting video frames from the target video stream to obtain multiple frames of images;

[0022] Process each frame of the image, determine the target frame related to the virtual application scene, and use the target frame as the background layer;

[0023] Determine a virtual object corresponding to the virtual application scene based on the processing model, and display the virtual object and the background layer to the user;

[0024] receiving a first movement operation for a virtual object;

[0025] Determining a superimposed position of the virtual object on the background layer in response to the first movement operation;

[0026] The virtual object is rendered to a corresponding superimposed position to obtain a target AR.

[0027] Optionally, processing each frame of the image to determine a target frame related to the virtual application scene includes:

[0028] Identify each frame of the image to determine whether it contains features related to the virtual application scene;

[0029] If included, the frame image is used as the target frame.

[0030] Optionally, also include:

[0031] Receiving a virtual application scene selected on a mobile terminal;

[0032] In response to the virtual application scene, determining a virtual object corresponding to the virtual application scene;

[0033] When receiving feedback that the camera permission of the mobile terminal is authorized, obtaining an initial video stream collected by the camera of the mobile terminal;

[0034] If it is determined that the initial video stream matches the virtual application scene, preprocessing the initial video stream based on the virtual application scene to obtain a target video stream;

[0035] The virtual object and the target video stream are rendered to obtain a target AR.

[0036] A second aspect of an embodiment of the present invention shows an AR processing device, the device comprising:

[0037] An acquisition unit, configured to acquire an initial video stream collected by the camera of the mobile terminal when receiving feedback that the camera permission authorization of the mobile terminal is passed;

[0038] A determination unit, configured to determine whether there is a virtual application scene corresponding to the video object in the initial video stream; if so, obtain the virtual application scene, and determine a target processing model corresponding to the virtual application scene;

[0039] The processing unit is used to pre-process the initial video stream based on the virtual application scenario to obtain a target video stream; and process the target video stream using the target processing model to obtain a target AR.

[0040] A third aspect of an embodiment of the present invention shows an electronic device, which is used to run a program, wherein the program executes the AR processing method shown in the first aspect of the embodiment of the present invention when running.

[0041] A fourth aspect of an embodiment of the present invention shows a storage medium, wherein the storage medium includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute the AR processing method shown in the first aspect of the embodiment of the present invention.

[0042] Based on the above-mentioned embodiment of the present invention, an AR processing method, device, electronic device and storage medium are provided, the method comprising: when receiving the feedback that the camera permission authorization of the mobile terminal is passed, obtaining the initial video stream collected by the camera of the mobile terminal; determining whether there is a virtual application scene corresponding to the video object in the initial video stream; if so, obtaining the virtual application scene, and determining the target processing model corresponding to the virtual application scene; pre-processing the initial video stream based on the virtual application scene to obtain the target video stream; processing the target video stream using the target processing model to obtain the target AR. In the embodiment of the present invention, the initial video stream uploaded by the user is obtained, and the virtual application scene corresponding to the video object in the initial video stream and the target processing model corresponding to the virtual application scene are determined; the present invention does not need to rely on a third-party platform, and AR processing is performed on the target video stream through the target processing model corresponding to the virtual application scene to obtain the target AR, which can reduce the time of AR processing and obtain a better AR realism effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0044] Figure 1 A schematic diagram of interaction between a mobile terminal and a server according to an embodiment of the present invention;

[0045] Figure 2 A schematic diagram of a flow chart of an AR processing method according to an embodiment of the present invention;

[0046] Figure 3 A schematic diagram of an AR processing process according to an embodiment of the present invention;

[0047] Figure 4 A schematic flow chart of another AR processing method according to an embodiment of the present invention;

[0048] Figure 5 The present invention is a schematic diagram of the structure of an AR processing device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0051] It should be noted that the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0052] In this application, the terms "comprises", "comprising" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element.

[0053] See also Figure 1 , is a schematic diagram of interaction between a mobile terminal and a server according to an embodiment of the present invention.

[0054] The mobile terminal 10 is connected to the server 20 , and there may be multiple mobile terminals 10 .

[0055] The mobile terminal 10 performs AR processing through a video application or an e-commerce platform connected to the video application, or performs AR processing on a separate AR application, and the server 20 obtains operation information of the mobile terminal 10 .

[0056] Specifically, when a user triggers AR processing based on a video application on the mobile terminal 10 or an e-commerce platform connected to the video application, the server 20 requests the camera permission of the mobile terminal. When receiving feedback that the camera permission authorization of the mobile terminal is passed, the server 20 obtains the initial video stream captured by the camera of the mobile terminal; determines whether there is a virtual application scene corresponding to the video object in the initial video stream; if so, obtains the virtual application scene and determines the target processing model corresponding to the virtual application scene; pre-processes the initial video stream based on the virtual application scene to obtain the target video stream; and processes the target video stream using the target processing model to obtain the target AR.

[0057] In an embodiment of the present invention, an initial video stream uploaded by a user is obtained, and a virtual application scene corresponding to a video object in the initial video stream and a target processing model corresponding to the virtual application scene are determined; the present invention does not require the aid of a third-party platform, and AR processing is performed on the target video stream through the target processing model corresponding to the virtual application scene to obtain a target AR, which can reduce the time of AR processing and obtain a better AR reality effect.

[0058] See also Figure 2 , is a flow chart of an AR processing method according to an embodiment of the present invention, the method comprising:

[0059] Step S201: when receiving a feedback indicating that the camera authority of the mobile terminal is authorized, obtaining an initial video captured by the camera of the mobile terminal.

[0060] Optionally, the user triggers the start of an augmented reality (AR) processing system through a mobile terminal. When the server receives the AR processing system start-up instruction, it uses the web video and voice real-time communication technology (WebReal-Time Communications, WebRTC) to access the hardware device media interface getUserMedia API to request the camera permission of the mobile terminal, so as to control the camera on the mobile terminal to start when receiving the camera permission authorization feedback confirmed by the user based on the mobile terminal.

[0061] It should be noted that the shooting time and shooting location of the initial video can be controlled by the user holding the mobile terminal.

[0062] In the specific implementation of step S201, when the camera on the mobile terminal is turned on, the initial video captured by the camera on the mobile terminal, that is, the media input stream, is obtained.

[0063] The corresponding sample code is:

[0064] navigator.mediaDevices.getUserMedia({video:true,audio:false})

[0065] .then(function(stream){

[0066] / / Bind the video stream to a <video>Element, preview

[0067] varvideo=document.querySelector('video');

[0068] video.srcObject = stream;

[0069] video.play();

[0070] })

[0071] .catch(function(err){

[0072] console.log("An error occurred:"+err);

[0073] });

[0074] Step S202: Determine whether there is a virtual application scene corresponding to the video object in the initial video stream. If so, execute step S203. If not, output a prompt message that the initial video does not conform to AR processing, and return to execute step S201.

[0075] It should be noted that the specific process of implementing step S202 includes the following steps:

[0076] Step S11: inputting the video object in the initial video stream into a pre-built AR recognition engine, and the pre-built AR recognition engine recognizes the video object and outputs a recognition result.

[0077] In step S11, the AR recognition engine is pre-built based on historical AR materials uploaded by multiple users;

[0078] It should be noted that the process of building an AR recognition engine based on historical AR materials uploaded by multiple users in advance includes:

[0079] Optionally, the server is provided with libraries including but not limited to WebRTC support library, image processing library (OpenCV) and 3D rendering library (such as Three.js or Unity3D WebGL). These libraries provide underlying support for AR recognition engine and 3D / 2D rendering engine.

[0080] Step S21: receiving historical AR materials uploaded by multiple users;

[0081] In the specific implementation of step S21, the historical AR material uploaded by the user is received through a network Web interface or an application program interface.

[0082] It should be noted that the network web interface or application program interface is able to handle file uploads, including validating file types and size limits.

[0083] Optionally, the uploaded AR materials are stored in a specified directory of the server, and a unique identifier or file name is generated for each AR file for subsequent processing and reference.

[0084] Historical AR materials are generally various types of videos played in video applications, or images virtually combined with video storage, items virtually combined in the mall, etc.

[0085] Step S22: processing each of the historical AR materials respectively to obtain processed AR materials;

[0086] In the specific implementation of step S22, for each of the historical AR materials, the historical AR materials are sequentially resized, image enhanced, denoised, and feature extracted to obtain feature data;

[0087] Optionally, the feature data is associated with corresponding historical AR materials for quick matching during real-time recognition.

[0088] It should be noted that the process of resizing the historical AR material is: scaling the image corresponding to the historical AR material to a uniform size according to a preset standard size, so as to reduce processing time and memory consumption.

[0089] The process of performing image enhancement on the historical AR material is: performing image contrast and brightness enhancement or applying filters to the resized historical AR material to enhance image features, so that key features of the image are more obvious.

[0090] The process of performing noise reduction processing on the historical AR material is: using an image noise reduction algorithm to perform noise reduction on the historical AR material after image enhancement, so as to reduce image noise and improve the robustness of the recognition algorithm.

[0091] The process of extracting features from the historical AR material is as follows: extracting key features from the historical AR material after noise reduction to obtain feature data, that is, the processed historical AR material.

[0092] Among them, the feature detection algorithm (SIFT) in the AR recognition engine can be used to extract features.

[0093] Step S23: constructing an AR recognition engine based on the processed historical AR material.

[0094] In the specific implementation of step S23, first, the feature data is serialized. Specifically, the extracted feature data needs to be serialized into a preset format so that it can be stored in a database or a file system.

[0095] The preset format is set in advance by the technician according to the actual situation. For example, JSON, XML or a specific binary format may be used, depending on the structure of the feature data and the retrieval requirements.

[0096] Next, select a storage mechanism for the serialized feature data. That is, if the system design requires efficient query and large-scale data management, you can choose to use a relational database (such as MySQL, PostgreSQL) or a NoSQL database (MongoDB) to store the serialized feature data.

[0097] The records in the database should contain the corresponding relationship between the user session identifier, the material identifier and the serialized feature data.

[0098] For smaller-scale applications or when real-time requirements are not very high, you can choose to store serialized feature data in the file system, with each material corresponding to one file.

[0099] Finally, the user session and the serialized feature data, that is, the processed historical AR material and the original historical AR material, as well as the corresponding relationship between the user sessions can be associated to build an AR recognition engine. The AR recognition engine ensures that each feature data record can be clearly associated with the corresponding user session and uploaded AR material. In the actual recognition process, the corresponding feature data can be quickly retrieved according to the current user session to achieve efficient material recognition.

[0100] It should be noted that the user session at this time refers to the data corresponding to the user's login status, uploaded AR materials and model resources, specifically user information, session identifier and resource mapping relationship.

[0101] In the process of implementing step S11, the pre-built AR recognition engine is used to sequentially resize, enhance, denoise and extract features of the video object to obtain corresponding target feature data. Then, it is determined whether the AR recognition engine itself stores feature data corresponding to the target feature data. If so, a recognition result of successful recognition is output and step S12 is executed; if not, a failure result of failed recognition is output.

[0102] Optionally, the pre-built AR recognition engine can directly calculate the similarity between the video object and the historical AR material. If any similarity is higher than a preset threshold, a recognition result of successful recognition is output; if all similarities are lower than the preset threshold, a failure result of failed recognition is output.

[0103] In the embodiment of the present invention, the AR recognition engine can improve the recognition rate of AR recognition materials, and can accurately recognize them even in poor lighting or partial occlusion, thereby improving the user experience and making the triggering of AR content more reliable and smooth.

[0104] Step S12: Determine whether there is a virtual application scene corresponding to the video object in the initial video stream.

[0105] It should be noted that the virtual application scene is composed of historical AR materials, that is, there is a correlation between the historical AR materials and the virtual application scene.

[0106] In the specific implementation of step S12, the similarity between the video object and the historical AR material is calculated, and the virtual application scene corresponding to the historical AR material with the maximum similarity is used as the virtual application scene of the video object. At this time, it is determined that the initial video stream can be AR processed.

[0107] Step S203: acquiring the virtual application scenario, and determining a target processing model corresponding to the virtual application scenario;

[0108] It should be noted that the processing model may be a two-dimensional interactive animation 2D model or a three-dimensional interactive animation 3D model, and the number of the processing models may be multiple.

[0109] Each processing model is associated with a virtual application scene constructed by an AR material.

[0110] The processing model stores a virtual application scenario and virtual objects that conform to the scenario.

[0111] It should be noted that the process of pre-building the processing model includes:

[0112] Step S31: Acquire historical virtual materials, where the historical virtual materials include a virtual application scene and virtual objects of the scene.

[0113] In the specific implementation of step S31, the server receives the virtual application scene and the virtual object of the scene uploaded by the user through the network Web interface or the application interface API.

[0114] The virtual application scene and the virtual objects of the scene may be 3D model files, such as .obj files and .fbx files, or 2D image files, such as .jpg files and .png files. The received multiple files may be checked for file size or type.

[0115] .obj and .fbx are both 3D model file formats, and .jpg and .png files are both image file formats.

[0116] Among them, the virtual application scene can generally be a scene obtained by the user through the video playback data in the video application, and the virtual object refers to the virtual application scene, that is, the characters and objects in a video, which can be used for the user's second creation, that is, the process of generating the target AR.

[0117] Optionally, the file received in step S31 is saved to a designated directory or object storage service on the server side. Each file should generate a unique identifier or be stored using the original file name for subsequent processing and reference.

[0118] Step S32: constructing corresponding processing models based on the virtual material to obtain multiple processing models.

[0119] In the process of implementing step S32, first, the virtual material is divided according to different material types. Then, for each divided virtual material, if the virtual material is a material in a 3D model file format, a 3D model is constructed; if the virtual material is a material in an image file format, a 2D model is constructed; and the processing model corresponding to each divided part is constructed in turn to obtain multiple processing models.

[0120] It should be noted that the processing model stores the virtual application scenarios and the association relationship with the virtual objects.

[0121] In the embodiment of the present invention, the model is processed and rendered to reduce rendering delay, ensuring that the AR content can be synchronized with the real world in real time, thereby providing users with a more immersive and seamless AR experience.

[0122] Optionally, it also includes: configuring corresponding model attributes for each processing model, and the model material includes model size, position, and animation.

[0123] Among them, size refers to the size of the model in the AR scene, that is, the virtual application scene; position refers to the position of the processing model relative to the recognized AR material; animation means that when the processing model contains or supports animation, the user can specify the playback mode or trigger conditions of the animation.

[0124] It should be noted that the model attributes corresponding to each processing model configuration can be pre-set by the user, and the attribute data configured by the user needs to be stored in the database and associated with the corresponding processing model, so that when the AR scene needs to render the model, the system can read these attributes and display the model correctly.

[0125] Optionally, the method also includes compressing and adjusting each processed model to reduce the model file size.

[0126] Specifically, using model compression tools or algorithms to reduce file size can speed up the download of processed models and improve loading efficiency on mobile devices. For example, for 3D models, this can be achieved by reducing the number of polygons (PolygonReduction).

[0127] Next, adjust the texture resolution. For processing models with textures, reducing the texture resolution can significantly reduce the rendering burden. At the same time, compressed texture formats can be used to further reduce file size.

[0128] In the specific implementation of step S203, the virtual application scenario is obtained, and the virtual application scenario is used to search for a plurality of pre-built processing models, and the processing model corresponding to the virtual application scenario is determined.

[0129] Specifically, a processing model storing the corresponding virtual application scenario is searched from among the multiple processing models, and is used as the target processing model.

[0130] Step S204: pre-processing the initial video stream based on the virtual application scenario to obtain a target video stream.

[0131] It should be noted that the specific process of implementing step S204 includes the following steps:

[0132] Step S41: determining corresponding scenario requirements based on the virtual application scenario;

[0133] It should be noted that the virtual application scenario pre-stores its corresponding requirements, which are set by the technicians according to the actual situation.

[0134] Step S42: adjusting the video objects in the initial video stream according to the scene requirements to obtain a target video stream.

[0135] In the process of implementing step S41 and step S42, the requirements of the virtual application scene are determined, including adjusting the video resolution and AR effect parameters, etc. The initial video stream is adjusted according to the requirements of the virtual application scene such as adjusting the video resolution and AR effect parameters, that is, preprocessing is performed to obtain the target video stream.

[0136] Optionally, in addition to the above-mentioned preprocessing method, the resolution of the initial video stream may be dynamically adjusted according to the network bandwidth and device performance.

[0137] Specifically, the current network conditions and device processing capabilities are detected, and the video resolution requested by getUserMediaAPI is adjusted in real time to achieve this.

[0138] The code for dynamically adjusting the resolution according to network conditions is as follows:

[0139] function adjustResolution(networkQuality){

[0140] var constraints = {video:{width:640,height:360},audio:false}; / / Default resolution

[0141] if(networkQuality===='high'){

[0142] constraints.video.width = 1280; / / Increase resolution

[0143] constraints.video.height=720;

[0144] }else if(networkQuality===='low'){

[0145] constraints.video.width = 320; / / reduce resolution

[0146] constraints.video.height=240;

[0147] }

[0148] navigator.mediaDevices.getUserMedia(constraints)

[0149] .then(function(stream){

[0150] / / Update the video stream

[0151] })

[0152] .catch(function(err){

[0153] console.log("An error occurred:"+err);

[0154] });

[0155] }

[0156] Optionally, the preprocessing method also includes frame rate control, that is, by lowering the frame rate of the video stream, the burden of encoding and decoding can be reduced, which is suitable for AR scenarios that do not require high frame rate capture.

[0157] The code for requesting a low frame rate video stream is:

[0158] navigator.mediaDevices.getUserMedia(video:{frameRate:{max:15}},audio:false})

[0159] .then(function(stream){

[0160] / / Use low frame rate video stream

[0161] });

[0162] Optionally, the preprocessing method also includes video compression. WebRTC is configured to use the highly compressed digital video format H.264 / SV. When establishing a WebRTC connection, it is necessary to specify the use of H.264 / SVC as the video codec in the Session Description Protocol (SDP) and configure the corresponding layered coding parameters. The code is as follows:

[0163] const peerConnection=new RTCPeerConnection();

[0164] / / Get the video stream

[0165] navigator.mediaDevices.getUserMedia({video:true})

[0166] .then(stream=>{

[0167] peerConnection.addStream(stream);

[0168] });

[0169] / / Specify H.264 / SVC encoding when creating an offer

[0170] peerConnection.createOffer({

[0171] offerToReceiveVideo:true,

[0172] offerToReceiveAudio:true

[0173] }).then(offer=>{

[0174] / / Modify SDP to specify the use of H.264 / SVC

[0175] offer.sdp=offer.sdp.replace('m=video 9UDP / TLS / RTP / SAVPF96','m=video 9UDP / TLS / RTP / SAVPF 9697');

[0176] offer.sdp+='a=rtpmap:97H264-SVC / 90000\n';

[0177] returnpeerConnection.setLocalDescription(offer);

[0178] });

[0179] In the embodiment of the present invention, the layered coding parameters of H.264 / SVC, such as resolution, frame rate and quality layer, are dynamically adjusted according to the network status and device performance to pre-process the initial video stream.

[0180] It involves real-time monitoring of network bandwidth and device performance indicators, and then adjusting relevant parameters in SDP or implementing it through other control mechanisms.

[0181] Optionally, it also includes: using WebRTC's bandwidth estimation mechanism to monitor the current network status and adjust the video quality according to the estimated bandwidth to ensure smooth video transmission and reduce freezes and delays. This process can be assisted by monitoring the signaling and video call onicecandidate events of the local and remote peer RTCPeerConnection and analyzing ICE candidates.

[0182] Step S205: Process the target video stream using the target processing model to obtain a target AR.

[0183] It should be noted that the specific process of implementing step S205 includes the following steps:

[0184] Step S51: extracting video frames from the target video stream to obtain multiple frames of images;

[0185] In the specific implementation of step S51, single-frame image data is extracted from the captured target video stream to obtain multiple-frame images.

[0186] Specifically, the target video stream is drawn onto a hidden Canvas element, and then the image data of the current frame is obtained from the Canvas. The implementation code is as follows:

[0187] function captureFrame(videoElement,canvasElement){

[0188] canvasElement.getContext('2d').drawImage(videoElement,0,0,canvasElement.width,canvasElement.height);

[0189] returncanvasElement.getContext('2d').getImageData(0,0,canvasElement.width,canvasElement.height);

[0190] }

[0191] Step S52: Process each frame of the image, determine a target frame related to the virtual application scene, and use the target frame as a background layer.

[0192] In the process of implementing step S52, a preset image recognition algorithm is used to process each extracted frame image to identify whether it contains corresponding target feature data, that is, features related to the virtual application scene, and the frame image containing the corresponding target feature data is used as the target frame. If the number of target frames is one, the target frame is used as the background layer; if the number of target frames is multiple, they are continuously combined and the combined image is used as the background layer.

[0193] It should be noted that the target feature data refers to the data obtained through processing in step S11.

[0194] The background layer can be an image or a multi-frame image, that is, a video stream constructed by continuous frames.

[0195] The preset image recognition algorithm may be a feature matching algorithm SIFT, which may pre-calculate and store relevant feature data when previously uploading materials, so as to facilitate fast matching.

[0196] Step S53: determining a virtual object corresponding to the virtual application scene based on the target processing model, and displaying the virtual object and the background layer to the user;

[0197] In the specific implementation of step S53, the target processing model is searched using the virtual application scene to determine the virtual object corresponding to the virtual application scene from the target processing model, and the virtual object is displayed to the user together with the background layer.

[0198] Among them, the local end and remote peer application interface RTCPeerConnectionAPI of WebRTC are used to display the background layer and virtual objects to the user so that the user can operate based on the virtual objects and background layer.

[0199] Step S54: receiving a first movement operation for the virtual object;

[0200] Step S55: determining the superimposed position of the virtual object on the background layer in response to the first moving operation;

[0201] In the process of implementing step S54 and step S55, first, the virtual object may be an icon of the background layer, and the first movement operation on the virtual object is: an input operation performed by the user on the area where the background layer is located. For example, the first movement operation may include any one or more actions such as dragging or sliding a virtual object to place the virtual object on the background layer.

[0202] Next, the superimposed position of the virtual object on the background layer is matched based on an image recognition algorithm such as scale-invariant feature transform (SIFT) to determine the exact position of the virtual object in the current video frame, i.e., the background layer; that is, the matching result returned by the image recognition algorithm is parsed to obtain a transformation matrix or other forms of position data to ensure that the AR effect can be accurately aligned with objects in the real world.

[0203] Step S56: Render the virtual object to the corresponding superimposed position to obtain the target AR.

[0204] In the process of implementing step S56, after determining the overlay position, the next step is to render the AR content, that is, the virtual object, at this position, so that the visual effect of the virtual object and the background layer is a smooth image. By using web technologies such as the 3D drawing protocol WebGL and the three-dimensional engine Three.js, these contents can be dynamically rendered on the video stream, that is, the virtual object can be dynamically rendered on the background layer to obtain the target AR.

[0205] Optionally, the method further includes pre-rendering a 3D / 2D model. First, a target processing model is loaded, and a corresponding virtual object is rendered.

[0206] Specifically, first, download the model file from the server or retrieve the virtual object in the target processing model from the cache. The implementation code is as follows:

[0207] function loadModel(modelConfig){

[0208] / / Load the model according to modelConfig (including the URL and type of the model)

[0209] / / For 3D models, you may use libraries such as Three.js to load

[0210] / / For 2D images, you may use Label or Canvas drawing

[0211] }

[0212] Next, the virtual objects in the processing model are rendered to the overlay positions.

[0213] The overlay position refers to the specific position, rotation, and scaling parameters of the virtual object in the current video frame, i.e., the background layer, to ensure that the model is correctly aligned with the actual environment.

[0214] The specific implementation code is:

[0215] function renderModelAtPosition(model,position,rotation,scale){

[0216] / / According to the position, rotation and scale parameters

[0217] / / Render the model to the corresponding position of the video stream

[0218] }

[0219] Optionally, to provide an interactive AR experience, the server can respond to user interaction events, such as clicking or touching virtual objects in the processing model.

[0220] While rendering, the server sets up event listeners to capture and process user interactions. The specific implementation code is as follows:

[0221] function setupInteractionListeners(model){

[0222] / / Set interaction listeners for the model, such as click or touch events

[0223] / / When the user interacts with the model, execute the corresponding logic

[0224] }

[0225] Optionally, also include:

[0226] The server receives the user's operation to change the model and executes the predefined interaction logic, such as changing the state of the model, triggering animation, displaying related information or links, etc.

[0227] The specific implementation code is:

[0228] function handleInteraction(model,interactionType){

[0229] / / Process the interaction logic according to the interaction type (interactionType), such as click or touch

[0230] / / May include changing model properties, playing animations, displaying additional information, etc.

[0231] }

[0232] Optionally, maintain good performance and smoothness when rendering 3D / 2D models and handling interactive events. Ensure that all 3D models and 2D images are optimized to reduce rendering burden. This includes using low-polygon models, compressed textures, etc. Dynamically load and unload resources as needed to avoid unnecessary memory usage. Use caching strategies to reduce the overhead of repeated loading.

[0233] Optionally, in addition to the above-mentioned processes of step S53 and step S54, there are other ways to determine the superimposed position.

[0234] First, the position and posture changes of the virtual object are estimated by comparing the changes in feature points between multiple consecutive frames of the background layer.

[0235] Specifically, a pre-built position prediction model may be used for prediction, and the prediction model may be trained on the placement position of a virtual object in a virtual application scenario by using an optical flow method, a feature-based matching algorithm, or the like.

[0236] Next, the background layer is converted into a 3D map consisting of coordinates.

[0237] Finally, based on the estimated position and posture of the virtual object, the virtual object is superimposed on the 3D map to obtain the target AR, such as determining the position of furniture relative to the corner of the room or specific furniture.

[0238] Optionally, based on the precise position and posture of the device and a 3D map of the environment, the precise position and orientation of the virtual content in the real world can be calculated. The virtual object can then be superimposed on the background layer to achieve an AR effect.

[0239] The specific implementation process based on the above steps S201 to S205 can also be achieved by Figure 3 Provide explanation.

[0240] In the embodiment of the present invention, the initial video stream uploaded by the user is obtained, and the virtual application scene corresponding to the video object in the initial video stream and the target processing model corresponding to the virtual application scene are determined; the present invention does not need to rely on a third-party platform, and AR processing is performed on the target video stream through the target processing model corresponding to the virtual application scene to obtain the target AR, which can reduce the AR processing time and obtain a better AR realism effect. Therefore, a more immersive and seamless AR experience can be provided.

[0241] Based on the above embodiments of the present invention, an AR processing method is shown. Figure 4 As shown, the present invention is a flowchart corresponding to another AR processing method.

[0242] Step S401: receiving a virtual application scene selected on a mobile terminal;

[0243] Step S402: In response to the virtual application scene, determining a virtual object corresponding to the virtual application scene;

[0244] In the specific implementation of step S401 and step S402, the server receives the user can directly select the corresponding virtual application scene on the mobile terminal; responds to the virtual application scene, and selects the virtual object corresponding to the virtual application scene from the multiple processing models constructed by step S31 and step S33;

[0245] Step S403: when receiving the feedback that the camera permission authorization of the mobile terminal is passed, obtaining the initial video stream collected by the camera of the mobile terminal;

[0246] It should be noted that the specific implementation process of step S403 is the same as the specific implementation process of the above-mentioned specific implementation step S201, and they can refer to each other.

[0247] Step S404: Determine whether the initial video stream matches the virtual application scene. If so, execute step S405; if not, output a request for re-capturing the camera.

[0248] In the process of specifically implementing step S404, the pre-built AR recognition engine is used to determine the target feature data corresponding to the video object, and then, it is determined whether the similarity between the feature data corresponding to the virtual application scene stored in the AR recognition engine itself and the target feature data is higher than a preset threshold. If so, it is determined that the initial video stream matches the virtual application scene; if not, it is determined that the initial video stream does not match the virtual application scene, and a request for re-capturing the camera is output.

[0249] Step S405: pre-processing the initial video stream based on the virtual application scene to obtain a target video stream;

[0250] It should be noted that the specific implementation process of step S405 is the same as the specific implementation process of the above-mentioned specific implementation step S204, and they can refer to each other.

[0251] Step S406: Render the virtual object and the target video stream to obtain a target AR.

[0252] It should be noted that the specific process of implementing step S406 includes the following steps:

[0253] Step S61: extracting video frames from the target video stream to obtain multiple frames of images;

[0254] Step S62: Process each frame of the image, determine a target frame related to the virtual application scene, and use the target frame as a background layer.

[0255] It should be noted that the specific implementation process of step S61 and step S62 is the same as the implementation process of step S51 and step S52 and can refer to each other.

[0256] Step S63: displaying the virtual object and the background layer to the user;

[0257] Step S64: receiving a first movement operation for the virtual object;

[0258] Step S65: determining the superimposed position of the virtual object on the background layer in response to the first movement operation;

[0259] Step S66: Render the virtual object to the corresponding superimposed position to obtain the target AR.

[0260] It should be noted that the specific implementation process of step S64 to step S66 is the same as the specific implementation process of the above-mentioned step S54 to step S56, and they can refer to each other.

[0261] In an embodiment of the present invention, by responding to the virtual application scene, a virtual object corresponding to the virtual application scene is determined; after determining that the initial video stream matches the virtual application scene, it is determined that the initial video stream can be processed without the need for a third-party platform, and AR processing is performed on the target video stream using the virtual object to obtain the target AR, which can reduce the time for AR processing and achieve a better AR reality effect.

[0262] Based on the AR processing method shown in the above embodiment of the present invention, the embodiment of the present invention correspondingly discloses a structural schematic diagram of another AR processing device, such as Figure 5 As shown, the device comprises:

[0263] The acquisition unit 501 is used to acquire an initial video stream collected by the camera of the mobile terminal when receiving feedback that the camera permission authorization of the mobile terminal is passed;

[0264] The determining unit 502 is used to determine whether there is a virtual application scene corresponding to the video object in the initial video stream; if so, obtain the virtual application scene and determine the target processing model corresponding to the virtual application scene;

[0265] The processing unit 503 is used to pre-process the initial video stream based on the virtual application scenario to obtain a target video stream; and process the target video stream using the target processing model to obtain a target AR.

[0266] The specific principles and execution processes of each unit in the AR processing device disclosed in the above embodiment of the present invention are the same as the corresponding contents in the AR processing method provided in the above embodiment of the present invention. Please refer to the corresponding parts of the AR processing method disclosed in the above embodiment of the present invention, and will not be repeated here.

[0267] In an embodiment of the present invention, an initial video stream uploaded by a user is obtained, and a virtual application scene corresponding to a video object in the initial video stream and a target processing model corresponding to the virtual application scene are determined; the present invention does not require the aid of a third-party platform, and AR processing is performed on the target video stream through the target processing model corresponding to the virtual application scene to obtain a target AR, which can reduce the time of AR processing and obtain a better AR reality effect.

[0268] Optionally, the determining unit for determining whether there is a virtual application scene corresponding to the video object in the initial video stream is specifically configured to:

[0269] Inputting the video object in the initial video stream into a pre-built AR recognition engine, the pre-built AR recognition engine recognizes the video object and outputs a recognition result, wherein the AR recognition engine is pre-built based on historical AR materials uploaded by multiple users;

[0270] If the recognition result shows that the recognition is successful, it is determined that there is a virtual application scene corresponding to the video object in the initial video stream.

[0271] Optionally, determining a confirmation unit for a processing model corresponding to the virtual application scenario includes:

[0272] The virtual application scenario is used to search for a plurality of pre-constructed processing models, and a processing model corresponding to the virtual application scenario is determined, wherein the processing model is pre-constructed.

[0273] Optionally, the processing unit pre-processes the initial video stream based on the virtual application scene to obtain a target video stream, including:

[0274] Determining corresponding scenario requirements based on the virtual application scenario;

[0275] The video objects in the initial video stream are adjusted according to the scene requirements to obtain a target video stream.

[0276] Optionally, the target video stream is processed by using the target processing model to obtain a processing unit of the target AR, including:

[0277] Extracting video frames from the target video stream to obtain multiple frames of images;

[0278] Process each frame of the image, determine the target frame related to the virtual application scene, and use the target frame as the background layer;

[0279] Determine a virtual object corresponding to the virtual application scene based on the processing model, and display the virtual object and the background layer to the user;

[0280] receiving a first movement operation for a virtual object;

[0281] Determining a superimposed position of the virtual object on the background layer in response to the first movement operation;

[0282] The virtual object is rendered to a corresponding superimposed position to obtain a target AR.

[0283] Optionally, processing each frame of the image to determine a target frame related to the virtual application scene includes:

[0284] Identify each frame of the image to determine whether it contains features related to the virtual application scene;

[0285] If included, the frame image is used as the target frame.

[0286] Optionally, the processing unit is further configured to:

[0287] Receiving a virtual application scene selected on a mobile terminal;

[0288] In response to the virtual application scene, determining a virtual object corresponding to the virtual application scene;

[0289] When receiving feedback that the camera permission of the mobile terminal is authorized, obtaining an initial video stream collected by the camera of the mobile terminal;

[0290] If it is determined that the initial video stream matches the virtual application scene, preprocessing the initial video stream based on the virtual application scene to obtain a target video stream;

[0291] The virtual object and the target video stream are rendered to obtain a target AR.

[0292] An embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory is used to store program code and data for AR processing, and the processor is used to call the program instructions in the memory to execute the steps shown in the AR processing method in the above embodiment.

[0293] An embodiment of the present application provides a storage medium, which includes a stored program, wherein when the program is running, a device where the storage medium is located is controlled to execute the AR processing method shown in the above embodiment.

[0294] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0295] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0296] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.< / video>

Claims

1. An AR processing method, characterized in that: The method comprises: When receiving a feedback that the camera permission of the mobile terminal is authorized, obtaining an initial video stream collected by the camera of the mobile terminal; Determining whether there is a virtual application scene corresponding to the video object in the initial video stream; If so, obtaining the virtual application scenario and determining a target processing model corresponding to the virtual application scenario; Preprocessing the initial video stream based on the virtual application scenario to obtain a target video stream; The target video stream is processed using the target processing model to obtain a target AR.

2. The method according to claim 1, characterized in that Determining whether there is a virtual application scene corresponding to the video object in the initial video stream includes: Inputting the video object in the initial video stream into a pre-built AR recognition engine, the pre-built AR recognition engine recognizes the video object and outputs a recognition result, wherein the AR recognition engine is pre-built based on historical AR materials uploaded by multiple users; If the recognition result shows that the recognition is successful, it is determined that there is a virtual application scene corresponding to the video object in the initial video stream.

3. The method according to claim 1, characterized in that Determining a target processing model corresponding to the virtual application scenario includes: The virtual application scenario is used to search for a plurality of pre-constructed processing models, and a target processing model corresponding to the virtual application scenario is determined, wherein the processing model is pre-constructed.

4. The method according to claim 1, characterized in that: Preprocessing the initial video stream based on the virtual application scenario to obtain a target video stream includes: Determining corresponding scenario requirements based on the virtual application scenario; The video objects in the initial video stream are adjusted according to the scene requirements to obtain a target video stream.

5. The method according to claim 1, characterized in that: The target video stream is processed by using the target processing model to obtain a target AR, including: Extracting video frames from the target video stream to obtain multiple frames of images; Process each frame of the image, determine the target frame related to the virtual application scene, and use the target frame as the background layer; Determine a virtual object corresponding to the virtual application scene based on the processing model, and display the virtual object and the background layer to the user; receiving a first movement operation for a virtual object; Determining a superimposed position of the virtual object on the background layer in response to the first movement operation; The virtual object is rendered to a corresponding superimposed position to obtain a target AR.

6. The method according to claim 5, characterized in that Each frame of the image is processed to determine the target frame related to the virtual application scene, including: Identify each frame of the image to determine whether it contains features related to the virtual application scene; If included, the frame image is used as the target frame.

7. The method according to claim 1, characterized in that Also includes: Receiving a virtual application scene selected on a mobile terminal; In response to the virtual application scene, determining a virtual object corresponding to the virtual application scene; When receiving feedback that the camera permission of the mobile terminal is authorized, obtaining an initial video stream collected by the camera of the mobile terminal; If it is determined that the initial video stream matches the virtual application scene, preprocessing the initial video stream based on the virtual application scene to obtain a target video stream; The virtual object and the target video stream are rendered to obtain a target AR.

8. An AR processing device, characterized in that: The device comprises: An acquisition unit, configured to acquire an initial video stream collected by the camera of the mobile terminal when receiving feedback that the camera permission authorization of the mobile terminal is passed; A determination unit, configured to determine whether there is a virtual application scene corresponding to the video object in the initial video stream; if so, obtain the virtual application scene, and determine a target processing model corresponding to the virtual application scene; The processing unit is used to pre-process the initial video stream based on the virtual application scenario to obtain a target video stream; and process the target video stream using the target processing model to obtain a target AR.

9. An electronic device, characterized in that: The electronic device is used to run a program, wherein the program executes the AR processing method according to any one of claims 1 to 7 when running.

10. A storage medium, characterized in that: The storage medium includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute the AR processing method according to any one of claims 1 to 7.