WO2022241701A1 - 一种图像处理方法及装置 - Google Patents

一种图像处理方法及装置 Download PDF

Info

Publication number
WO2022241701A1
WO2022241701A1 PCT/CN2021/094744 CN2021094744W WO2022241701A1 WO 2022241701 A1 WO2022241701 A1 WO 2022241701A1 CN 2021094744 W CN2021094744 W CN 2021094744W WO 2022241701 A1 WO2022241701 A1 WO 2022241701A1
Authority
WO
WIPO (PCT)
Prior art keywords
moment
pose
sub
image
acquisition device
Prior art date
Application number
PCT/CN2021/094744
Other languages
English (en)
French (fr)
Inventor
陆枭
姚亚群
黄荣锋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN202180098163.6A priority Critical patent/CN117296082A/zh
Priority to PCT/CN2021/094744 priority patent/WO2022241701A1/zh
Publication of WO2022241701A1 publication Critical patent/WO2022241701A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating 3D models or images for computer graphics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating 3D models or images for computer graphics
    • G06T19/20Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts

Definitions

  • the present application relates to the technical field of virtual reality, and in particular to an image processing method and device.
  • VR virtual reality
  • AR augmented reality
  • MR mixed reality
  • VR virtual reality
  • technologies such as VR are often combined with video see through technology (video see through, VST) or perspective technology (pass through, PT).
  • video see through technology video see through, VST
  • PT perspective technology
  • the captured image frame corresponds to the image to be displayed.
  • a series of processing is required from the captured image frame to the image to be displayed, and there is a long processing delay. This is a burning problem.
  • the present application provides an image processing method and device for reducing the processing time delay of the image to be displayed.
  • the second image frame is an image frame collected by the image acquisition device at the second moment;
  • the first moment is before the second moment, and the first moment is the moment when the image acquisition device captures the first image frame, and the first image frame and the second image frame are two phases captured by the image acquisition device adjacent image frame; generating the second virtual object according to the second pose; acquiring the second image frame; superimposing the second virtual object and the second image frame to obtain the image to be displayed corresponding to the second moment.
  • the first pose may be determined in the following manner:
  • determining the first pose according to the first image frame and the motion state at the first moment includes:
  • the above method is applied to the following physical equipment: the physical equipment is composed of the image acquisition device, the head-mounted device, the sensor, the display and other devices, the image acquisition device is set
  • the device is also provided with a sensor and a display.
  • the above-mentioned image processing method is realized through the combination of the image acquisition device, the head-mounted device, the sensor, and the display, thereby providing an application scenario of the method, so that each part has its own independent division of labor, without causing the image acquisition device, etc. Partially overburdened, the image processing method described above can be performed more efficiently.
  • predicting the second pose of the second virtual object corresponding to the second image frame according to the first pose of the image acquisition device at the first moment includes:
  • the at least two moments include: the first moment, the first moment From thereafter to at least one moment before the second moment; predicting the second pose according to the pose of the image acquisition device at the second moment.
  • the motion state at least one moment in the middle after the first moment and before the second moment is also considered, so as to capture in time Changes in motion state after the first moment more accurately predict this second pose.
  • the time period between the first moment and the second moment is divided into at least two sub-periods, the at least two sub-periods include adjacent first sub-periods and second sub-periods, the first sub-period The period is located before the second sub-period, the end time of the first sub-period is the first sub-moment, and the end time of the second sub-period is the second sub-moment; according to the first pose and the image acquisition device at least The motion state at two moments, predicting the pose of the image acquisition device at the second moment, including:
  • the first cumulative pose predicting the pose of the image acquisition device at the second sub-moment according to the predicted pose at the first sub-moment and the first cumulative pose.
  • any two adjacent first sub-periods and second sub-periods based on the predicted pose at the first sub-moment and the motion state at the first sub-moment, it is predicted that the image acquisition device will The pose of the second sub-time, so that each iteration refers to the latest motion state at the end of the first sub-period, until the pose of the image acquisition device at the second moment is predicted, so through multiple sub-periods Multiple segment predictions can more accurately predict the pose of the image acquisition device at the second moment.
  • w 0 and w 0 represent weighting coefficients
  • t 0 represents the first sub-moment
  • t 1 represents the second sub-moment
  • the first sub-pose is obtained according to the pose at the initial moment of the first sub-period and the motion state at the initial moment of the first sub-period of
  • the second sub-pose is obtained according to the motion state at the initial moment of the first sub-period
  • the first sub-cumulative pose is obtained according to the pose at the first sub-moment and the motion state at the first sub-moment, is the second sub-cumulative pose of the first cumulative pose
  • the second sub-cumulative pose of the first cumulative pose is the second sub-cumulative pose of the first cumulative pose
  • the at least two sub-periods include a third sub-period, the third sub-period is adjacent to the second sub-period, the third sub-period is the last sub-period in the time period, and the third sub-period
  • the cut-off time of is the third sub-moment; the method also includes:
  • the pose at the second sub-moment and the motion state at the second sub-moment determine the second cumulative pose of the image acquisition device from the second sub-moment to the third sub-moment and the position of the second sub-moment Algorithm correction result of pose; according to the algorithm correction result of the second cumulative pose, the pose of the second sub-moment and the pose of the second sub-moment, predict the position of the image acquisition device at the third sub-moment posture.
  • the motion state of the image acquisition device since the motion state of the image acquisition device will not be acquired after the second sub-moment and before the third sub-moment, it can first be based on the pose of the second sub-moment, the second sub-moment Correct the pose of the second sub-moment, and further predict the pose of the image acquisition device at the third sub-moment, so that the pose of the third sub-moment can be corrected to obtain a more accurate The pose of the third sub-moment of .
  • the pose at the second sub-moment it is predicted that the image acquisition device will be at the third sub-moment
  • the pose satisfies the following formula:
  • t 1 represents the second sub-moment
  • t 2 represents the third sub-moment
  • the result of the algorithm correction accumulated from the second sub-moment to the third sub-moment is obtained, and then the result of the algorithm correction and Weighting the pose at the second sub-moment that has not been corrected by the algorithm can more accurately predict the pose at the third sub-moment, so that the pose at the second moment can be predicted more accurately.
  • generating a second virtual object according to the second pose includes:
  • generating a second virtual object according to the second pose includes:
  • the image processing method can be executed in the following multi-threaded manner:
  • Obtaining the image to be displayed corresponding to the second moment is executed through the main thread; predicting the second pose of the second virtual object corresponding to the second image frame is executed through the first slave thread.
  • the pose prediction will be performed in the time period between every two adjacent image frames, and the second pose at the second moment will be predicted through the first pose at the first moment, and according to the image acquisition device At the pose at the second moment, predict the third pose of the third virtual object corresponding to the third image frame, so as to sequentially predict the virtual object corresponding to the next image frame according to the pose of the image acquisition device corresponding to the previous image frame pose, and one slave thread corresponds to one image frame, so that the execution of the slave threads corresponding to each image frame does not interfere with each other, even if a slave thread executes an error, it will not affect the prediction of other slave threads on the pose.
  • distortion correction is performed on the first image frame, a distortion-corrected single-channel image is extracted, and the distortion-corrected single-channel image is down-sampled to obtain a first preprocessed image.
  • the main thread directly outputs the first preprocessing image, so that the first preprocessing image not only retains the key features in the first image frame, but also effectively reduces the amount of data, and directly uses the first preprocessing image to participate Operation, thus not only maintaining the calculation accuracy, but also significantly reducing the calculation amount of the first slave thread.
  • the image processing method also includes:
  • the first slave thread transmits the predicted second pose to the main thread.
  • the first slave thread directly uses the second pose as the input of the main thread, or it can be transmitted in the following ways:
  • the prediction module is used to predict the second pose of the second virtual object corresponding to the second image frame according to the first pose of the image acquisition device at the first moment; the second image frame is the image acquisition device at the second moment The image frame collected; the first moment is located before the second moment, and the first moment is the moment when the image acquisition device collects the first image frame, and the first image frame and the second image frame are the image acquisition device Two adjacent image frames collected;
  • the prediction module is further used for:
  • the prediction module is specifically used for:
  • the image acquisition device is set on a head-mounted device, and the head-mounted device is also provided with a sensor and a display;
  • the prediction module is specifically used to: acquire the motion state collected by the sensor at the first moment;
  • the motion state collected by the sensor at the first moment is used as the motion state of the image acquisition device at the first moment;
  • the processing module is also used for: displaying the image to be displayed on the display.
  • the prediction module is specifically used for:
  • the at least two moments include: the first moment, the first moment From thereafter to at least one moment before the second moment; predicting the second pose according to the pose of the image acquisition device at the second moment.
  • the time period between the first moment and the second moment is divided into at least two sub-periods, the at least two sub-periods include adjacent first sub-periods and second sub-periods, the first sub-period The period is located before the second sub-period, the cut-off time of the first sub-period is the first sub-time, and the cut-off time of the second sub-period is the second sub-time;
  • the prediction module is specifically used for:
  • the first cumulative pose predicting the pose of the image acquisition device at the second sub-moment according to the predicted pose at the first sub-moment and the first cumulative pose.
  • predicting the pose of the image acquisition device at the second sub-moment according to the pose at the first sub-moment and the first cumulative pose may specifically satisfy the following formula:
  • w 0 and w 0 represent weighting coefficients
  • t 0 represents the first sub-moment
  • t 1 represents the second sub-moment
  • the first sub-pose is obtained according to the pose at the initial moment of the first sub-period and the motion state at the initial moment of the first sub-period of
  • the second sub-pose is obtained according to the motion state at the initial moment of the first sub-period
  • the first sub-cumulative pose is obtained according to the pose at the first sub-moment and the motion state at the first sub-moment, is the second sub-cumulative pose of the first cumulative pose
  • the second sub-cumulative pose of the first cumulative pose is the second sub-cumulative pose of the first cumulative pose
  • the at least two sub-periods include a third sub-period, the third sub-period is adjacent to the second sub-period, the third sub-period is the last sub-period in the time period, and the third sub-period
  • the cut-off moment of the period is the third sub-moment; the prediction module is also used for:
  • t 1 represents the second sub-moment
  • t 2 represents the third sub-moment
  • processing module is specifically used for:
  • the second virtual object is generated according to the first image frame and the second pose.
  • the second virtual object is generated according to the second pose and the preset virtual space model.
  • obtaining the image to be displayed corresponding to the second moment is executed through the main thread; predicting the second pose of the second virtual object corresponding to the second image frame is executed through the first slave thread; the processing module also Used for:
  • the second slave thread By executing the second slave thread, predict the third pose of the third virtual object corresponding to the third image frame according to the pose of the image acquisition device at the second moment, and the third image frame is the image acquisition device at the second moment.
  • Image frames collected at three moments; the second moment is located before the third moment, and the second image frame and the third image frame are two adjacent image frames collected by the image acquisition device; wherein, the first slave thread Execute in parallel with the second slave thread.
  • processing module is also used for:
  • distortion correction is performed on the first image frame, a distortion-corrected single-channel image is extracted, and the distortion-corrected single-channel image is down-sampled to obtain a first preprocessed image.
  • processing module is also used for:
  • processing module is also used for:
  • the second virtual object is stored in the shared cache; a mutex is set for the second virtual object in the shared cache; the mutex is used to prohibit the main thread from reading the second virtual object; when the second virtual object is the earliest pose in the shared cache, release the mutex set for the second virtual object in the shared cache; use the main thread to read from the shared cache the second virtual object.
  • another image processing device which includes: one or more processors and a transmission interface; wherein, the one or more processors are configured to call computer instructions stored in a memory, so that the device The method according to any one of the first aspect above is carried out.
  • an electronic device in a fourth aspect, includes: one or more processors; one or more memories; wherein, the one or more memories store one or more computer instructions, and when the one or more When a computer instruction is executed by the one or more processors, the electronic device is made to perform the method according to any one of the first aspect above.
  • a computer program product includes computer instructions, and when the computer instructions are executed on a computer or a processor, the computer or the processor executes any one of the above-mentioned first aspects. method.
  • FIG. 2 is a schematic structural diagram of a physical device to which an image processing method provided in an embodiment of the present application is applicable;
  • FIG. 4 is a time schematic diagram of adjacent sub-periods in an image processing method provided in an embodiment of the present application.
  • FIG. 5 is a time schematic diagram of the third sub-period in an image processing method provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an image processing device provided by an embodiment of the present application.
  • references to "one embodiment” or “some embodiments” or the like in this specification means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application.
  • appearances of the phrases “in one embodiment,” “in some embodiments,” “in other embodiments,” “in other embodiments,” etc. in various places in this specification are not necessarily All refer to the same embodiment, but mean “one or more but not all embodiments” unless specifically stated otherwise.
  • the terms “including”, “comprising”, “having” and variations thereof mean “including but not limited to”, unless specifically stated otherwise.
  • multiple in the embodiments of the present application refers to two or more than two. In view of this, “multiple” can also be understood as “at least two” in the embodiments of the present application. "At least one” can be understood as One or more, such as being understood as one, two or more. For example, including at least one means including one, two or more, and does not limit which several are included. For example, including A, At least one of B and C, then included may be A, B, C, A and B, A and C, B and C, or A and B and C. At least one of A, B or C, may be interpreted A, B, C, A and B, A and C, B and C, or A and B and C.
  • ordinal numerals such as “first” and “second” mentioned in the embodiments of the present application are used to distinguish multiple objects, and are not used to limit the order, timing, priority, or importance of multiple objects.
  • Virtual reality virtual reality
  • VR virtual reality
  • AR augmented reality
  • MR mixed reality
  • VST video see through
  • PT perspective technology
  • VST or PT can obtain image frames from real-world scenes, and superimpose virtual objects on the image frames. displayed in front of the human eye.
  • a series of processing is required from collecting image frames to displaying images, and there is a long processing time delay.
  • FIG. 1 an embodiment of the present application provides an image processing method.
  • the second image frame is an image frame collected by the image acquisition device at a second moment; the first moment is located before the second moment, and the first moment is a first image collected by the image acquisition device At the time of each frame, the first image frame and the second image frame are two adjacent image frames collected by the image acquisition device.
  • Step 102 Generate the second virtual object according to the second pose.
  • Step 103 Acquire the second image frame.
  • Step 104 Superimposing the second virtual object and the second image frame to obtain an image to be displayed corresponding to the second moment.
  • the first image frame and the second image frame are two adjacent image frames collected by the image acquisition device.
  • the first moment and the second image frame The duration between the two moments is determined according to the frame rate of the image acquisition device. For example, if the frame rate of the image acquisition device is 20Hz, then the duration between the first moment and the second moment is 50ms.
  • the second virtual object corresponding to the second image frame when the second virtual object corresponding to the second image frame is calculated, there may be a The situation of the image frame (such as the fourth image frame) after the second image frame is obtained, so that the second virtual object corresponding to the second image frame is superimposed on the image frame after the second image frame, resulting in the virtual object in the image to be displayed does not match the image frame, the fourth image frame is the second image frame after the second image frame; and under the method described in steps 101 to 104, the second image frame can be directly obtained when the second image frame is collected.
  • the matched second virtual object, so that the image to be displayed can display the image collected in real time.
  • the first pose can be obtained in the following manner:
  • a first pose is determined.
  • the specific determination method may be based on a preset pose algorithm, and the preset pose algorithm may be a simultaneous localization and mapping (SLAM) algorithm.
  • SLAM simultaneous localization and mapping
  • the first image frame can be directly used as the input of the preset pose algorithm, or the first image frame can be preprocessed, and the preprocessed image can be used as the preset pose algorithm input of.
  • the first pose can also be obtained in the following manner:
  • a first pose is calculated according to the motion state of the image acquisition device at the first moment.
  • the preset pose algorithm can also be used, and the motion state at the first moment can be directly used as the input of the preset pose algorithm, or the motion state at the first moment can be preprocessed, and the preprocessed The final image is used as the input of the preset pose algorithm.
  • the first pose can also be determined according to the following steps (hereinafter referred to as the step of comprehensively determining the first pose):
  • the first weighted pose can be determined according to the first preset pose algorithm according to the first image frame; and the second weighted pose can be determined according to the second preset pose algorithm according to the motion state at the first moment. Two weighted poses; performing a weighted average according to the first weighted pose and the second weighted pose to determine the first pose.
  • the position information in the first pose is determined according to the motion state at the first moment, and the position information in the first pose is determined according to the first image frame.
  • Pose information in a pose is also possible to use only one preset pose algorithm. For example, the position information in the first pose is determined according to the motion state at the first moment, and the position information in the first pose is determined according to the first image frame. Pose information in a pose.
  • the local pose calculation factors may be ignored, so the first image frame and the first moment Motion state, determining the first pose can make the first pose fully consider the factors of the image frame and the motion state, so that the first pose is more accurate.
  • the first pose is determined according to the first image frame and the motion state at the first moment, specifically as follows:
  • the first preprocessing image can not only retain the key characteristics in the first image frame, but also effectively reduce the amount of data, and directly use the first preprocessing image to participate in the calculation, thereby maintaining the calculation accuracy and The computation load is significantly reduced, thereby improving the efficiency of determining the first pose.
  • the methods in steps 101 to 104 can be applied to the physical device shown in FIG. 2 .
  • the physical device includes a head-mounted device 1 , a sensor 2 , an image acquisition device 3 and a display 4 .
  • the head-mounted device 1 is used for calculating and processing the image, which can be implemented specifically by setting a processor and a memory in the head-mounted device 1 .
  • the image acquisition device 3 is arranged on the head-mounted device 1 , and the sensor 2 and the display 4 are also arranged on the head-mounted device 1 .
  • the physical device shown in FIG. 2 is only used as an example to show the physical device to which the methods of steps 101 to 104 can be applied.
  • the physical device shown in FIG. 2 can also be modified in various ways according to actual needs.
  • the physical device may also include a fixing device to prevent the user from falling off due to movement when wearing the headset 1 .
  • the motion state of the image acquisition device 3 at the first moment can be obtained specifically in the following manner:
  • the movement state of the sensor 2 and the movement state of the image acquisition device 3 can be set to move synchronously, so that the deviation of the movement state of the image acquisition device 3 at the first moment can be reduced.
  • step 104 may be specifically executed by the display 4 , and the image to be displayed is displayed on the display 4 .
  • the method shown in FIG. 1 can be applied to the architecture shown in FIG. 3 .
  • the motion state of the image acquisition device 3 at the first moment can be obtained through the sensor 2, and the first image frame of the image acquisition device 3 at the first moment can be obtained and output to the head-mounted device 1, thereby
  • the head-mounted device 1 can obtain the first pose according to the motion state at the first moment and the first image frame, and then predict the second pose based on the first pose, and further obtain the second virtual object.
  • the head-mounted device 1 can superimpose the second virtual image pre-generated before the second moment with the second image frame to obtain an image to be displayed, and output it to the display 4 for display.
  • the above-mentioned architecture is only an example of the application in FIG. 1, and the architecture shown in FIG. 3 can also have various deformations.
  • the sensor 2 can also obtain the motion state of at least one moment after the first moment and before the second moment .
  • step 101 to step 104 The specific process of step 101 to step 104 will be described in detail below.
  • step 101 may be as follows:
  • the motion state of the image acquisition device during the time period between the first moment and the second moment can be approximated as the motion state at the first moment, with the first pose as a reference, according to the first
  • the motion state at the moment determine the cumulative pose in the time period between the first moment and the second moment, so as to predict the second pose; or predict the first moment to the second moment according to the motion state at the first moment
  • the motion state of the image acquisition device at any time predict the motion state of the image acquisition device from the first moment to the second moment, and take the first pose as a reference, according to the predicted motion of the image acquisition device between the first moment and the second moment State, determine the cumulative pose in the time period between the first moment and the second moment, so as to predict the second pose.
  • a possible situation of step 101 (hereinafter referred to as the situation of at least two moments) can also be as follows:
  • the first pose and the motion state of the image capture device at at least two moments predict the pose of the image capture device at the second moment; according to the image capture device at the second moment pose, predict the second pose.
  • the at least two moments include: the first moment, at least one moment after the first moment and before the second moment.
  • the motion state at least one moment between after the first moment and before the second moment is also considered, so that The motion state change after the first moment is captured in time to predict the second pose more accurately.
  • the first pose and the average motion state of the motion state of the image acquisition device at at least two moments predict the cumulative pose from the first moment to the second moment, and according to the first moment Predicting the pose of the image acquisition device at the second moment from the cumulative pose and the first pose up to the second moment, and based on the pose of the image acquisition device at the second moment , to predict the second pose.
  • the more specific situation can also be as follows (hereinafter referred to as the situation of adjacent sub-periods):
  • the time period between the first moment and the second moment is divided into at least two sub-periods, the at least two sub-periods include adjacent first sub-periods and second sub-periods, the first sub-period The period is located before the second sub-period, the end time of the first sub-period is the first sub-time, and the end time of the second sub-period is the second sub-time.
  • any two adjacent first sub-periods and second sub-periods are taken as an example for illustration, and a specific time schematic diagram of this case may be shown in FIG. 4 .
  • only the end time of the first sub-period is taken as the start time of the second sub-period
  • the end time of can also be before the start time of the second sub-period, so that there is also a time interval between the first sub-period and the second sub-period.
  • the position of the image acquisition device at the second moment can be predicted according to the first pose and the motion state of the image acquisition device at at least two moments in the following manner: posture:
  • the pose and posture predicted by the image acquisition device at the first sub-moment and the motion state of the image acquisition device at the first sub-moment determine that the image acquisition device starts from the first sub-moment to The first cumulative pose of the second sub-moment;
  • the predicted The pose of the image acquisition device at the second sub-moment so that each iteration refers to the latest motion state at the end of the first sub-period, until the predicted position of the image acquisition device at the second time pose, so the pose of the image acquisition device at the second moment can be more accurately predicted through multiple sub-segment predictions in multiple sub-periods.
  • predicting the pose of the image acquisition device at the second sub-moment according to the pose at the first sub-moment and the first cumulative pose may specifically satisfy the following formula:
  • w 0 and w 0 represent weighting coefficients
  • t 0 represents the first sub-moment
  • t 1 represents the second sub-moment
  • the first sub-pose of the pose at the first sub-moment is the first sub-pose of the pose at the first sub-moment, the first sub-pose is based on the pose at the start time of the first sub-period and the start time of the first sub-period obtained from the state of motion, is the second sub-pose of the pose at the first sub-moment, and the second sub-pose is obtained according to the motion state at the initial moment of the first sub-period;
  • the first sub-cumulative pose of the first cumulative pose is the first sub-cumulative pose of the first cumulative pose, and the first sub-cumulative pose is obtained according to the pose at the first sub-moment and the motion state at the first sub-moment, is the second sub-cumulative pose of the first cumulative pose, and the second sub-cumulative pose is obtained according to the motion state at the first sub-moment.
  • the first sub-pose and the first sub-cumulative pose are obtained according to the pose at the beginning moment of the first sub-period, and the predicted pose is based on the first
  • the image frame is obtained, so the first sub-pose and the first sub-cumulative pose are calculated by considering the first image frame, while the second sub-pose and the second sub-cumulative pose are obtained according to the motion state
  • the first image frame is not considered, so the weighted average of the pose considering the first image frame and the pose not considering the first image frame can be more accurately predicted at the second sub-moment.
  • the above formula is only a calculation method for predicting the pose at the second sub-moment. According to the pose at the first sub-moment and the first cumulative pose, it is predicted that the image acquisition device will be at The pose of the second sub-moment can be calculated by flexibly selecting a formula according to requirements. For example, the formula can also be as follows:
  • a more specific situation (hereinafter referred to as the situation of the third sub-period) may be as follows:
  • the at least two sub-periods include a third sub-period, the third sub-period is adjacent to the second sub-period, the third sub-period is the last sub-period in the time period, and the third sub-period is adjacent to the second sub-period.
  • the cut-off time of the three sub-periods is the third sub-time.
  • the at least two sub-periods include at least three sub-periods, and a specific time diagram of this case may be shown in FIG. 5 .
  • the cut-off time of can also be before the start time of the third sub-period, so that there is a time interval between the second sub-period and the third sub-period.
  • the pose at the second sub-moment and the motion state at the second sub-moment determine the second cumulative pose and the position of the image acquisition device from the second sub-moment to the third sub-moment
  • the algorithm correction result of the pose of the second sub-moment
  • the motion state of the image acquisition device since the motion state of the image acquisition device will not be acquired after the second sub-moment and before the third sub-moment, it may first be based on the pose at the second sub-moment, the second sub-time The motion state at the sub-moment, correct the pose at the second sub-moment, and further predict the pose of the image acquisition device at the third sub-moment, so that the pose at the third sub-moment can be Correction is performed to obtain a more accurate pose at the third sub-moment.
  • the image acquisition device According to the second accumulated pose, the pose at the second sub-moment, and an algorithm correction result of the pose at the second sub-moment, it is predicted that the image acquisition device will be at the third
  • the pose at the sub-moment satisfies the following formula:
  • the pose at the third sub-moment can be predicted more accurately, so that the pose at the second moment can be predicted more accurately.
  • the above formula is only a calculation method for predicting the pose at the third sub-moment.
  • the formula can be flexibly selected according to the requirements for calculation.
  • the formula can also be as follows:
  • Step 102 can specifically be performed in the following manner:
  • the second virtual object is generated according to the first image frame and the second pose.
  • the pose corresponding to the first moment is the first pose
  • the image frame collected at the first moment is the first image frame
  • the first image can be transformed according to the change from the first pose to the second pose
  • the frame is subjected to corresponding image warping, so as to obtain the second virtual object.
  • the second virtual object may be generated according to the second pose and a preset virtual space model.
  • the preset virtual space model is a pre-built virtual space.
  • the preset virtual space model When the preset virtual space model is at a certain position and maintains a certain posture (such as when obtaining a certain posture), it can The virtual space model determines the corresponding image frame of the pose and generates the corresponding virtual object. Therefore, when the second pose is predicted, the second virtual object can be generated according to the second pose and the preset virtual space model.
  • steps 101 to 104 can be implemented in the following multi-threaded manner:
  • Step 101, step 102 can all be carried out by the first slave thread, also can be carried out jointly by the first slave thread and main thread, as can be executed step 101 by the first slave thread, then by main thread execution step 102;
  • Step 103, step 104 can be executed by the main thread, or jointly executed by the main thread and the display thread. For example, after the main thread executes step 103, the display thread executes step 104.
  • the specific thread execution method can be flexibly selected according to actual needs, and will not be done here. limited.
  • the first image frame and the first pose can also be obtained through the main thread in the following manner:
  • a first image frame By executing the main thread, acquiring a first image frame, performing distortion correction on the first image frame, extracting a distortion-corrected single-channel image, and down-sampling the distortion-corrected single-channel image, to obtain a first preview Process images.
  • the first pose can be determined according to the first pre-processing image and the motion state at the first moment.
  • the step of determining the first pose can be performed by the main thread or by the first slave thread. If the first slave thread executes this step, the main thread can be dedicated to acquiring image frames, or perform the process on the acquired image frames. Preprocessing, or obtaining the image to be displayed, can reduce the time delay for the main thread to obtain the image to be displayed, and the process of predicting the second pose in the middle can be executed exclusively by the first slave thread, thus ensuring the smooth execution of the entire process .
  • the second slave thread may also be executed to predict the third pose of the third virtual object corresponding to the third image frame according to the pose of the image acquisition device at the second moment.
  • the third image frame is an image frame collected by the image acquisition device at a third moment; the second moment is before the third moment, and the second image frame and the third image frame are the Two adjacent image frames captured by the image acquisition device; wherein, the first slave thread and the second slave thread are executed in parallel.
  • the execution actions of the second slave thread and the first slave thread can be the same, but the objects to be executed and the predicted poses are different. That is, the execution object of the first slave thread is the pose at the first moment, and the second pose is predicted, while the execution object of the second slave thread is the pose at the second moment, and the third pose is predicted. How the second slave thread predicts the third pose based on the pose at the second moment can refer to the above description of the first slave thread predicting the second pose. The process is similar and will not be repeated here.
  • the pose prediction will be performed in the time period between every two adjacent image frames, and the second pose at the second moment will be predicted through the first pose at the first moment, and according to the image acquisition Predicting the third pose of the third virtual object corresponding to the third image frame based on the pose of the device at the second moment, so as to predict the corresponding pose of the next image frame according to the pose of the image acquisition device corresponding to the previous image frame.
  • Virtual object pose, and one slave thread corresponds to one image frame, so that the execution of the slave threads corresponding to each image frame does not interfere with each other, even if a slave thread executes an error, it will not affect the prediction of other slave threads on the pose.
  • the main thread can run all the time, while the slave thread can run all the time, as follows:
  • K slave threads are always running, and K is a positive integer greater than 2.
  • K is a positive integer greater than 2.
  • the first image frame, the fourth image frame, the seventh image frame, and other slave threads can be deduced by analogy.
  • the first slave thread is destroyed.
  • the first slave thread can either be destroyed by itself or be destroyed by the main thread.
  • the first slave thread may transmit the predicted second pose to the main thread.
  • the first slave thread directly uses the second pose as the input of the main thread, or in the following manner transmission:
  • the second virtual object is stored in the shared cache; and a mutex is set for the second virtual object in the shared cache.
  • the mutex is used to prohibit the main thread from reading the second virtual object.
  • a mutex is set for the second virtual object in the shared cache, and when the second virtual object is the earliest in the shared cache pose, it means that the virtual objects before the second virtual object have been read by the main thread, then the second virtual object is already the first virtual object stored in the shared cache, which can be stored first
  • the virtual objects in the shared cache are first read by the main thread, so that the virtual objects can be read accurately in order through the mutex, increasing the accuracy of the image to be displayed.
  • Thread 0 acquires the Xth image frame captured by the image acquisition device, where X is a positive integer.
  • X represents the serial number of the image frame collected by the image acquisition device, for example, the Xth image frame can be the first image frame, can be the second image frame, ..., can also be the Nth image frame, etc., N is a positive integer greater than 2; the Xth moment can be the first moment, the second moment, ..., or the Nth moment, etc.
  • FIG. 6 illustrates the specific process of the multi-thread mode by taking the process from the Xth moment to the X+1th moment as an example.
  • thread X When thread 0 (the main thread) acquires the Xth image frame captured by the image capture device, thread X can start to be created.
  • the Xth slave thread may be the first slave thread, the second slave thread...the Nth slave thread, and so on.
  • Thread 0 can store the Xth image frame into the data cache, or preprocess the Xth image frame to obtain the Xth preprocessed image, and store the Xth preprocessed image into the data cache (in FIG.
  • the image frame is preprocessed as an example); thread X (the Xth slave thread) can also be created when the Xth preprocessed image is obtained.
  • thread X From time X to time X+1, after thread X is created, it can predict X+1 based on the X-th preprocessed image (or directly based on the X-th image frame) and the motion state of X-th time pose, and generate the X+1th virtual object according to the X+1th pose; for example, after thread 1 (such as the first slave thread) is created, according to the first preprocessing image and the motion state at the first moment, predict second pose, and generate a second virtual object according to the second pose.
  • thread 1 such as the first slave thread
  • a mutex can be added to the X+1 virtual object.
  • the main thread (thread 0) needs to obtain the X+1 virtual object (that is, the X+1 virtual object When it is the earliest virtual object in the shared cache), unlock the X+1th virtual object.
  • an image processing device including:
  • the prediction module 701 is configured to predict the second pose of the second virtual object corresponding to the second image frame according to the first pose of the image acquisition device at the first moment; the second image frame is the image acquisition device at the second The image frame collected at time; the first time is located before the second time, and the first time is the time when the image acquisition device collects the first image frame, and the first image frame and the second image frame are the time when the image is collected Two adjacent image frames collected by the device;
  • the image acquisition device is set on a head-mounted device, and the head-mounted device is also provided with a sensor and a display;
  • the prediction module 701 is specifically configured to: acquire the motion state collected by the sensor at the first moment;
  • the movement state collected by the sensor at the first moment is used as the movement state of the image acquisition device at the first moment;
  • the processing module 702 is also configured to: display the image to be displayed on the display.
  • the at least two moments include: the first moment, the first moment From thereafter to at least one moment before the second moment; predicting the second pose according to the pose of the image acquisition device at the second moment.
  • the time period between the first moment and the second moment is divided into at least two sub-periods, the at least two sub-periods include adjacent first sub-periods and second sub-periods, the first sub-period The period is located before the second sub-period, the cut-off time of the first sub-period is the first sub-time, and the cut-off time of the second sub-period is the second sub-time;
  • the prediction module 701 is specifically used for:
  • the first cumulative pose predicting the pose of the image acquisition device at the second sub-moment according to the predicted pose at the first sub-moment and the first cumulative pose.
  • predicting the pose of the image acquisition device at the second sub-moment according to the pose at the first sub-moment and the first accumulated pose may specifically satisfy the following formula:
  • w 0 and w 0 represent weighting coefficients
  • t 0 represents the first sub-moment
  • t 1 represents the second sub-moment
  • the first sub-pose is obtained according to the pose at the initial moment of the first sub-period and the motion state at the initial moment of the first sub-period of
  • the second sub-pose is obtained according to the motion state at the initial moment of the first sub-period
  • the first sub-cumulative pose is obtained according to the pose at the first sub-moment and the motion state at the first sub-moment, is the second sub-cumulative pose of the first cumulative pose
  • the second sub-cumulative pose of the first cumulative pose is the second sub-cumulative pose of the first cumulative pose
  • the at least two sub-periods include a third sub-period, the third sub-period is adjacent to the second sub-period, the third sub-period is the last sub-period in the time period, and the third sub-period
  • the deadline of the period is the third sub-moment; the prediction module 701 is also used for:
  • the pose at the second sub-moment and the motion state at the second sub-moment determine the second cumulative pose of the image acquisition device from the second sub-moment to the third sub-moment and the position of the second sub-moment Algorithm correction result of pose; according to the algorithm correction result of the second cumulative pose, the pose of the second sub-moment and the pose of the second sub-moment, predict the position of the image acquisition device at the third sub-moment posture.
  • t 1 represents the second sub-moment
  • t 2 represents the third sub-moment
  • processing module 702 is specifically used for:
  • the second virtual object is generated according to the first image frame and the second pose.
  • processing module 702 is specifically used for:
  • the second virtual object is generated according to the second pose and the preset virtual space model.
  • obtaining the image to be displayed corresponding to the second moment is executed through the main thread; predicting the second pose of the second virtual object corresponding to the second image frame is executed through the first slave thread; the processing module 702 Also used for:
  • the second slave thread By executing the second slave thread, predict the third pose of the third virtual object corresponding to the third image frame according to the pose of the image acquisition device at the second moment, and the third image frame is the image acquisition device at the second moment.
  • Image frames collected at three moments; the second moment is located before the third moment, and the second image frame and the third image frame are two adjacent image frames collected by the image acquisition device; wherein, the first slave thread Execute in parallel with the second slave thread.
  • processing module 702 is also used for:
  • distortion correction is performed on the first image frame, a distortion-corrected single-channel image is extracted, and the distortion-corrected single-channel image is down-sampled to obtain a first preprocessed image.
  • processing module 702 is also used for:
  • the first slave thread is created; when the second pose of the second virtual object is predicted, the first slave thread is destroyed.
  • processing module 702 is also used for:
  • the second virtual object is stored in the shared cache; a mutex is set for the second virtual object in the shared cache; the mutex is used to prohibit the main thread from reading the second virtual object; when the second virtual object is the earliest pose in the shared cache, release the mutex set for the second virtual object in the shared cache; use the main thread to read from the shared cache the second virtual object.
  • the embodiment of the present application also provides another image processing device, which includes: one or more processors and a transmission interface; wherein, the one or more processors are configured to invoke computer instructions stored in the memory, so that the The device executes the steps and optional steps in the method shown in FIG. 1 .
  • FIG. 8 is a schematic structural diagram of another electronic device provided by an embodiment of the present application.
  • the electronic device may be an image processing device, and the electronic device 800 includes: at least one central processing unit (Central Processing Unit, CPU), memory, and the type of memory may include, for example, a static random-access memory (Static Random-Access Memory, SRAM) And read-only memory (Read-Only Memory, ROM), microcontroller (Micro controller Unit, MCU), wireless local area network (Wireless Local Area Network, WLAN) subsystem, bus, transmission interface, etc.
  • the electronic device 800 may also include other dedicated processors such as an application processor (Application Processor, AP), NPU, and other power management subsystems, clock management subsystems, and power management subsystems. subsystem.
  • Application Processor Application Processor
  • the connectors include various interfaces, transmission lines or buses, etc. These interfaces are usually electrical communication interfaces, but may also be mechanical interfaces or other forms of interfaces. This embodiment does not limit it.
  • the CPU can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor; optionally, the CPU can be a processor group composed of a plurality of processors, and between a plurality of processors are coupled to each other by one or more buses.
  • the CPU implements any image processing method in the foregoing method embodiments by calling program instructions stored in the on-chip memory or the off-chip memory.
  • the CPU and the MCU jointly implement any image processing method in the foregoing method embodiments, for example, the CPU completes some steps in the image processing method, and the MCU completes other steps in the image processing method.
  • the AP or other special-purpose processor implements any one of the image processing methods in the foregoing method embodiments by calling program instructions stored in the on-chip memory or off-chip memory.
  • the transmission interface can be an interface for receiving and sending data of the processor chip, and the transmission interface usually includes multiple interfaces.
  • the transmission interface can include an internal integrated circuit (Inter-Integrated Circuit, I2C) Interface, Serial Peripheral Interface (SPI), Universal asynchronous receiver-transmitter (UART) interface, General-purpose input/output (GPIO) interface, etc. It should be understood that these interfaces may implement different functions by multiplexing the same physical interface.
  • the transmission interface may also include High Definition Multimedia Interface (HDMI), V-By-One interface, Embedded Display Port (EDP), mobile industry processing Interface (Mobile Industry Processor Interface, MIPI) or Display Port (DP), etc.
  • HDMI High Definition Multimedia Interface
  • V-By-One interface V-By-One interface
  • EDP Embedded Display Port
  • MIPI Mobile Industry Processor Interface
  • DP Display Port
  • the above parts are integrated on the same chip; in another optional situation, the memory may be an independent chip.
  • a WLAN subsystem may include, for example, radio frequency circuits and a baseband.
  • the chip involved in the embodiment of this application is a system manufactured on the same semiconductor substrate by an integrated circuit process, also called a semiconductor chip, which can be fabricated on a substrate (usually a semiconductor such as silicon) by using an integrated circuit process.
  • the integrated circuit may include various functional devices, and each type of functional device includes transistors such as logic gate circuits, Metal-Oxide-Semiconductor (MOS) transistors, bipolar transistors or diodes, and may also include capacitors, resistors, etc. or other components such as inductors.
  • MOS Metal-Oxide-Semiconductor
  • bipolar transistors or diodes may also include capacitors, resistors, etc. or other components such as inductors.
  • Each functional device can work independently or under the action of necessary driver software, and can realize various functions such as communication, calculation, or storage.
  • the embodiment of the present application also provides a computer-readable storage medium.
  • Computer instructions are stored on the computer-readable storage medium. When these computer instructions are called and executed by a computer, the computer can complete any one of the above-mentioned method embodiments and method embodiments. methods involved in a possible design.
  • the computer-readable storage medium is not limited, for example, it may be RAM (random-access memory, random access memory), ROM (read-only memory, read-only memory), etc.
  • An embodiment of the present application also provides a computer program product, the computer program product includes computer instructions, and when the computer instructions are executed on a computer or a processor, the computer or the processor executes the above-mentioned method embodiment and method embodiment.
  • the embodiment of the present application also provides a chip, which may include a processor and an interface circuit, for completing the methods involved in any of the above method embodiments and any possible implementations of the method embodiments, wherein "coupling” Refers to the direct or indirect coupling of two parts to each other, which can be fixed or movable.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software it may be implemented in whole or in part in the form of computer instructions.
  • the computer instructions When the computer instructions are loaded and executed on the computer, the procedures or functions according to the embodiments of the present invention will be generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber) or wireless (eg, infrared, wireless, microwave, etc.) means.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media.
  • the available medium may be a magnetic medium (such as a floppy disk, a hard disk, or a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (Solid State Disk, SSD)), etc.
  • a magnetic medium such as a floppy disk, a hard disk, or a magnetic tape
  • an optical medium such as a DVD
  • a semiconductor medium such as a solid state disk (Solid State Disk, SSD)
  • the steps of the method or algorithm described in the embodiments of the present application may be directly embedded in hardware, a software unit executed by a processor, or a combination of both.
  • the software unit may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM or any other storage medium in the art.
  • the storage medium can be connected to the processor, so that the processor can read information from the storage medium, and can write information to the storage medium.
  • the storage medium can also be integrated into the processor.
  • the processor and the storage medium can be set in the ASIC, and the ASIC can be set in the terminal device.
  • the processor and the storage medium may also be disposed in different components in the terminal device.
  • These computer instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device Steps are provided for implementing the functions specified in the flow chart or flow charts and/or block diagram block or blocks.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Architecture (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本申请实施例提供一种图像处理方法及装置。其中方法包括:根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿,所述第二图像帧为所述图像采集装置在第二时刻采集的图像帧;根据所述第二位姿生成所述第二虚拟对象;获取所述第二图像帧;将所述第二虚拟对象和所述第二图像帧叠加,得到所述第二时刻对应的待显示图像。上述方法中,不需要获取所述第二图像帧后才计算第二位姿,可以提前根据预测的第二位姿生成第二虚拟对象,可以在获取第二图像帧后,直接将提前生成的第二虚拟对象和即时获取的第二图像帧叠加,及时得到所述第二时刻对应的待显示图像。

Description

一种图像处理方法及装置 技术领域
本申请涉及虚拟现实技术领域,尤其涉及一种图像处理方法及装置。
背景技术
虚拟现实(virtual reality,VR)、增强现实(augmented reality,AR)、混合现实(mixed reality,MR)等技术是将虚拟世界呈现给使用者的常用技术,在近年来得到了突飞猛进的发展,AR和MR均要以VR为基础。目前VR等技术常与视频透视技术(video see through,VST)或透视技术(pass through,PT)相结合应用。目前的应用方案中,可以从真实世界场景采集图像,并通过VR等技术处理后,将处理后的图像显示给用户。
目前的应用方案中采集的图像帧与待显示图像是对应的,然而,从采集图像帧到待显示图像需要一系列的处理,存在较久的处理时延。这是一个亟待解决的问题。
发明内容
本申请提供一种图像处理方法及装置,用于降低待显示图像的处理时延。
第一方面,本申请提供一种图像处理方法,该方法可以由本申请提供的图像处理装置执行,该方法包括:
根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿;该第二图像帧为该图像采集装置在第二时刻采集的图像帧;该第一时刻位于该第二时刻之前,且该第一时刻为该图像采集装置采集第一图像帧的时刻,该第一图像帧和该第二图像帧为该图像采集装置采集的两个相邻图像帧;根据该第二位姿生成该第二虚拟对象;获取该第二图像帧;将该第二虚拟对象和该第二图像帧叠加,得到该第二时刻对应的待显示图像。
需要说明的是,现有技术中,由于计算位姿的处理时延较久,当计算得到第二图像帧对应的第二虚拟对象时,可能会出现获取到第二图像帧之后的图像帧(如第四图像帧)的情况,从而使得第二图像帧对应的第二虚拟对象与第二图像帧之后的图像帧叠加,导致待显示图像中虚拟对象和图像帧不匹配,第四图像帧为第二图像帧之后的第二个图像帧;而上述方法下,可以在第二图像帧采集到时就可以直接获取到与之匹配的第二虚拟对象,从而待显示图像可以显示实时采集的图像。
上述方法中,可以在获取第二图像帧之前,根据图像采集装置在第一时刻的第一位姿,提前预测第二虚拟对象的第二位姿,不需要获取该第二图像帧后才计算第二位姿,可以提前根据预测的第二位姿生成第二虚拟对象,由于该第一图像帧和该第二图像帧为该图像采集装置采集的两个相邻图像帧,且提前预测了该第二位姿,所以可以在获取第二图像帧后,便可以直接将提前生成的第二虚拟对象和即时获取的第二图像帧叠加,及时得到该第二时刻对应的待显示图像,从而降低了该第二时刻对应的待显示图像的处理时延。
可选的,根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,可以按照以下方式确定该第一位姿:
获取该图像采集装置在该第一时刻的运动状态;根据该第一图像帧和该第一时刻的运 动状态,确定该第一位姿。
上述方法中,综合该第一图像帧和该第一时刻的运动状态,确定该第一位姿,可以使得该第一位姿充分考虑图像帧和运动状态的因素,使得该第一位姿更加精确。
可选的,根据所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿,包括:
对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像;根据该第一预处理图像和该第一时刻的运动状态,确定该第一位姿。
通过上述预处理过程,可以使得第一预处理图像既保留了第一图像帧中的关键特性,又可以有效降低数据量,直接用第一预处理图像参与运算,从而既保持了计算精度,又显著降低了运算量,提升确定该第一位姿的效率。
可选的,上述方法应用于如下物理设备:该物理设备由该图像采集装置、头戴装置、传感器和显示器等各部分装置组合而成,该图像采集装置设置在头戴装置上,该头戴装置上还设置有传感器和显示器。
所述方法可以按照通过以下方式由各部分装置组合执行:
获取该传感器在该第一时刻采集到的运动状态;将该传感器在该第一时刻采集到的运动状态,作为该图像采集装置在该第一时刻的运动状态;将该待显示图像显示在该显示器上。
通过该图像采集装置、头戴装置、传感器和显示器等组合实现了上述图像处理方法,从而提供了该方法的一种应用场景,使得各部分都有其独立的分工,不会造成图像采集装置等部分的负担过重,使得上述图像处理方法执行得更加有效率。
可选的,根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿,包括:
根据该第一位姿和该图像采集装置在至少两个时刻的运动状态,预测该图像采集装置在该第二时刻的位姿;该至少两个时刻包括:该第一时刻、该第一时刻之后至该第二时刻之前的至少一个时刻;根据该图像采集装置在该第二时刻的位姿,预测该第二位姿。
上述方法中,在计算该第二位姿的过程中,除了第一时刻的运动状态外,还考虑了该第一时刻之后至该第二时刻之前中间至少一个时刻的运动状态,从而及时捕捉到第一时刻之后的运动状态变化,更准确地预测该第二位姿。
可选的,该第一时刻与该第二时刻之间的时间段被划分为至少两个子时段,该至少两个子时段中包括相邻的第一子时段和第二子时段,该第一子时段位于该第二子时段之前,该第一子时段的截止时刻为第一子时刻,该第二子时段的截止时刻为第二子时刻;根据该第一位姿和该图像采集装置在至少两个时刻的运动状态,预测该图像采集装置在该第二时刻的位姿,包括:
根据该图像采集装置在该第一子时刻预测到的位姿和该图像采集装置在该第一子时刻的运动状态,确定该图像采集装置自该第一子时刻起至该第二子时刻的第一累积位姿;根据该第一子时刻预测到的位姿以及该第一累积位姿,预测该图像采集装置在该第二子时刻的位姿。
上述方法中,针对任意两个相邻的第一子时段和第二子时段,以该第一子时刻预测到的位姿和该第一子时刻的运动状态为基准,预测该图像采集装置在该第二子时刻的位姿, 从而每次迭代都参照了最新的第一子时段的截止时刻的运动状态,直至预测到该图像采集装置在该第二时刻的位姿,所以通过多个子时段多次分段预测可以更准确地预测到该图像采集装置在该第二时刻的位姿。
可选的,根据所述第一子时刻的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿,具体可以满足以下公式:
Figure PCTCN2021094744-appb-000001
其中,
Figure PCTCN2021094744-appb-000002
为该第二子时刻的位姿,
Figure PCTCN2021094744-appb-000003
为该第一子时刻的位姿,
Figure PCTCN2021094744-appb-000004
为该第一累积位姿,w 0和w 0表示加权系数,t 0表示第一子时刻,t 1表示第二子时刻;
Figure PCTCN2021094744-appb-000005
是该第一子时刻的位姿的第一子位姿,该第一子位姿是根据该第一子时段的起始时刻的位姿和该第一子时段的起始时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000006
是该第一子时刻的位姿的第二子位姿,该第二子位姿是根据该第一子时段的起始时刻的运动状态得到的;
Figure PCTCN2021094744-appb-000007
是该第一累积位姿的第一子累积位姿,该第一子累积位姿是根据该第一子时刻的位姿和该第一子时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000008
是该第一累积位姿的第二子累积位姿,该第二子累积位姿是根据该第一子时刻的运动状态得到的。
上述公式中,第一子位姿、第一子累积位姿都是根据该第一子时段的起始时刻的位姿得到的,而预测到的位姿都是根据第一时刻的第一图像帧得到的,所以第一子位姿、第一子累积位姿是考虑了第一图像帧计算得到的位姿,而第二子位姿、第二子累积位姿都是根据运动状态得到的,并未考虑第一图像帧,所以将考虑了第一图像帧的位姿和未考虑第一图像帧的位姿进行加权平均,可以更准确地预测该第二子时刻的位姿。
可选的,至少两个子时段中包括第三子时段,该第三子时段与该第二子时段相邻,该第三子时段是该时间段内的最后一个子时段,该第三子时段的截止时刻为第三子时刻;该方法还包括:
根据该第二子时刻的位姿、该第二子时刻的运动状态,确定该图像采集装置自该第二子时刻起至该第三子时刻的第二累积位姿和该第二子时刻的位姿的算法校正结果;根据该第二累积位姿、该第二子时刻的位姿以及该第二子时刻的位姿的算法校正结果,预测该图像采集装置在该第三子时刻的位姿。
上述方式下,对于第三子时段,由于第二子时刻之后至第三子时刻之前不会再获取图像采集装置的运动状态,可以先根据该第二子时刻的位姿、该第二子时刻的运动状态,对该第二子时刻的位姿进行校正,并进一步预测该图像采集装置在该第三子时刻的位姿,从而可以对该第三子时刻的位姿进行校正,获得更准确的该第三子时刻的位姿。
可选的,根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿,满足以下公式:
Figure PCTCN2021094744-appb-000009
其中,
Figure PCTCN2021094744-appb-000010
为该第三子时刻的位姿,
Figure PCTCN2021094744-appb-000011
为该第二子时刻的位姿的算法校正结果,
Figure PCTCN2021094744-appb-000012
为该第二累积位姿,
Figure PCTCN2021094744-appb-000013
为该第二子时刻的位姿,w 2和w 3表示加权系数,t 1表示第二子时刻,t 2表示第三子时刻。
上述公式中,通过该第二子时刻的位姿的算法校正结果和该第二累积位姿,得到第二子时刻累积至第三子时刻的算法校正的结果,再将进行算法校正的结果和未进行算法校正的该第二子时刻的位姿进行加权,可以更为准确地预测第三子时刻的位姿,从而可以更准确地预测第二时刻的位姿。
可选的,根据第二位姿生成第二虚拟对象,包括:
根据第一图像帧和第二位姿,生成第二虚拟对象。
可选的,根据第二位姿生成第二虚拟对象,包括:
根据第二位姿和预设虚拟空间模型,生成第二虚拟对象。
可选的,该图像处理方法可以通过以下多线程方式执行:
得到第二时刻对应的待显示图像是通过主线程执行的;预测第二图像帧对应的第二虚拟对象的第二位姿是通过第一从线程执行的。
获取该第二图像帧之后,还包括:
通过执行第二从线程,根据该图像采集装置在该第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,该第三图像帧为该图像采集装置在第三时刻采集的图像帧;该第二时刻位于该第三时刻之前,该第二图像帧和该第三图像帧为该图像采集装置采集的两个相邻图像帧;其中,该第一从线程和该第二从线程并行执行。
通过上述多线程方式,每两个相邻图像帧之间的时间段都会进行位姿预测,通过第一时刻的第一位姿,预测第二时刻的第二位姿,且根据该图像采集装置在该第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,从而依次根据前一图像帧对应图像采集装置的位姿,预测下一图像帧对应的虚拟对象位姿,且一个从线程与一个图像帧对应,从而各图像帧对应的从线程执行互不干扰,即便某个从线程执行出现错误,也不会影响其他从线程对位姿的预测。
可选的,根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,还包括:
通过执行该主线程,对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
通过上述预处理过程,主线程直接输出第一预处理图像,可以使得第一预处理图像既保留了第一图像帧中的关键特性,又可以有效降低数据量,直接用第一预处理图像参与运算,从而既保持了计算精度,又显著降低了第一从线程的运算量。
可选的,该图像处理方法还包括:
获取到该第一图像帧后,创建该第一从线程;当预测得到该第二虚拟对象的该第二位姿后,该第一从线程被销毁。
通过上述方式,只在需要预测第二位姿时创建第一从线程用于预测第二位姿即可,当第一从线程预测到第二位姿后,第一从线程即被销毁,从而可以及时回收资源。
另外,第一从线程将预测到的第二位姿传输给该主线程可以有多种方式,比如第一从线程直接将第二位姿作为该主线程的输入,也可以按照以下方式传输:
通过执行该第一从线程,将该第二虚拟对象存入共享缓存;为该共享缓存中该第二虚拟对象设置互斥锁;该互斥锁用于禁止该主线程读取该第二虚拟对象;当该第二虚拟对象为该共享缓存中时刻最早的位姿时,将该共享缓存中为该第二虚拟对象设置的互斥锁解除;使用该主线程,从该共享缓存中读取该第二虚拟对象。
通过上述方式,将该第二虚拟对象存入共享缓存后,为该共享缓存中该第二虚拟对象设置互斥锁,当该第二虚拟对象为该共享缓存中时刻最早的位姿时,说明该第二虚拟对象之前的虚拟对象都已经被主线程读取,那么该第二虚拟对象已经是该共享缓存中最先存入 的虚拟对象,可以使得先存入共享缓存的虚拟对象先被主线程读取,从而通过互斥锁,使得虚拟对象能够按照顺序准确地被读取,增加了待显示图像的准确性。
第二方面,本申请提供一种图像处理装置,包括:
预测模块,用于根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿;该第二图像帧为该图像采集装置在第二时刻采集的图像帧;该第一时刻位于该第二时刻之前,且该第一时刻为该图像采集装置采集第一图像帧的时刻,该第一图像帧和该第二图像帧为该图像采集装置采集的两个相邻图像帧;
处理模块,用于根据该第二位姿生成该第二虚拟对象;处理模块,还用于获取该第二图像帧;处理模块,还用于将该第二虚拟对象和该第二图像帧叠加,得到该第二时刻对应的待显示图像。
需要说明的是,第二图像帧是图像采集装置采集的,处理模块可以从图像采集装置处获取第二图像帧,也可以图像采集装置将采集到的第二图像帧存入数据缓存中后,处理模块从数据缓存中获取第二图像帧。
可选的,根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,该预测模块还用于:
获取该图像采集装置在该第一时刻的运动状态;根据该第一图像帧和该第一时刻的运动状态,确定该第一位姿。
可选的,该预测模块具体用于:
对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像;根据该第一预处理图像和该第一时刻的运动状态,确定该第一位姿。
可选的,该图像采集装置设置在头戴装置上,该头戴装置上还设置有传感器和显示器;该预测模块具体用于:获取该传感器在该第一时刻采集到的运动状态;将该传感器在该第一时刻采集到的运动状态,作为该图像采集装置在该第一时刻的运动状态;该处理模块还用于:将该待显示图像显示在该显示器上。
可选的,该预测模块具体用于:
根据该第一位姿和该图像采集装置在至少两个时刻的运动状态,预测该图像采集装置在该第二时刻的位姿;该至少两个时刻包括:该第一时刻、该第一时刻之后至该第二时刻之前的至少一个时刻;根据该图像采集装置在该第二时刻的位姿,预测该第二位姿。
可选的,该第一时刻与该第二时刻之间的时间段被划分为至少两个子时段,该至少两个子时段中包括相邻的第一子时段和第二子时段,该第一子时段位于该第二子时段之前,该第一子时段的截止时刻为第一子时刻,该第二子时段的截止时刻为第二子时刻;该预测模块具体用于:
根据该图像采集装置在该第一子时刻预测到的位姿和该图像采集装置在该第一子时刻的运动状态,确定该图像采集装置自该第一子时刻起至该第二子时刻的第一累积位姿;根据该第一子时刻预测到的位姿以及该第一累积位姿,预测该图像采集装置在该第二子时刻的位姿。
可选的,根据所述第一子时刻的位姿以及所述第一累积位姿,预测所述图像采集装置 在所述第二子时刻的位姿,具体可以满足以下公式:
Figure PCTCN2021094744-appb-000014
其中,
Figure PCTCN2021094744-appb-000015
为该第二子时刻的位姿,
Figure PCTCN2021094744-appb-000016
为该第一子时刻的位姿,
Figure PCTCN2021094744-appb-000017
为该第一累积位姿,w 0和w 0表示加权系数,t 0表示第一子时刻,t 1表示第二子时刻;
Figure PCTCN2021094744-appb-000018
是该第一子时刻的位姿的第一子位姿,该第一子位姿是根据该第一子时段的起始时刻的位姿和该第一子时段的起始时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000019
是该第一子时刻的位姿的第二子位姿,该第二子位姿是根据该第一子时段的起始时刻的运动状态得到的;
Figure PCTCN2021094744-appb-000020
是该第一累积位姿的第一子累积位姿,该第一子累积位姿是根据该第一子时刻的位姿和该第一子时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000021
是该第一累积位姿的第二子累积位姿,该第二子累积位姿是根据该第一子时刻的运动状态得到的。
可选的,该至少两个子时段中包括第三子时段,该第三子时段与该第二子时段相邻,该第三子时段是该时间段内的最后一个子时段,该第三子时段的截止时刻为第三子时刻;该预测模块还用于:
根据该第二子时刻的位姿、该第二子时刻的运动状态,确定该图像采集装置自该第二子时刻起至该第三子时刻的第二累积位姿和该第二子时刻的位姿的算法校正结果;根据该第二累积位姿、该第二子时刻的位姿以及该第二子时刻的位姿的算法校正结果,预测该图像采集装置在该第三子时刻的位姿。
可选的,根据该第二累积位姿、该第二子时刻的位姿以及该第二子时刻的位姿的算法校正结果,预测该图像采集装置在该第三子时刻的位姿,满足以下公式:
Figure PCTCN2021094744-appb-000022
其中,
Figure PCTCN2021094744-appb-000023
为该第三子时刻的位姿,
Figure PCTCN2021094744-appb-000024
为该第二子时刻的位姿的算法校正结果,
Figure PCTCN2021094744-appb-000025
为该第二累积位姿,
Figure PCTCN2021094744-appb-000026
为该第二子时刻的位姿,w 2和w 3表示加权系数,t 1表示第二子时刻,t 2表示第三子时刻。
可选的,该处理模块具体用于:
根据第一图像帧和第二位姿,生成该第二虚拟对象。
可选的,该处理模块具体用于:
根据第二位姿和预设虚拟空间模型,生成该第二虚拟对象。
可选的,得到该第二时刻对应的待显示图像是通过主线程执行的;预测第二图像帧对应的第二虚拟对象的第二位姿是通过第一从线程执行的;该处理模块还用于:
通过执行第二从线程,根据该图像采集装置在该第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,该第三图像帧为该图像采集装置在第三时刻采集的图像帧;该第二时刻位于该第三时刻之前,该第二图像帧和该第三图像帧为该图像采集装置采集的两个相邻图像帧;其中,该第一从线程和该第二从线程并行执行。
可选的,该处理模块还用于:
通过执行该主线程,对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
可选的,该处理模块还用于:
获取到该第一图像帧后,创建该第一从线程;当预测得到该第二虚拟对象的该第二位姿后,该第一从线程被销毁。
可选的,该处理模块还用于:
通过执行该第一从线程,将该第二虚拟对象存入共享缓存;为该共享缓存中该第二虚拟对象设置互斥锁;该互斥锁用于禁止该主线程读取该第二虚拟对象;当该第二虚拟对象为该共享缓存中时刻最早的位姿时,将该共享缓存中为该第二虚拟对象设置的互斥锁解除;使用该主线程,从该共享缓存中读取该第二虚拟对象。
第三方面,提供另一种图像处理装置,该装置包括:一个或多个处理器以及传输接口;其中,该一个或多个处理器被配置为调用存储在存储器中的计算机指令,使得该装置执行如上述第一方面中任一项的方法。
第四方面,提供一种电子设备,该电子设备包括:一个或多个处理器;一个或多个存储器;其中,该一个或多个存储器存储有一个或多个计算机指令,当该一个或多个计算机指令被该一个或多个处理器执行时,使得该电子设备执行如上述第一方面中任一项的方法。
第五方面,提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令,当计算机指令在计算机上运行时,使得该计算机执行如上述第一方面中任一项的方法。
第六方面,提供一种计算机程序产品,该计算机程序产品包括计算机指令,当该计算机指令在计算机或处理器上执行时,使得该计算机或该处理器执行如上述第一方面中任一项的方法。
以上第二方面到第六方面的有益效果,请参见第一方面的有益效果,不重复赘述。
附图说明
图1为本申请实施例提供的一种图像处理方法的流程示意图;
图2为本申请实施例提供的一种图像处理方法可应用的物理设备的结构示意图;
图3为本申请实施例提供的一种图像处理方法可应用的架构示意图;
图4为本申请实施例提供的一种图像处理方法中相邻子时段的情形的时间示意图;
图5为本申请实施例提供的一种图像处理方法中第三子时段的情形的时间示意图;
图6为本申请实施例提供的一种图像处理方法中多线程方式的具体过程示意图;
图7为本申请实施例提供的一种图像处理装置的结构示意图;
图8为本申请实施例提供的另一种图像处理装置的结构示意图。
具体实施方式
为了使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施例作进一步地详细描述。方法实施例中的具体操作方法也可以应用于装置实施例或系统实施例中。
以下实施例中所使用的术语只是为了描述特定实施例的目的,而并非旨在作为对本申请的限制。如在本申请的说明书和所附权利要求书中所使用的那样,单数表达形式“一个”、“一种”、“所述”、“上述”、“该”和“这一”旨在也包括例如“一个或多个”这种表达形式,除非其上下文中明确地有相反指示。还应当理解,在本申请实施例中,“一个或多个”是指一个或两个以上(包含两个);“和/或”,描述关联对象的关联关系,表示可以存在三种关系;例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A、B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。
在本说明书中描述的参考“一个实施例”或“一些实施例”等意味着在本申请的一个 或多个实施例中包括结合该实施例描述的特定特征、结构或特点。由此,在本说明书中的不同之处出现的语句“在一个实施例中”、“在一些实施例中”、“在其他一些实施例中”、“在另外一些实施例中”等不是必然都参考相同的实施例,而是意味着“一个或多个但不是所有的实施例”,除非是以其他方式另外特别强调。术语“包括”、“包含”、“具有”及它们的变形都意味着“包括但不限于”,除非是以其他方式另外特别强调。
本申请实施例中的术语多个”是指两个或两个以上,鉴于此,本申请实施例中也可以将“多个”理解为“至少两个”。“至少一个”,可理解为一个或多个,例如理解为一个、两个或更多个。例如,包括至少一个,是指包括一个、两个或更多个,而且不限制包括的是哪几个。例如,包括A、B和C中的至少一个,那么包括的可以是A、B、C,A和B,A和C,B和C,或A和B和C。A、B或C中的至少一个,可以解释为A、B、C,A和B,A和C,B和C,或A和B和C。同理,对于“至少一种”等描述的理解,也是类似的。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,字符“/”,如无特殊说明,一般表示前后关联对象是一种“或”的关系。
除非有相反的说明,本申请实施例提及“第一”、“第二”等序数词用于对多个对象进行区分,不用于限定多个对象的顺序、时序、优先级或者重要程度。
虚拟现实(virtual reality,VR)、增强现实(augmented reality,AR)、混合现实(mixed reality,MR)等技术是将虚拟世界呈现给使用者的常用技术,AR和MR均要以VR为基础。视频透视技术(video see through,VST)或透视技术(pass through,PT)是以VR技术为基础的常见应用技术,VST或PT可以从真实世界场景获取图像帧,在图像帧上叠加虚拟对象,显示在人眼面前。然而,从采集图像帧到显示图像需要一系列的处理,存在较久的处理时延。为此,如图1所示,本申请实施例提供一种图像处理方法。
步骤101:根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿。
所述第二图像帧为所述图像采集装置在第二时刻采集的图像帧;所述第一时刻位于所述第二时刻之前,且所述第一时刻为所述图像采集装置采集第一图像帧的时刻,所述第一图像帧和所述第二图像帧为所述图像采集装置采集的两个相邻图像帧。
步骤102:根据所述第二位姿生成所述第二虚拟对象。
步骤103:获取所述第二图像帧。
步骤104:将所述第二虚拟对象和所述第二图像帧叠加,得到所述第二时刻对应的待显示图像。
步骤101~步骤104所述的方法中,所述第一图像帧和所述第二图像帧为所述图像采集装置采集的两个相邻图像帧,显然,所述第一时刻与所述第二时刻之间的时长是根据图像采集装置的帧率确定的,举例来说,图像采集装置的帧率为20Hz,那么所述第一时刻与所述第二时刻之间的时长为50ms。
需要说明的是,现有技术中,由于计算位姿的处理时延较久,由于计算位姿的处理时延较久,当计算得到第二图像帧对应的第二虚拟对象时,可能会出现获取到第二图像帧之后的图像帧(如第四图像帧)的情况,从而使得第二图像帧对应的第二虚拟对象与第二图像帧之后的图像帧叠加,导致待显示图像中虚拟对象和图像帧不匹配,第四图像帧为第二 图像帧之后的第二个图像帧;而步骤101~步骤104所述的方法下,可以在第二图像帧采集到时就可以直接获取到与之匹配的第二虚拟对象,从而待显示图像可以显示实时采集的图像。
步骤101之前,所述第一位姿可以按照以下方式获取:
根据第一图像帧,确定第一位姿。
具体确定方式可以依据预设位姿算法,预设位姿算法可以为即时定位与地图构建(simultaneous localization and mapping,SLAM)算法。
需要说明的是,上述方式中,既可以直接将第一图像帧作为预设位姿算法的输入,也可以将第一图像帧进行预处理后,将预处理后的图像作为预设位姿算法的输入。
所述第一位姿也可以按照以下方式获取:
根据所述图像采集装置在所述第一时刻的运动状态,计算得到第一位姿。
上述方式中,同样可以依据预设位姿算法,且既可以直接将第一时刻的运动状态作为预设位姿算法的输入,也可以将第一时刻的运动状态进行预处理后,将预处理后的图像作为预设位姿算法的输入。
也可以按照如下步骤(以下称为综合确定第一位姿的步骤)确定所述第一位姿:
获取所述图像采集装置在所述第一时刻的运动状态;根据所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿。
举例来说,可以根据所述第一图像帧按照第一预设位姿算法,确定第一加权位姿;并根据所述第一时刻的运动状态,按照第二预设位姿算法,确定第二加权位姿;根据第一加权位姿和第二加权位姿进行加权平均,确定所述第一位姿。
也可以只用一种预设位姿算法,举例来说,根据所述第一时刻的运动状态,确定所述第一位姿中的位置信息,根据所述第一图像帧,确定所述第一位姿中的姿态信息。
由于仅根据第一图像帧或仅根据所述第一时刻的运动状态确定第一位姿,都可能会忽略局部的位姿计算因素,所以综合所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿,可以使得所述第一位姿充分考虑图像帧和运动状态的因素,使得所述第一位姿更加精确。
综合确定第一位姿的步骤中,根据所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿,具体可以如下:
对所述第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像;根据所述第一预处理图像和所述第一时刻的运动状态,确定所述第一位姿。
通过上述预处理过程,可以使得第一预处理图像既保留了第一图像帧中的关键特性,又可以有效降低数据量,直接用第一预处理图像参与运算,从而既保持了计算精度,又显著降低了运算量,从而可以提升确定所述第一位姿的效率。
步骤101~步骤104的方法可以应用于如图2所示的物理设备。该物理设备包括头戴装置1、传感器2、图像采集装置3和显示器4。头戴装置1用于对图像进行计算处理,具体可以通过在头戴装置1中设置处理器和存储器来实现。所述图像采集装置3设置在头戴装置1上,所述头戴装置1上还设置有传感器2和显示器4。需要说明的是,图2所示的物理设备仅作为示例展示步骤101~步骤104的方法可应用的物理设备,图2所示的物理设备 还可以根据实际需求做多种变形,举例来说,该物理设备还可以包括固定装置,防止用户佩戴头戴装置1时因为运动而脱落。
基于图2所示的架构,综合确定第一位姿的步骤中,具体可以按照以下方式获取所述图像采集装置3在所述第一时刻的运动状态:
获取所述传感器2在所述第一时刻采集到的运动状态;将所述传感器2在所述第一时刻采集到的运动状态,作为所述图像采集装置3在所述第一时刻的运动状态。
需要说明的是,上述传感器2的运动状态和图像采集装置3的运动状态可以设置同步运动,从而可以降低所述图像采集装置3在所述第一时刻的运动状态的偏差。
基于图2所示的物理设备,步骤104具体可以由显示器4执行,并将待显示图像显示在所述显示器4上。
基于图2所示的物理设备,图1示出的方法可以应用于图3所示的架构。图3示出的架构中,可以通过传感器2获取图像采集装置3在第一时刻的运动状态,并获取图像采集装置3在第一时刻的第一图像帧,输出到头戴装置1中,从而头戴装置1可以根据第一时刻的运动状态和第一图像帧得到第一位姿,进而基于第一位姿预测第二位姿,并进一步得到第二虚拟对象,当通过图像采集装置3获得了第二时刻的第二图像帧时,头戴装置1便可以将在第二时刻前预先生成的第二虚拟图像与第二图像帧叠加,得到待显示图像,并输出至显示器4进行显示。
需要说明的是,上述架构只是图1应用的一个示例,图3示出的架构还可以有多种变形,如传感器2还可以获取第一时刻之后至第二时刻之前的至少一个时刻的运动状态。
下面详细描述步骤101~步骤104的具体过程。
步骤101的一种可能情形可以如下:
根据所述第一位姿和所述第一时刻的运动状态,预测所述第二位姿。
具体来说,可以将第一时刻至第二时刻之间时间段内图像采集装置的运动状态近似为所述第一时刻的运动状态,以所述第一位姿为基准,根据所述第一时刻的运动状态,确定第一时刻至第二时刻之间时间段内的累积位姿,从而预测所述第二位姿;或者,根据所述第一时刻的运动状态预测第一时刻至第二时刻图像采集装置的运动状态,预测第一时刻至第二时刻图像采集装置的运动状态,以所述第一位姿为基准,根据预测的第一时刻至第二时刻之间图像采集装置的运动状态,确定第一时刻至第二时刻之间时间段内的累积位姿,从而预测所述第二位姿。
上述两种方式仅作为示例,根据所述第一位姿和所述第一时刻的运动状态,预测所述第二位姿的实施方式还可以有多种,在此不再赘述。
步骤101的一种可能情形(以下称为至少两个时刻的情形)还可以如下:
根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态,预测所述图像采集装置在所述第二时刻的位姿;根据所述图像采集装置在所述第二时刻的位姿,预测所述第二位姿。
其中,所述至少两个时刻包括:所述第一时刻、所述第一时刻之后至所述第二时刻之前的至少一个时刻。
上述情形下,在计算所述第二位姿的过程中,除了第一时刻的运动状态外,还考虑了所述第一时刻之后至所述第二时刻之前中间至少一个时刻的运动状态,从而及时捕捉到第 一时刻之后的运动状态变化,更准确地预测所述第二位姿。
上述至少两个时刻的情形中,更具体的情形可以如下:
根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态的平均运动状态,预测所述第一时刻至所述第二时刻的累积位姿,并根据所述第一时刻至所述第二时刻的累积位姿以及所述第一位姿,预测所述图像采集装置在所述第二时刻的位姿,并根据所述图像采集装置在所述第二时刻的位姿,预测所述第二位姿。
上述至少两个时刻的情形中,更具体的情形还可以如下(以下称为相邻子时段的情形):
所述第一时刻与所述第二时刻之间的时间段被划分为至少两个子时段,所述至少两个子时段中包括相邻的第一子时段和第二子时段,所述第一子时段位于所述第二子时段之前,所述第一子时段的截止时刻为第一子时刻,所述第二子时段的截止时刻为第二子时刻。
需要说明的是,相邻子时段的情形中以任意两个相邻的第一子时段和第二子时段为例说明,该情形具体的时间示意图可以如图4所示。另外,第一子时段的截止时刻与第二子时段的开始时刻的关系不做约束,图4中仅以第一子时段的截止时刻为第二子时段的开始时刻为例,第一子时段的截止时刻也可以第二子时段的开始时刻之前,使得第一子时段与第二子时段之间也有时段间隔。
相邻子时段的情形中,可以具体按照以下方式,根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态,预测所述图像采集装置在所述第二时刻的位姿:
根据所述图像采集装置在所述第一子时刻预测到的位姿和所述图像采集装置在所述第一子时刻的运动状态,确定所述图像采集装置自所述第一子时刻起至所述第二子时刻的第一累积位姿;
根据所述第一子时刻预测到的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿。
显然,通过上述方式,针对任意两个相邻的第一子时段和第二子时段,以所述第一子时刻预测到的位姿和所述第一子时刻的运动状态为基准,预测所述图像采集装置在所述第二子时刻的位姿,从而每次迭代都参照了最新的第一子时段的截止时刻的运动状态,直至预测到所述图像采集装置在所述第二时刻的位姿,所以通过多个子时段多次分段预测可以更准确地预测到所述图像采集装置在所述第二时刻的位姿。
可选的,所述根据所述第一子时刻的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿,具体可以满足以下公式:
Figure PCTCN2021094744-appb-000027
其中,
Figure PCTCN2021094744-appb-000028
为所述第二子时刻的位姿,
Figure PCTCN2021094744-appb-000029
为所述第一子时刻的位姿,
Figure PCTCN2021094744-appb-000030
为所述第一累积位姿,w 0和w 0表示加权系数,t 0表示第一子时刻,t 1表示第二子时刻;
Figure PCTCN2021094744-appb-000031
是所述第一子时刻的位姿的第一子位姿,所述第一子位姿是根据所述第一子时段的起始时刻的位姿和所述第一子时段的起始时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000032
是所述第一子时刻的位姿的第二子位姿,所述第二子位姿是根据所述第一子时段的起始时刻的运动状态得到的;
Figure PCTCN2021094744-appb-000033
是所述第一累积位姿的第一子累积位姿,所述第一子累积位姿是根据所述第 一子时刻的位姿和所述第一子时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000034
是所述第一累积位姿的第二子累积位姿,所述第二子累积位姿是根据所述第一子时刻的运动状态得到的。
上述公式中,第一子位姿、第一子累积位姿都是根据所述第一子时段的起始时刻的位姿得到的,而预测到的位姿都是根据第一时刻的第一图像帧得到的,所以第一子位姿、第一子累积位姿是考虑了第一图像帧计算得到的位姿,而第二子位姿、第二子累积位姿都是根据运动状态得到的,并未考虑第一图像帧,所以将考虑了第一图像帧的位姿和未考虑第一图像帧的位姿进行加权平均,可以更准确地预测所述第二子时刻的位姿。
需要说明的是,上述公式仅是预测所述第二子时刻的位姿一种计算方式,根据所述第一子时刻的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿,可根据需求灵活选择公式计算,举例来说,公式还可以如下:
Figure PCTCN2021094744-appb-000035
或者,也可以如下:
Figure PCTCN2021094744-appb-000036
在上述相邻子时段的情形中,更具体的情形(以下称为第三子时段的情形)可以如下:
所述至少两个子时段中包括第三子时段,所述第三子时段与所述第二子时段相邻,所述第三子时段是所述时间段内的最后一个子时段,所述第三子时段的截止时刻为第三子时刻。
需要说明的是,第三子时段的情形中,所述至少两个子时段包括至少三个子时段,该情形具体的时间示意图可以如图5所示。另外,第二子时段的截止时刻与第三子时段的开始时刻的关系不做约束,图5中仅以第二子时段的截止时刻为第三子时段的开始时刻为例,第二子时段的截止时刻也可以第三子时段的开始时刻之前,使得第二子时段与第三子时段之间有时段间隔。
可以执行以下步骤:
根据所述第二子时刻的位姿、所述第二子时刻的运动状态,确定所述图像采集装置自所述第二子时刻起至所述第三子时刻的第二累积位姿和所述第二子时刻的位姿的算法校正结果;
根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿。
上述方式下,对于第三子时段,由于第二子时刻之后至第三子时刻之前不会再获取图像采集装置的运动状态,可以先根据所述第二子时刻的位姿、所述第二子时刻的运动状态,对所述第二子时刻的位姿进行校正,并进一步预测所述图像采集装置在所述第三子时刻的位姿,从而可以对所述第三子时刻的位姿进行校正,获得更准确的所述第三子时刻的位姿。
可选的,所述根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿,满足以下公式:
Figure PCTCN2021094744-appb-000037
其中,
Figure PCTCN2021094744-appb-000038
为所述第三子时刻的位姿,
Figure PCTCN2021094744-appb-000039
为所述第二子时刻的位姿的算法校正结果,
Figure PCTCN2021094744-appb-000040
为所述第二累积位姿,
Figure PCTCN2021094744-appb-000041
为所述第二子时刻的位姿,w 2和w 3表示加权系数,t 1表示第二子时刻,t 2表示第三子时刻。
上述公式中,通过所述第二子时刻的位姿的算法校正结果和所述第二累积位姿,得到第二子时刻累积至第三子时刻的算法校正的结果,再将进行算法校正的结果和未进行算法校正的所述第二子时刻的位姿进行加权,可以更为准确地预测第三子时刻的位姿,从而可以更准确地预测第二时刻的位姿。
需要说明的是,上述公式仅是预测所述第三子时刻的位姿一种计算方式,根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿,可根据需求灵活选择公式计算,举例来说,公式还可以如下:
Figure PCTCN2021094744-appb-000042
步骤102具体可以按照如下方式执行:
根据第一图像帧和第二位姿,生成所述第二虚拟对象。
具体来说,第一时刻对应的位姿为第一位姿,且第一时刻采集的图像帧为第一图像帧,那么可以根据第一位姿至第二位姿的变化,将第一图像帧进行相应的图像扭曲,从而得到第二虚拟对象。
或者,可以根据第二位姿和预设虚拟空间模型,生成所述第二虚拟对象。
具体来说,预设虚拟空间模型是预先构建的虚拟空间,在预设虚拟空间模型处于某个位置并保持某个姿态(如获取某一位姿时),便可以根据该位姿和预设虚拟空间模型,确定该位姿相应的图像帧,并生成相应的虚拟对象。所以,当预测到第二位姿时,便可以根据第二位姿和预设虚拟空间模型,生成所述第二虚拟对象。
需要说明的是,步骤101~步骤104所述的方法具体可以通过以下多线程方式实现:
步骤101、步骤102可以均通过第一从线程执行,也可以由第一从线程和主线程一起联合执行,如可由第一从线程执行步骤101,再由主线程执行步骤102;步骤103、步骤104可以均通过主线程执行,也可以由主线程和显示线程联合执行,如主线程执行步骤103后,由显示线程执行步骤104,具体的线程执行方式可根据实际需求灵活选取,在此不做限定。
在步骤101之前,还可以通过主线程按照以下方式获取第一图像帧和第一位姿:
通过执行所述主线程,获取第一图像帧,对所述第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
在主线程获得第一预处理图像之后,便可根据第一预处理图像和第一时刻的运动状态,确定第一位姿。确定第一位姿的步骤既可以由主线程执行,也可以由第一从线程执行,若第一从线程执行该步骤,那么主线程便可以专用于获取图像帧,或者对获取的图像帧进行预处理,或者得到待显示图像,从而能够降低主线程得到待显示图像的时延,中间对第二位姿进行预测的过程可以交由第一从线程专门执行,从而保证了整个流程的流畅执行。
在步骤103之后,还可以通过执行第二从线程,根据所述图像采集装置在所述第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿。
所述第三图像帧为所述图像采集装置在第三时刻采集的图像帧;所述第二时刻位于所述第三时刻之前,所述第二图像帧和所述第三图像帧为所述图像采集装置采集的两个相邻图像帧;其中,所述第一从线程和所述第二从线程并行执行。
显然,第二从线程和第一从线程的执行动作可以是相同的,只是执行的对象和预测的位姿不同。即第一从线程的执行对象是第一时刻的位姿,预测的是第二位姿,而第二从线程的执行对象是第二时刻的位姿,预测的是第三位姿,具体第二从线程如何根据第二时刻的位姿预测第三位姿,可以参照上述第一从线程预测第二位姿的描述,其过程类似,在此不再赘述。
通过上述多线程方式,每两个相邻图像帧之间的时间段都会进行位姿预测,通过第一时刻的第一位姿,预测第二时刻的第二位姿,且根据所述图像采集装置在所述第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,从而依次根据前一图像帧对应图像采集装置的位姿,预测下一图像帧对应的虚拟对象位姿,且一个从线程与一个图像帧对应,从而各图像帧对应的从线程执行互不干扰,即便某个从线程执行出现错误,也不会影响其他从线程对位姿的预测。
上述多线程方式中,主线程可以一直运行,而从线程既可以一直运行,具体如下:
K个从线程一直运行,K为大于2的正整数,每个图像帧获取到后,都可以通过相应的从线程进行处理。举例来说,可以按照图像帧获取的先后顺序,依次交由相应的从线程,如共有3个从线程,第一从线程、第二从线程和第三从线程,第一从线程用于处理第一图像帧、第四图像帧、第七图像帧,其它从线程可以以此类推。
也可以根据具体情形开启或销毁,具体如下:
获取到所述第一图像帧后,创建所述第一从线程;
当预测得到所述第二虚拟对象的所述第二位姿后,所述第一从线程被销毁。
需要说明的是,第一从线程既可以自行销毁,也可以由主线程销毁。
显然,通过上述方式,只在需要预测第二位姿时创建第一从线程用于预测第二位姿即可,当第一从线程预测到第二位姿后,第一从线程即被销毁,从而可以及时回收资源。
另外,第一从线程将预测到的第二位姿传输给所述主线程可以有多种方式,比如第一从线程直接将第二位姿作为所述主线程的输入,也可以按照以下方式传输:
通过执行所述第一从线程,将所述第二虚拟对象存入共享缓存;为所述共享缓存中所述第二虚拟对象设置互斥锁。所述互斥锁用于禁止所述主线程读取所述第二虚拟对象。
当所述第二虚拟对象为所述共享缓存中时刻最早的位姿时,将所述共享缓存中为所述第二虚拟对象设置的互斥锁解除;使用所述主线程,从所述共享缓存中读取所述第二虚拟对象。
通过上述方式,将所述第二虚拟对象存入共享缓存后,为所述共享缓存中所述第二虚拟对象设置互斥锁,当所述第二虚拟对象为所述共享缓存中时刻最早的位姿时,说明所述第二虚拟对象之前的虚拟对象都已经被主线程读取,那么所述第二虚拟对象已经是所述共享缓存中最先存入的虚拟对象,可以使得先存入共享缓存的虚拟对象先被主线程读取,从而通过互斥锁,使得虚拟对象能够按照顺序准确地被读取,增加了待显示图像的准确性。
基于上述多线程方式的描述,多线程方式的具体过程可以参照图6。
线程0(主线程)获取图像采集装置采集的第X图像帧,X为正整数。图6示出的具过程中X表示图像采集装置所采集图像帧的序号,举例来说,第X图像帧可以为第一图像帧,可以为第二图像帧,…,也可以为第N图像帧等,N为大于2的正整数;第X时刻可以为第一时刻,可以为第二时刻,…,也可以为第N时刻等。图6以第X时刻至第X+1 时刻的过程为例说明多线程方式的具体过程。
线程0(主线程)获取图像采集装置采集的第X图像帧时,线程X可以开始创建。第X从线程可以为第一从线程、第二从线程…第N从线程等。
线程0可以将第X图像帧存入数据缓存,也可以对第X图像帧进行预处理,获得第X预处理图像,并将第X预处理图像存入数据缓存(图6中以对第X图像帧进行预处理为例说明);线程X(第X从线程)也可以在获得第X预处理图像时创建。
在第X时刻至第X+1时刻的时间段,线程X创建后,便可以根据第X预处理图像(也可以直接根据第X图像帧)和第X时刻的运动状态,预测第X+1位姿,并根据第X+1位姿生成第X+1虚拟对象;举例来说,线程1(如第一从线程)创建后,根据第一预处理图像和第一时刻的运动状态,预测第二位姿,并根据第二位姿生成第二虚拟对象。
将第X+1虚拟对象存入共享缓存后,可以为第X+1虚拟对象加上互斥锁,当主线程(线程0)需要获取第X+1虚拟对象时(即第X+1虚拟对象为共享缓存中最早的虚拟对象时),为第X+1虚拟对象解锁。
在获取到第X+1图像帧后,将第X+1图像帧和第X+1虚拟对象叠加,便获得了第X+1时刻的待显示图像;在获取到第X+1图像帧之前,获取到第X图像帧之后,已将第X图像帧和第X虚拟对象叠加,获得了第X时刻的待显示图像。所以,通过上述多线程方式,可以使得每获得一个图像帧都可以预测下一相邻图像帧的位姿,生成下一相邻图像帧对应的虚拟对象,并在获取下一相邻图像帧时,叠加得到待显示图像,由于各个图像帧都有对应的从线程各自负责,且还可以设置互斥锁,各个图像帧的处理都不受影响。
如图7所示,本申请提供一种图像处理装置,包括:
预测模块701,用于根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿;该第二图像帧为该图像采集装置在第二时刻采集的图像帧;该第一时刻位于该第二时刻之前,且该第一时刻为该图像采集装置采集第一图像帧的时刻,该第一图像帧和该第二图像帧为该图像采集装置采集的两个相邻图像帧;
处理模块702,用于根据该第二位姿生成该第二虚拟对象;处理模块702,还用于获取该第二图像帧;处理模块702,还用于将该第二虚拟对象和该第二图像帧叠加,得到该第二时刻对应的待显示图像。
需要说明的是,第二图像帧是图像采集装置采集的,处理模块702可以从图像采集装置处获取第二图像帧,也可以图像采集装置将采集到的第二图像帧存入数据缓存中后,处理模块702从数据缓存中获取第二图像帧。
可选的,根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,该预测模块701还用于:
获取该图像采集装置在该第一时刻的运动状态;根据该第一图像帧和该第一时刻的运动状态,确定该第一位姿。
可选的,该预测模块701具体用于:
对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像;根据该第一预处理图像和该第一时刻的运动状态,确定该第一位姿。
可选的,该图像采集装置设置在头戴装置上,该头戴装置上还设置有传感器和显示器; 该预测模块701具体用于:获取该传感器在该第一时刻采集到的运动状态;将该传感器在该第一时刻采集到的运动状态,作为该图像采集装置在该第一时刻的运动状态;该处理模块702还用于:将该待显示图像显示在该显示器上。
可选的,该预测模块701具体用于:
根据该第一位姿和该图像采集装置在至少两个时刻的运动状态,预测该图像采集装置在该第二时刻的位姿;该至少两个时刻包括:该第一时刻、该第一时刻之后至该第二时刻之前的至少一个时刻;根据该图像采集装置在该第二时刻的位姿,预测该第二位姿。
可选的,该第一时刻与该第二时刻之间的时间段被划分为至少两个子时段,该至少两个子时段中包括相邻的第一子时段和第二子时段,该第一子时段位于该第二子时段之前,该第一子时段的截止时刻为第一子时刻,该第二子时段的截止时刻为第二子时刻;该预测模块701具体用于:
根据该图像采集装置在该第一子时刻预测到的位姿和该图像采集装置在该第一子时刻的运动状态,确定该图像采集装置自该第一子时刻起至该第二子时刻的第一累积位姿;根据该第一子时刻预测到的位姿以及该第一累积位姿,预测该图像采集装置在该第二子时刻的位姿。
可选的,根据所述第一子时刻的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿,具体可以满足以下公式:
Figure PCTCN2021094744-appb-000043
其中,
Figure PCTCN2021094744-appb-000044
为该第二子时刻的位姿,
Figure PCTCN2021094744-appb-000045
为该第一子时刻的位姿,
Figure PCTCN2021094744-appb-000046
为该第一累积位姿,w 0和w 0表示加权系数,t 0表示第一子时刻,t 1表示第二子时刻;
Figure PCTCN2021094744-appb-000047
是该第一子时刻的位姿的第一子位姿,该第一子位姿是根据该第一子时段的起始时刻的位姿和该第一子时段的起始时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000048
是该第一子时刻的位姿的第二子位姿,该第二子位姿是根据该第一子时段的起始时刻的运动状态得到的;
Figure PCTCN2021094744-appb-000049
是该第一累积位姿的第一子累积位姿,该第一子累积位姿是根据该第一子时刻的位姿和该第一子时刻的运动状态得到的,
Figure PCTCN2021094744-appb-000050
是该第一累积位姿的第二子累积位姿,该第二子累积位姿是根据该第一子时刻的运动状态得到的。
可选的,该至少两个子时段中包括第三子时段,该第三子时段与该第二子时段相邻,该第三子时段是该时间段内的最后一个子时段,该第三子时段的截止时刻为第三子时刻;该预测模块701还用于:
根据该第二子时刻的位姿、该第二子时刻的运动状态,确定该图像采集装置自该第二子时刻起至该第三子时刻的第二累积位姿和该第二子时刻的位姿的算法校正结果;根据该第二累积位姿、该第二子时刻的位姿以及该第二子时刻的位姿的算法校正结果,预测该图像采集装置在该第三子时刻的位姿。
可选的,根据该第二累积位姿、该第二子时刻的位姿以及该第二子时刻的位姿的算法校正结果,预测该图像采集装置在该第三子时刻的位姿,满足以下公式:
Figure PCTCN2021094744-appb-000051
其中,
Figure PCTCN2021094744-appb-000052
为该第三子时刻的位姿,
Figure PCTCN2021094744-appb-000053
为该第二子时刻的位姿的算法校正结果,
Figure PCTCN2021094744-appb-000054
为该第二累积位姿,
Figure PCTCN2021094744-appb-000055
为该第二子时刻的位姿,w 2和w 3表示加权系数,t 1表示第二子时刻,t 2表示第三子时刻。
可选的,该处理模块702具体用于:
根据第一图像帧和第二位姿,生成该第二虚拟对象。
可选的,该处理模块702具体用于:
根据第二位姿和预设虚拟空间模型,生成该第二虚拟对象。
可选的,得到该第二时刻对应的待显示图像是通过主线程执行的;预测第二图像帧对应的第二虚拟对象的第二位姿是通过第一从线程执行的;该处理模块702还用于:
通过执行第二从线程,根据该图像采集装置在该第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,该第三图像帧为该图像采集装置在第三时刻采集的图像帧;该第二时刻位于该第三时刻之前,该第二图像帧和该第三图像帧为该图像采集装置采集的两个相邻图像帧;其中,该第一从线程和该第二从线程并行执行。
可选的,该处理模块702还用于:
通过执行该主线程,对该第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
可选的,该处理模块702还用于:
获取到该第一图像帧后,创建该第一从线程;当预测得到该第二虚拟对象的该第二位姿后,该第一从线程被销毁。
可选的,该处理模块702还用于:
通过执行该第一从线程,将该第二虚拟对象存入共享缓存;为该共享缓存中该第二虚拟对象设置互斥锁;该互斥锁用于禁止该主线程读取该第二虚拟对象;当该第二虚拟对象为该共享缓存中时刻最早的位姿时,将该共享缓存中为该第二虚拟对象设置的互斥锁解除;使用该主线程,从该共享缓存中读取该第二虚拟对象。
本申请实施例还提供另一种图像处理装置,该装置包括:一个或多个处理器以及传输接口;其中,该一个或多个处理器被配置为调用存储在存储器中的计算机指令,使得该装置执行图1所示的方法中的步骤及可选步骤。
如图8所示,图8是本申请实施例提供的另一种电子设备的结构示意图。该电子设备可以是图像处理装置,该电子设备800包括:至少一个中央处理器(Central Processing Unit,CPU),存储器,存储器的类型例如可以包括静态随机存取存储器(Static Random-Access Memory,SRAM)和只读存储器(Read-Only Memory,ROM),微控制器(Micro controller Unit,MCU)、无线局域网(Wireless Local Area Network,WLAN)子系统、总线、传输接口等。虽然图8中未示出,该电子设备800还可以包括应用处理器(Application Processor,AP),NPU等其他专用处理器,以及电源管理子系统、时钟管理子系统和功耗管理子系统等其他子系统。
电子设备800的上述各个部分通过连接器相耦合,示例性的,连接器包括各类接口、传输线或总线等,这些接口通常是电性通信接口,但是也可能是机械接口或其它形式的接口,本实施例对此不做限定。
可选的,CPU可以是一个单核(single-CPU)处理器或多核(multi-CPU)处理器;可选的,CPU可以是多个处理器构成的处理器组,多个处理器之间通过一个或多个总线彼此耦合。在一种可选的情况中,CPU通过调用片上述存储器或者片外存储器中存储的程序指令实现如前述方法实施例中的任一种图像处理方法。在一种可选的情况中,CPU和MCU 共同实现如前述方法实施例中的任一种图像处理方法,例如CPU完成图像处理方法中的部分步骤,而MCU完成图像处理方法中的其他步骤。在一种可选的情况中,AP或者其他专用处理器通过调用片上述存储器或者片外存储器中存储的程序指令实现如前述方法实施例中的任一种图像处理方法。
该传输接口可以为处理器芯片的接收和发送数据的接口,该传输接口通常包括多种接口,在一种可选的情况下,该传输接口可以包括内部整合电路(Inter-Integrated Circuit,I2C)接口、串行外设接口(Serial Peripheral Interface,SPI)、通用异步收发机(Universal asynchronous receiver-transmitter,UART)接口、通用输入输出(General-purpose input/output,GPIO)接口等。应当理解,这些接口可以是通过复用相同的物理接口来实现不同的功能。
在一种可选的情况中,传输接口还可以包括高清晰度多媒体接口(High Definition Multimedia Interface,HDMI)、V-By-One接口、嵌入式显示端口(Embedded Display Port,eDP)、移动产业处理器接口(Mobile Industry Processor Interface,MIPI)或Display Port(DP)等。
在一种可选的情况中,上述各部分集成在同一个芯片上;在另一种可选的情况中,存储器可以是独立存在的芯片。
WLAN子系统例如可以包括射频电路和基带。
在本申请实施例中涉及的芯片是以集成电路工艺制造在同一个半导体衬底上的系统,也叫半导体芯片,其可以是利用集成电路工艺制作在衬底(通常是例如硅一类的半导体材料)上形成的集成电路的集合,其外层通常被半导体封装材料封装。所述集成电路可以包括各类功能器件,每一类功能器件包括逻辑门电路、金属氧化物半导体(Metal-Oxide-Semiconductor,MOS)晶体管、双极晶体管或二极管等晶体管,也可包括电容、电阻或电感等其他部件。每个功能器件可以独立工作或者在必要的驱动软件的作用下工作,可以实现通信、运算、或存储等各类功能。
本申请实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机指令,这些计算机指令被计算机调用执行时,可以使得计算机完成上述方法实施例、方法实施例的任意一种可能的设计中所涉及的方法。本申请实施例中,对计算机可读存储介质不做限定,例如,可以是RAM(random-access memory,随机存取存储器)、ROM(read-only memory,只读存储器)等。
本申请实施例还提供一种计算机程序产品,该计算机程序产品包括计算机指令,当该计算机指令在计算机或处理器上执行时,使得该计算机或该处理器执行上述方法实施例、方法实施例的任意一种可能的设计中所涉及的方法。
本申请实施例还提供一种芯片,该芯片可以包括处理器以及接口电路,用于完成上述方法实施例、方法实施例的任意一种可能的实现方式中所涉及的方法,其中,“耦合”是指两个部件彼此直接或间接地结合,这种结合可以是固定的或可移动性的。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机指令的形式实现。在计算机上加载和执行所述计算机指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存 储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(Solid State Disk,SSD))等。
本申请实施例中所描述的方法或算法的步骤可以直接嵌入硬件、处理器执行的软件单元、或者这两者的结合。软件单元可以存储于RAM存储器、闪存、ROM存储器、EPROM存储器、EEPROM存储器、寄存器、硬盘、可移动磁盘、CD-ROM或本领域中其它任意形式的存储媒介中。示例性地,存储媒介可以与处理器连接,以使得处理器可以从存储媒介中读取信息,并可以向存储媒介存写信息。可选地,存储媒介还可以集成到处理器中。处理器和存储媒介可以设置于ASIC中,ASIC可以设置于终端设备中。可选地,处理器和存储媒介也可以设置于终端设备中的不同的部件中。
这些计算机指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管结合具体特征及其实施例对本发明进行了描述,显而易见的,在不脱离本发明的范围的情况下,可对其进行各种修改和组合。相应地,本说明书和附图仅仅是所附权利要求所界定的本发明的示例性说明,且视为已覆盖本发明范围内的任意和所有修改、变化、组合或等同物。显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (23)

  1. 一种图像处理方法,其特征在于,包括:
    根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿;所述第二图像帧为所述图像采集装置在第二时刻采集的图像帧;所述第一时刻位于所述第二时刻之前,且所述第一时刻为所述图像采集装置采集第一图像帧的时刻,所述第一图像帧和所述第二图像帧为所述图像采集装置采集的两个相邻图像帧;
    根据所述第二位姿生成所述第二虚拟对象;
    获取所述第二图像帧;
    将所述第二虚拟对象和所述第二图像帧叠加,得到所述第二时刻对应的待显示图像。
  2. 如权利要求1所述的方法,其特征在于,所述根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿,包括:
    根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态,预测所述图像采集装置在所述第二时刻的位姿;所述至少两个时刻包括:所述第一时刻、所述第一时刻之后至所述第二时刻之前的至少一个时刻;
    根据所述图像采集装置在所述第二时刻的位姿,预测所述第二位姿。
  3. 如权利要求2所述的方法,其特征在于,所述第一时刻与所述第二时刻之间的时间段被划分为至少两个子时段,所述至少两个子时段中包括相邻的第一子时段和第二子时段,所述第一子时段位于所述第二子时段之前,所述第一子时段的截止时刻为第一子时刻,所述第二子时段的截止时刻为第二子时刻;
    所述根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态,预测所述图像采集装置在所述第二时刻的位姿,包括:
    根据所述图像采集装置在所述第一子时刻预测到的位姿和所述图像采集装置在所述第一子时刻的运动状态,确定所述图像采集装置自所述第一子时刻起至所述第二子时刻的第一累积位姿;
    根据所述第一子时刻预测到的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿。
  4. 如权利要求3所述的方法,其特征在于,所述至少两个子时段中包括第三子时段,所述第三子时段与所述第二子时段相邻,所述第三子时段是所述时间段内的最后一个子时段,所述第三子时段的截止时刻为第三子时刻;
    所述方法还包括:
    根据所述第二子时刻的位姿、所述第二子时刻的运动状态,确定所述图像采集装置自所述第二子时刻起至所述第三子时刻的第二累积位姿和所述第二子时刻的位姿的算法校正结果;
    根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿。
  5. 如权利要求1-4任一项所述的方法,其特征在于:
    所述得到所述第二时刻对应的待显示图像是通过主线程执行的;
    所述预测第二图像帧对应的第二虚拟对象的第二位姿是通过第一从线程执行的;
    所述获取所述第二图像帧之后,还包括:
    通过执行第二从线程,根据所述图像采集装置在所述第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,所述第三图像帧为所述图像采集装置在第三时刻采集的图像帧;所述第二时刻位于所述第三时刻之前,所述第二图像帧和所述第三图像帧为所述图像采集装置采集的两个相邻图像帧;
    其中,所述第一从线程和所述第二从线程并行执行。
  6. 如权利要求5所述的方法,其特征在于,所述根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,还包括:
    通过执行所述主线程,对所述第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
  7. 如权利要求5或6所述的方法,其特征在于,所述方法还包括:
    获取到所述第一图像帧后,创建所述第一从线程;
    当预测得到所述第二虚拟对象的所述第二位姿后,所述第一从线程被销毁。
  8. 如权利要求5-7任一项所述的方法,其特征在于,还包括:
    通过执行所述第一从线程,将所述第二虚拟对象存入共享缓存;
    为所述共享缓存中所述第二虚拟对象设置互斥锁;所述互斥锁用于禁止所述主线程读取所述第二虚拟对象;
    当所述第二虚拟对象为所述共享缓存中时刻最早的位姿时,将所述共享缓存中为所述第二虚拟对象设置的互斥锁解除;
    使用所述主线程,从所述共享缓存中读取所述第二虚拟对象。
  9. 如权利要求1-8任一项所述的方法,其特征在于,所述根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿之前,还包括:
    获取所述图像采集装置在所述第一时刻的运动状态;
    根据所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿。
  10. 如权利要求9所述的方法,其特征在于,所述图像采集装置设置在头戴装置上,所述头戴装置上还设置有传感器和显示器;所述获取所述图像采集装置在所述第一时刻的运动状态,包括:
    获取所述传感器在所述第一时刻采集到的运动状态;
    将所述传感器在所述第一时刻采集到的运动状态,作为所述图像采集装置在所述第一时刻的运动状态;
    所述方法还包括:
    将所述待显示图像显示在所述显示器上。
  11. 一种图像处理装置,其特征在于,包括:
    预测模块,用于根据图像采集装置在第一时刻的第一位姿,预测第二图像帧对应的第二虚拟对象的第二位姿;所述第二图像帧为所述图像采集装置在第二时刻采集的图像帧;所述第一时刻位于所述第二时刻之前,且所述第一时刻为所述图像采集装置采集第一图像帧的时刻,所述第一图像帧和所述第二图像帧为所述图像采集装置采集的两个相邻图像帧;
    处理模块,用于根据所述第二位姿生成所述第二虚拟对象;
    所述处理模块,还用于获取所述第二图像帧;
    所述处理模块,还用于将所述第二虚拟对象和所述第二图像帧叠加,得到所述第二时刻对应的待显示图像。
  12. 如权利要求11所述的装置,其特征在于,所述预测模块具体用于:
    根据所述第一位姿和所述图像采集装置在至少两个时刻的运动状态,预测所述图像采集装置在所述第二时刻的位姿;所述至少两个时刻包括:所述第一时刻、所述第一时刻之后至所述第二时刻之前的至少一个时刻;
    根据所述图像采集装置在所述第二时刻的位姿,预测所述第二位姿。
  13. 如权利要求12所述的装置,其特征在于,所述第一时刻与所述第二时刻之间的时间段被划分为至少两个子时段,所述至少两个子时段中包括相邻的第一子时段和第二子时段,所述第一子时段位于所述第二子时段之前,所述第一子时段的截止时刻为第一子时刻,所述第二子时段的截止时刻为第二子时刻;
    所述预测模块具体用于:
    根据所述图像采集装置在所述第一子时刻预测到的位姿和所述图像采集装置在所述第一子时刻的运动状态,确定所述图像采集装置自所述第一子时刻起至所述第二子时刻的第一累积位姿;
    根据所述第一子时刻预测到的位姿以及所述第一累积位姿,预测所述图像采集装置在所述第二子时刻的位姿。
  14. 如权利要求13所述的装置,其特征在于,所述至少两个子时段中包括第三子时段,所述第三子时段与所述第二子时段相邻,所述第三子时段是所述时间段内的最后一个子时段,所述第三子时段的截止时刻为第三子时刻;
    所述预测模块还用于:
    根据所述第二子时刻的位姿、所述第二子时刻的运动状态,确定所述图像采集装置自所述第二子时刻起至所述第三子时刻的第二累积位姿和所述第二子时刻的位姿的算法校正结果;
    根据所述第二累积位姿、所述第二子时刻的位姿以及所述第二子时刻的位姿的算法校正结果,预测所述图像采集装置在所述第三子时刻的位姿。
  15. 如权利要求11-14任一项所述的装置,其特征在于:
    所述得到所述第二时刻对应的待显示图像是通过主线程执行的;
    所述预测第二图像帧对应的第二虚拟对象的第二位姿是通过第一从线程执行的;
    所述处理模块还用于:
    通过执行第二从线程,根据所述图像采集装置在所述第二时刻的位姿,预测第三图像帧对应的第三虚拟对象的第三位姿,所述第三图像帧为所述图像采集装置在第三时刻采集的图像帧;所述第二时刻位于所述第三时刻之前,所述第二图像帧和所述第三图像帧为所述图像采集装置采集的两个相邻图像帧;
    其中,所述第一从线程和所述第二从线程并行执行。
  16. 如权利要求15所述的装置,其特征在于,所述处理模块还用于:
    通过执行所述主线程,对所述第一图像帧进行畸变校正,提取畸变校正后的单通道图像,并对畸变校正后的单通道图像进行下采样,获得第一预处理图像。
  17. 如权利要求15或16所述的装置,其特征在于,所述处理模块还用于:
    获取到所述第一图像帧后,创建所述第一从线程;
    当预测得到所述第二虚拟对象的所述第二位姿后,所述第一从线程被销毁。
  18. 如权利要求15-17任一项所述的装置,其特征在于,所述处理模块还用于:
    通过执行所述第一从线程,将所述第二虚拟对象存入共享缓存;
    为所述共享缓存中所述第二虚拟对象设置互斥锁;所述互斥锁用于禁止所述主线程读取所述第二虚拟对象;
    当所述第二虚拟对象为所述共享缓存中时刻最早的位姿时,将所述共享缓存中为所述第二虚拟对象设置的互斥锁解除;
    使用所述主线程,从所述共享缓存中读取所述第二虚拟对象。
  19. 如权利要求11-18任一项所述的装置,其特征在于,所述预测模块还用于:
    获取所述图像采集装置在所述第一时刻的运动状态;
    根据所述第一图像帧和所述第一时刻的运动状态,确定所述第一位姿。
  20. 如权利要求19所述的装置,其特征在于,所述图像采集装置设置在头戴装置上,所述头戴装置上还设置有传感器和显示器;所述预测模块具体用于:
    获取所述传感器在所述第一时刻采集到的运动状态;
    将所述传感器在所述第一时刻采集到的运动状态,作为所述图像采集装置在所述第一时刻的运动状态;
    所述处理模块还用于:
    将所述待显示图像显示在所述显示器上。
  21. 一种图像处理装置,其特征在于,所述装置包括:一个或多个处理器以及传输接口;其中,所述一个或多个处理器被配置为调用存储在存储器中的计算机指令,使得所述装置执行如权利要求1-10任一项所述的方法。
  22. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括计算机指令,当所述计算机指令在计算机上运行时,使得所述计算机执行如权利要求1-10任一项所述的方法。
  23. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机指令,当所述计算机指令在计算机或处理器上执行时,使得所述计算机或所述处理器执行如权利要求1-10中任一项所述的方法。
PCT/CN2021/094744 2021-05-20 2021-05-20 一种图像处理方法及装置 WO2022241701A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202180098163.6A CN117296082A (zh) 2021-05-20 2021-05-20 一种图像处理方法及装置
PCT/CN2021/094744 WO2022241701A1 (zh) 2021-05-20 2021-05-20 一种图像处理方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/094744 WO2022241701A1 (zh) 2021-05-20 2021-05-20 一种图像处理方法及装置

Publications (1)

Publication Number Publication Date
WO2022241701A1 true WO2022241701A1 (zh) 2022-11-24

Family

ID=84140137

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/094744 WO2022241701A1 (zh) 2021-05-20 2021-05-20 一种图像处理方法及装置

Country Status (2)

Country Link
CN (1) CN117296082A (zh)
WO (1) WO2022241701A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108027652A (zh) * 2015-09-16 2018-05-11 索尼公司 信息处理设备、信息处理方法以及程序
CN108273265A (zh) * 2017-01-25 2018-07-13 网易(杭州)网络有限公司 虚拟对象的显示方法及装置
CN110244840A (zh) * 2019-05-24 2019-09-17 华为技术有限公司 图像处理方法、相关设备及计算机存储介质
CN110633009A (zh) * 2018-06-22 2019-12-31 索尼互动娱乐股份有限公司 用于显示虚拟对象的方法和系统
CN112752119A (zh) * 2019-10-31 2021-05-04 中兴通讯股份有限公司 一种时延误差校正方法、终端设备、服务器及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108027652A (zh) * 2015-09-16 2018-05-11 索尼公司 信息处理设备、信息处理方法以及程序
CN108273265A (zh) * 2017-01-25 2018-07-13 网易(杭州)网络有限公司 虚拟对象的显示方法及装置
CN110633009A (zh) * 2018-06-22 2019-12-31 索尼互动娱乐股份有限公司 用于显示虚拟对象的方法和系统
CN110244840A (zh) * 2019-05-24 2019-09-17 华为技术有限公司 图像处理方法、相关设备及计算机存储介质
CN112752119A (zh) * 2019-10-31 2021-05-04 中兴通讯股份有限公司 一种时延误差校正方法、终端设备、服务器及存储介质

Also Published As

Publication number Publication date
CN117296082A (zh) 2023-12-26

Similar Documents

Publication Publication Date Title
KR102352102B1 (ko) 인터리빙된 채널 데이터를 위한 구성가능한 컨볼루션 엔진
WO2019184657A1 (zh) 图像识别方法、装置、电子设备及存储介质
US10282805B2 (en) Image signal processor and devices including the same
US20190220652A1 (en) Face anti-spoofing using spatial and temporal convolutional neural network analysis
TW202112138A (zh) 用於處理輸入視訊的方法以及系統
JP2022136092A (ja) ニューラルネットワークプロセッサにおいてタスクを割り当てるためのシステム及び方法
EP2165311A1 (en) Information processing method and apparatus, program, and storage medium
WO2021027585A1 (zh) 人脸图像处理方法及电子设备
TWI441091B (zh) 借助圖形處理單元執行影像信號處理的方法以及用於執行影像信號處理的裝置
CN111273772B (zh) 基于slam测绘方法的增强现实交互方法、装置
US9460489B2 (en) Image processing apparatus and image processing method for performing pixel alignment
WO2022241701A1 (zh) 一种图像处理方法及装置
CN110401800B (zh) 图像处理方法、图像处理器、拍摄装置和电子设备
WO2023143240A1 (zh) 图像处理方法、装置、设备、存储介质和程序产品
US20220417382A1 (en) Buffer management for plug-in architectures in computation graph structures
US11842436B2 (en) Snapshot arbitration techniques for memory requests
CN110856014A (zh) 动态图像生成方法、装置、电子设备及存储介质
JP2007102478A (ja) 画像処理装置、画像処理方法、及び半導体集積回路
WO2021237736A1 (zh) 图像处理方法、装置和系统,计算机可读存储介质
US11270412B2 (en) Image signal processor, method, and system for environmental mapping
CN116762084A (zh) 用于神经处理器电路的分支操作
US11080864B2 (en) Feature detection, sorting, and tracking in images using a circular buffer
US11341373B1 (en) End-to-end training of a machine learning node that interfaces with a fixed function node
US11321798B2 (en) Dynamic allocation of system on chip resources for efficient signal processing
US20230067442A1 (en) Method of human pose estimation

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21940157

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 202180098163.6

Country of ref document: CN

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21940157

Country of ref document: EP

Kind code of ref document: A1