Video recording method and device
By pausing recording when abnormal motion is detected and restarting recording using historical image frames, the problem of unexpected images caused by abnormal motion in the video is solved, achieving smooth transition of the video and improving the filming rate.
Patent Information
- Application Number
- CN202210274829.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-03-18
AI Technical Summary
During the video shooting process, unexpected and abnormal movements of the shooting equipment caused the camera to record unexpected images, resulting in a low video production rate and the inability to smoothly transition the video clips after post-editing, resulting in a severe sense of fragmentation.
When the abnormal motion state of the electronic device is detected, the video recording is paused, and the image frame to be spliced is determined from the historical image frames collected before the abnormal motion. When the similarity between the image frame to be spliced and the target image frame is greater than or equal to the preset similarity Start recording video again.
It ensures that the final video does not contain images in abnormal motion, achieves smooth transition of video clips, and improves the video production rate.
Smart Images

Figure CN114727147B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a video recording method, device, electronic device and readable storage medium. Background Art
[0002] With the development of technology, more and more users begin to use camera equipment to shoot various videos, such as short videos, video blogs (Vlogs), etc. In the process of users using camera equipment to shoot videos, the camera equipment often experiences unexpected abnormal movements, such as falling, collision, etc.
[0003] In the related art, when a user is shooting a video with a camera mounted on a shooting device, if the shooting device moves abnormally, the camera will record video images that the user does not expect, such as images captured by the camera during a fall, abnormal images caused by the camera movement exceeding the processing capacity of the anti-shake algorithm, etc. As a result, unexpected images will appear in the video shot by the user. Even if the user cuts out the unexpected images in the video through post-editing, the video clips before and after the cut cannot transition smoothly, resulting in a serious sense of fragmentation in the video.
[0004] It can be seen that during the video shooting process, if the shooting equipment undergoes unexpected abnormal movement, it is very easy to cause the video shot to become waste. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a video recording method, device, electronic device and readable storage medium, which can solve the problem of low video success rate when the shooting device undergoes unexpected abnormal movement when the user is shooting a video.
[0006] In a first aspect, an embodiment of the present application provides a video recording method, the method comprising:
[0007] During the process of recording the target video according to the target image frame, if it is determined that the electronic device is in an abnormal motion state, pausing the recording of the target video;
[0008] Determining the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state;
[0009] When the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity, the target video is recorded starting from the image frame to be spliced.
[0010] In a second aspect, an embodiment of the present application provides a video recording device, the device comprising:
[0011] A pause module, used for pausing the recording of the target video if it is determined that the electronic device is in an abnormal motion state during the process of recording the target video according to the target image frame;
[0012] A determination module, used to determine the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state;
[0013] The recording module is used to record the target video starting from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0017] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0018] In an embodiment of the present application, it includes, in the process of recording the target video according to the target image frame, if it is determined that the electronic device is in an abnormal motion state, then pausing the recording of the target video; determining the image frame to be spliced from the historical image frames collected before the electronic device was in the abnormal motion state; and starting to record the target video from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to the preset similarity. The present application can suspend the recording of the target video when the motion state of the electronic device is detected to be abnormal, and continue to record the target video when the target image frame collected by the camera matches the image frame to be spliced collected before the recording is suspended, so that the target video finally shot will not contain the picture collected by the electronic device in the abnormal motion state, so that the transition of the pictures shot before and after the pause is smooth, and the success rate of shooting the target video by the electronic device is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1It is a flow chart of video recording steps provided in an embodiment of the present application;
[0020] Figure 2 is a schematic diagram of an abnormal motion state of an electronic device provided in an embodiment of the present application;
[0021] Figure 3 is another video recording step flow chart provided in an embodiment of the present application;
[0022] Figure 4 This is a schematic diagram of a framing screen display provided by the present application;
[0023] Figure 5 is a block diagram of a video recording device provided in an embodiment of the present application;
[0024] Figure 6 An electronic device provided by an embodiment of the present application;
[0025] Figure 7 It is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0028] The video recording method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0029] The following is an introduction to the terms involved in the embodiments of the present disclosure:
[0030] Target video: A user can record a video through a camera mounted on an electronic device, or a camera that is separately installed from the electronic device. In the embodiment of the present application, the target video refers to the video being recorded through the camera.
[0031] Abnormal motion state: The motion state of an electronic device can include abnormal motion state and non-abnormal motion state. Generally speaking, the abnormal motion state may refer to the electronic device undergoing movement beyond the user's expectations, such as falling, collision, etc. In the abnormal motion state, the camera on the electronic device will record unexpected images, resulting in unwanted clips in the target video.
[0032] Image frames to be spliced: In an embodiment of the present application, the recording of the target video will be paused when the motion state of the electronic device enters an abnormal motion state to avoid recording unexpected images. When the target video is subsequently recorded, the scene alignment will be performed according to the image frames to be spliced to ensure a smooth transition of the images recorded before and after the pause of the target video.
[0033] Reference Figure 1 , Figure 1 A video recording step flow chart provided in an embodiment of the present application is shown, which is applied to electronic devices, such as Figure 1 As shown, the specific steps include:
[0034] Step 101: During the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, the recording of the target video is paused.
[0035] In the embodiments of the present application, the electronic device may include at least one camera, and may record a video through a target image frame captured by the camera. For example, the electronic device may be a mobile phone, a tablet computer, a digital camera, a driving recorder, etc. It should be noted that some electronic devices may include more than one camera. For example, a mobile phone may include a front camera, a rear main camera, a rear wide-angle camera, and a rear telephoto camera. When recording a video through any camera, the solution provided in the embodiments of the present application may be applied.
[0036] After the electronic device starts recording the target video through the target image frames captured by the camera, the motion state of the electronic device can be determined in real time. In the embodiment of the present application, the motion state can include an abnormal motion state and a normal state. Since the electronic device is fixedly connected to the camera, when the electronic device is in an abnormal motion state, it can be considered that the camera is also in an abnormal motion state, which will cause the camera to move in an unexpected way by the user, resulting in the recorded target video containing unwanted images by the user.
[0037] like Figure 2 As shown, Figure 2A schematic diagram of an abnormal motion state of an electronic device provided by an embodiment of the present application is shown. Figure 2 As shown, when a user is holding a target video and the electronic device accidentally slips from the user's hand and enters a free fall state, the data from the sensor on the electronic device can be used to determine that the electronic device has entered an abnormal motion state.
[0038] It should be noted that in the embodiments of the present application, determining the motion state of the electronic device essentially requires determining the motion state of the camera. Therefore, the motion state of the electronic device can be determined by one or more motion parameters such as the motion speed, motion acceleration, and motion angular velocity of the camera and / or the electronic device body, and the embodiments of the present application are not specifically limited here.
[0039] In one case, the main body of the electronic device and the camera are designed as an integral whole. For example, for a general mobile phone, the camera is usually designed as an integral structure with the body of the mobile phone. In this case, the motion state of the camera can be equivalent to the motion state of the electronic device it carries. Specifically, the position information of the electronic device can be obtained at preset time intervals through a sensor set on the electronic device, and the position information at adjacent moments can be compared to determine the motion state of the electronic device between the adjacent moments.
[0040] In another case, the main body and the camera of the electronic device are designed to be separate bodies. In this case, the movement state of the camera can be determined by a sensor directly arranged on the camera.
[0041] In addition, the motion state of the electronic device can also be determined based on the image frames obtained by the camera. Specifically, two image frames taken by the camera at a preset time interval can be obtained, and image recognition can be performed on the two image frames to determine the same scene in the two image frames, and the motion state of the electronic device can be estimated based on the position and / or angle changes of the same scene in the two image frames. The technician can flexibly adjust the method for determining the motion state of the camera according to actual needs, and the embodiments of the present application are not specifically limited here.
[0042] When a user uses an electronic device to record a video, the user may accidentally drop or bump the electronic device, causing the electronic device to move abnormally. Since the abnormal movement of the electronic device is not intentional by the user, the electronic device will record images that the user does not want to appear in the current video recording, which can easily cause the target video being recorded to become a waste. In addition, when the camera is in an abnormal motion state, the camera's posture changes at a high speed, resulting in a large difference between two adjacent frames of images captured by the camera, which usually exceeds the capability of the anti-shake algorithm. This situation can easily cause the target video being recorded to have unexpected abnormal content, which can also easily cause the target video being recorded to become a waste.
[0043] Therefore, in an embodiment of the present application, when it is detected that the motion state of the electronic device enters an abnormal motion state, the recording of the target video can be paused. In this way, it can be ensured that the image frames captured by the camera when it is in an abnormal motion state will not be spliced into the target video, thereby avoiding recording of unexpected images in the target video and improving the success rate of the target video.
[0044] It should be noted that, considering the user's need to shoot personalized videos, the user may intentionally put the camera into an abnormal motion state to shoot personalized target videos. For example, when using a mobile phone to shoot a video, the user may throw the mobile phone to shoot a flying perspective. Therefore, in the embodiment of the present application, the user can choose to manually turn on and off the video shooting method provided in the embodiment of the present application.
[0045] Step 102: determining image frames to be spliced from historical image frames collected before the electronic device is in an abnormal motion state.
[0046] In the embodiment of the present application, the historical image frame refers to the target image frame that the camera has captured before detecting that the motion state of the electronic device enters an abnormal motion state. Since the historical image frame is captured before the camera enters an abnormal motion state, no abnormal picture will appear in the target video recorded based on the historical video frame. The image frame to be spliced is the starting frame for continuing recording after restarting the recording of the target video.
[0047] Specifically, the last image frame in the historical image frame can be used as the image frame to be spliced, so as to retain the normal picture that the user has recorded in the target video as much as possible. However, considering that the user may be recording a moving object or a motion video with a large range of changes in viewing angle before the camera is in the abnormal motion state, resulting in the presence of moving objects in the historical video frame or the historical video frame being relatively blurred, making it difficult to align the scene when continuing to record the target video, the last image frame can also be selected from the historical video as the image frame to be spliced, so as to facilitate the use of the image frame to be spliced for scene alignment in subsequent steps.
[0048] Step 103 : when the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity, start recording the target video from the image frame to be spliced.
[0049] After the user regains control of the electronic device, the camera of the electronic device can be moved and the real-time view picture in the electronic device can be observed to match the real-time view picture with the image frame to be spliced, so that the camera is in the shooting position of the image frame to be spliced before entering the abnormal motion state, and the currently shot target image frame is spliced with the image frame to be spliced in the target video to continue shooting the target video.
[0050] Specifically, the target image frame currently captured by the camera can be obtained, and the feature comparison of the target image frame currently captured and the image frame to be spliced can be performed frame by frame to determine the similarity between each target image frame currently captured and the image frame to be spliced. If the similarity between the two is greater than or equal to the preset similarity, it can be determined that the scene in the target image frame currently captured matches the scene in the image frame to be spliced successfully, and the camera has returned to the posture and shooting position for shooting the target image. At this time, the target video can be automatically continued to be recorded.
[0051] After continuing to record the target video, the target video frame captured by the camera is spliced behind the image frame to be spliced in the target video to resume recording the target video. During the splicing process, the target video frame captured by the camera after continuing to record the target video and the image frame to be spliced can be input into the anti-shake algorithm, and the target video frame captured by the camera is fine-tuned by cropping, displacement, etc. before being added to the target video, so that the transition between the video picture after the target video resumes shooting and the video picture before the target video is paused is smoother.
[0052] In summary, a video recording method provided by an embodiment of the present application includes, in the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, then pausing the recording of the target video; determining the image frame to be spliced from the historical image frames collected before the electronic device was in the abnormal motion state; when the similarity between the target image frame and the image frame to be spliced is greater than or equal to the preset similarity, starting to record the target video from the image frame to be spliced. The present application can suspend the recording of the target video when an abnormal motion state of the electronic device is detected, and continue to record the target video when the target image frame collected by the camera matches the image frame to be spliced collected before the recording is suspended, so that the target video finally shot will not contain the picture collected by the electronic device in the abnormal motion state, so that the transition of the pictures shot before and after the pause is smooth, and the success rate of shooting the target video by the electronic device is improved.
[0053] Reference Figure 3 , Figure 3 Another video recording step flow chart provided in an embodiment of the present application is shown. Figure 3 As shown, the specific steps include:
[0054] Step 201 : during the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, the recording of the target video is paused.
[0055] Optionally, step 201 may further include:
[0056] Sub-step 2011, acquiring data from the gravity sensor of the electronic device, and determining the movement path of the electronic device according to the data from the gravity sensor.
[0057] In an embodiment of the present application, the gravity sensor may include a gyroscope, an acceleration sensor, or other sensor carried by the electronic device and / or the camera, which can characterize the gravity or acceleration acting on the camera.
[0058] The real-time motion path of the electronic device can be calculated by the data of the gravity sensor obtained in real time. Specifically, the data of the gyroscope sensor and the acceleration sensor can be integrated to determine the three-dimensional coordinates of the camera in the three-dimensional space corresponding to multiple time points, and the curve path function can be solved according to the three-dimensional coordinates corresponding to multiple consecutive time points to determine the motion path of the electronic device. In addition, the motion path of the electronic device can also be determined by other methods, which are not specifically limited in the embodiments of the present application.
[0059] Sub-step 2012, when the motion path indicates that the electronic device has fallen or collided, determining that the electronic device is in an abnormal motion state.
[0060] After determining the motion path of the electronic device, the motion path can be matched with the preset path type to determine the motion state represented by the motion path. For example, the preset path type can include a falling type, a collision type, etc., which correspond to the matching results of the falling state, the collision state, etc. The accuracy of determining whether the electronic device is in an abnormal motion state is improved, the error caused by misjudgment and the wrong pause of recording is avoided, and the usability of the video recording solution of the present application is enhanced.
[0061] Due to the uncertainty of the motion path, it may be difficult to accurately identify the motion state corresponding to the motion path through simple rule matching. Therefore, in order to improve the accuracy of the motion state determination, technicians can also artificially create abnormal motion states such as falling states and motion states that make the camera exceed the anti-shake capability limit to establish a training set of abnormal motion states and motion paths, and use this training set to train the motion state recognition model. The motion state recognition model can output whether the motion path is an abnormal motion state or the abnormal motion state type corresponding to the motion state based on the input motion path.
[0062] Step 202: When it is determined that the electronic device is in an abnormal motion state, a target number of first anti-shake data frames are recorded.
[0063] In the embodiment of the present application, the target video captured before the pause can be spliced with the target image frame acquired after the restart of the shooting by planning the anti-shake path. By planning the anti-shake path, the slight shaking and vibration of the electronic device can be eliminated. For example, when a user holds an electronic device to shoot a target video, the shaking of the hand will cause slight vibrations in the camera motion path, resulting in shaking of the recorded image. By planning the anti-shake path, the influence of slight vibrations in the camera motion path on the image can be eliminated. The target image frame captured by the camera can be cropped, displaced, and corrected according to the anti-shake path, so that the target video can be smoother.
[0064] Specifically, since the planning of the anti-shake path requires anti-shake data frames within a time period, in the embodiment of the present application, in order for the anti-shake path to cover the shooting picture before the pause and the shooting picture after the restart, it is necessary to record the target number of the latest acquired first anti-shake data frames as the basis for subsequent anti-shake processing of the target video when the motion state of the electronic device enters the abnormal motion state. Among them, the anti-shake data can be obtained from the data of the gravity sensor and the image frame to be processed. The first anti-shake data refers to the target number of continuous anti-shake data frames that are newly acquired before the motion state of the electronic device enters the abnormal motion state. The target number can be determined by the technician according to the actual situation. For example, when the technician needs a higher anti-shake effect, the target number can be set to a larger value. When the technician needs a higher computing efficiency, the target number can be set to a smaller value.
[0065] It should be noted that the image frames to be processed in the anti-shake data frame are video frames acquired by the camera and have not yet been added to the target video. After the anti-shake path is determined according to the data of the gravity sensor in the anti-shake data frame, the image frames to be processed will be anti-shake processed according to the anti-shake path, and then the image frames to be processed after the anti-shake processing will be added to the target video as the video frames of the target video. Therefore, in the embodiment of the present application, the image frames to be processed in the first anti-shake data have not yet been added to the target video when the recording of the target video is paused.
[0066] Furthermore, for some cameras equipped with optical image stabilization, in order to achieve optical image stabilization, the chip and / or image sensor in the camera will autonomously displace in space to offset camera shake. However, after the motion state of the electronic device enters an abnormal motion state, the camera may be subjected to unexpected impacts, such as colliding with the ground after falling from a building. When the optical image stabilization module of the camera is working, if it is subjected to a large impact, it is easy to cause the optical image stabilization function to be damaged. Therefore, when it is detected that the motion state of the electronic device enters an abnormal motion state, the optical image stabilization function of the camera can be temporarily turned off while pausing the recording of the target video to protect the camera, thereby reducing the probability of damage to the optical image stabilization function of the camera due to continuous operation when the camera is in an abnormal motion state.
[0067] In order to further protect the camera, the camera can be directly turned off when it is detected that the movement state of the electronic device enters an abnormal movement state.
[0068] After detecting that the motion state of the electronic device enters an abnormal motion state, the motion state of the electronic device can be continuously detected. After detecting that the motion state of the electronic device has left the abnormal motion state and has continued for a preset safety period of time, the optical image stabilization function of the camera is turned on. If the camera is turned off when it is detected that the motion state of the electronic device enters an abnormal motion state, the camera needs to be turned on in this step.
[0069] Step 203, when the latest image frame collected when the electronic device enters the abnormal motion state includes a moving object, a static picture selection prompt message is sent to the user to prompt the user to select an image frame from the historical image frames.
[0070] If it is determined that there is a moving object in the latest image frame, a static picture selection prompt message may be sent to the user to prompt the user to select a video picture from the recorded target video.
[0071] Step 204 : In response to the user's selection operation on the image frame, determine the image frame selected by the user as the image frame to be spliced.
[0072] Specifically, after sending a prompt message to the user, the recorded target video and the corresponding playback progress bar can be displayed to the user. The user can browse the image frames in the recorded target video through the progress bar, and after finding a still picture, click the confirmation button to determine the image frame as the image frame to be spliced.
[0073] In an embodiment of the present application, a solution is also provided for prompting the user to manually determine the image frames to be stitched, thereby avoiding the situation where the automatically determined image frames to be stitched are difficult to match the scene due to the presence of moving objects, thereby improving the accuracy of subsequent restoration of the target video recording.
[0074] In an embodiment of the present application, in addition to determining a target still image frame in the historical image frames that does not contain a moving object as the image frame to be spliced, a most recently captured image frame in the historical image frames may also be determined as the image frame to be spliced.
[0075] If the latest image frame captured when the electronic device enters an abnormal motion state is directly determined as the image frame to be stitched, the image frame to be stitched may contain moving objects. For example, when the user's mobile phone falls, the phone is shooting the road, and there may be a moving vehicle in the image frame to be stitched. In this case, after the user picks up the phone, even if the phone is restored to the position and angle before the fall, the position of the vehicle in the image frame to be stitched may have changed within the shooting range, or the vehicle is no longer within the current shooting range. In this case, the real-time picture captured by the camera is difficult to match with the image frame to be stitched.
[0076] Therefore, in the embodiment of the present application, motion detection can also be performed on the latest image frame collected when the electronic device enters an abnormal motion state to determine whether there is a moving object in the latest image frame. Specifically, the latest image frame can be compared with the previous image frame acquired by the camera, and based on the difference between the two, it is determined whether there is a moving object in the latest image frame. The embodiment of the present application does not specifically limit the detection method of the moving object, and the technician can select a suitable method to perform motion detection on the latest video frame as needed.
[0077] If it is determined that there is a moving object in the latest image frame, motion detection can be further performed frame by frame on the image frames acquired before the latest image frame until a still video frame containing no moving object is found, and the target still image frame is determined as the image frame to be spliced.
[0078] It should be noted that in the embodiment of the present application, it is also possible not to detect the moving object, and directly determine the latest image frame collected when the electronic device enters an abnormal motion state as the image frame to be spliced. The technician can flexibly choose a solution for determining the image frame to be spliced according to the actual situation, and the embodiment of the present application does not specifically limit this.
[0079] In an embodiment of the present application, the user can improve computing efficiency by quickly determining the image frame to be spliced based on the latest image frame, or can determine the target still image frame captured before the electronic device enters an abnormal motion state as the image frame to be spliced, thereby improving the accuracy of subsequent scene matching.
[0080] Step 205 : performing a contour extraction operation on the image frames to be spliced to obtain a first contour corresponding to the image frames to be spliced.
[0081] In the embodiment of the present application, after the user regains control of the electronic device, the user needs to move the electronic device to the position before entering the abnormal motion state to continue recording the target video. However, the user may not remember the exact position of the electronic device when it entered the abnormal motion state. The outline of the object in the image frame to be spliced can be displayed in the framing screen of the electronic device so that the user can quickly find the framing scene that matches it.
[0082] Specifically, after determining the image frames to be spliced, edge detection can be performed on the objects in the image frames to be spliced to obtain the first contour line of the objects in the image frames to be spliced. For example, edge detection algorithms such as Canny and Sobel can be used to extract the first contour line from the image frames to be spliced.
[0083] Step 206: perform an object contour extraction operation on the target image frame to obtain a second contour line corresponding to the target image frame.
[0084] In an embodiment of the present application, after pausing the recording of the target video, the target image frames acquired by the camera in real time can continue to be displayed in the viewfinder of the electronic device; or after detecting that the electronic device has left an abnormal motion state, the target image frames acquired by the camera in real time can continue to be displayed in the viewfinder of the electronic device.
[0085] For the target image frame captured by the camera in real time, the contour line extraction operation can also be performed on it to obtain the second contour line corresponding to the target image frame. Specifically, the method of extracting the second contour line from the target image frame can be seen in step 205, and the embodiment of the present application will not be repeated.
[0086] Step 207: Overlay the first contour line and the second contour line and display them in the framing picture.
[0087] In the embodiment of the present application, the first contour line corresponding to the image frame to be stitched and the second contour line corresponding to the target image frame can be displayed simultaneously, so that the user can quickly align the scene captured by the current camera with the scene captured when the electronic device enters an abnormal motion state by referring to the first contour line and the second contour line.
[0088] Furthermore, the electronic device can also overlay and display the target image frame in the viewfinder screen at the same time, so that the user can obtain more reference information and improve the speed of the user's scene alignment.
[0089] It should be noted that the first contour line and the second contour line may be displayed in a superimposed manner in different display styles in the framing picture, and the first contour line may also have a different color from the second contour line.
[0090] like Figure 4 As shown, Figure 4 A schematic diagram of a framing screen display provided by the present application is shown in FIG. Figure 4 As shown, the dotted line in the viewfinder 1 represents the first contour line of the image frame to be stitched, and the solid line represents the second contour line of the target image frame. The user can refer to the difference between the first contour line and the second contour line, move the camera of the electronic device, and quickly complete the scene alignment.
[0091] In the embodiment of the present application, by simultaneously displaying the first contour line and the second contour line in the framing screen, the speed at which the user aligns the scene is improved, so that the user can quickly continue recording the target video after regaining control of the electronic device.
[0092] Step 208 : When the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity, recording the target video starts from the image frame to be spliced.
[0093] In the embodiment of the present application, since the first contour line is obtained based on the image frame to be spliced, and the second contour line is obtained based on the target image frame, the first contour line can be directly compared with the second contour line corresponding to each target image frame, and the contour line similarity between the first contour line and the second contour line can be calculated. When the contour line similarity is greater than the first preset similarity, it is determined that the similarity between the target image frame and the image frame to be spliced is greater than the preset similarity, and the target video is continued to be recorded based on the image frame to be spliced. Since the structure of the contour line is relatively simple compared to the image itself, the computing resources consumed by the determination of the contour line similarity are relatively small, and the comparison efficiency of the target image frame and the image frame to be spliced can be greatly improved through contour line comparison.
[0094] In order to improve the comparison accuracy, the image frame to be spliced can also be directly compared with the target image frame in the background to determine whether to start recording the target video. Specifically, the similarity between the image frame to be spliced and the target image frame can be directly determined by calculating the Euclidean distance, cosine distance and other methods between the images. In addition, several feature areas can be selected from the image frame to be spliced and the target image frame, and the similarity between the corresponding feature areas in the two image frames can be calculated respectively. The similarity of multiple feature areas is averaged to obtain the similarity of the two image frames, so as to strike a balance between the accuracy and efficiency of similarity determination.
[0095] Step 209, after recording the target video starting from the image frame to be spliced, obtain a second anti-shake data frame, determine an anti-shake path according to the second anti-shake data frame and the first anti-shake data frame, and perform anti-shake processing on the image frame to be processed contained in the first anti-shake data frame and the image frame to be processed contained in the second anti-shake data frame according to the anti-shake path.
[0096] In the embodiment of the present application, the first anti-shake data frame is obtained in step 202, wherein the image frame to be processed contained in the first anti-shake data frame has not actually participated in generating the target video. After continuing to record the target video based on the image frame to be spliced, the anti-shake path can be calculated based on the currently obtained second anti-shake data frame and the first anti-shake data frame, and the image to be processed contained in the first anti-shake data frame and the image to be processed contained in the second anti-shake data frame are anti-shake processed according to the anti-shake path and then added to the target video, so that the recorded target video achieves a better anti-shake effect.
[0097] Optionally, step 209 may further include:
[0098] Sub-step 2091: determining a first three-dimensional coordinate corresponding to the first anti-shake data frame according to the first anti-shake data frame, and calculating a second three-dimensional coordinate corresponding to the second anti-shake data frame according to the second anti-shake data frame.
[0099] In an embodiment of the present application, the first three-dimensional coordinates of the camera or electronic device corresponding to each first anti-shake data frame in the three-dimensional space can be determined based on an integration operation performed on the data of the gravity sensor (for example, data of the gyroscope sensor and the acceleration sensor) in the first anti-shake data frame.
[0100] And by performing an integration operation on the data of the gyro sensor and the acceleration sensor in the second anti-shake data frame, the second three-dimensional coordinates of the camera or the electronic device corresponding to each second anti-shake data frame in the three-dimensional space are determined.
[0101] Sub-step 2092: determining a motion trajectory of the electronic device according to the first three-dimensional coordinates and the second three-dimensional coordinates, and performing smoothing processing on the motion trajectory to obtain an anti-shake path.
[0102] A curve equation is constructed for the first three-dimensional coordinate and the second three-dimensional coordinate and solved to determine the motion trajectory of the electronic device during the acquisition of the first anti-shake data frame and the second anti-shake data frame. Since the motion trajectory is equivalent to the actual motion trajectory of the camera, which may contain jitter, the real motion trajectory of the electronic device can be smoothed by algorithms such as low-pass filtering, Kalman filtering, or dynamic programming (DP), and the noise (i.e., the jitter part) in the motion trajectory can be removed to obtain the anti-shake path.
[0103] For each image frame to be processed in the first anti-shake data frame and the second anti-shake data frame, the corrected coordinates of the generation moment of the image frame to be processed are obtained from the anti-shake path, the real position coordinates of the electronic device at the generation moment of the image frame to be processed are obtained from the above-mentioned motion trajectory, and the anti-shake correction amplitude for the image frame to be processed is calculated according to the difference between the corrected coordinates and the real position coordinates, wherein the anti-shake correction amplitude may refer to the offset distance, offset angle, etc. that need to be adjusted when the image to be processed is added to the target video.
[0104] In summary, another video recording method provided by an embodiment of the present application includes, in the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, pausing the recording of the target video; determining the image frame to be spliced from the historical image frames collected before the electronic device was in the abnormal motion state; and continuing to record the target video from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to the preset similarity. The present application can suspend the recording of the target video when an abnormal motion state of the electronic device is detected, and continue to record the target video when the target image frame collected by the camera matches the image frame to be spliced collected before the recording is suspended, so that the target video finally shot will not contain the picture collected by the electronic device in the abnormal motion state, so that the transition of the pictures shot before and after the pause is smooth, and the success rate of shooting the target video by the electronic device is improved.
[0105] The video recording method provided in the embodiment of the present application can be performed by a video recording device. In the embodiment of the present application, a method for performing video recording by a video recording device is taken as an example to illustrate the video recording device provided in the embodiment of the present application.
[0106] Reference Figure 5 , Figure 5 is a block diagram of a video recording device provided in an embodiment of the present application, such as Figure 5 As shown, the video recording device comprises:
[0107] The pause module 401 is used to pause the recording of the target video if it is determined that the electronic device is in an abnormal motion state during the process of recording the target video according to the target image frame;
[0108] A determination module 402 is used to determine the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state;
[0109] The recording module 403 is configured to start recording the target video from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity.
[0110] Optionally, the device further comprises:
[0111] A first acquisition submodule, configured to record a target number of first anti-shake data frames when it is determined that the electronic device is in an abnormal motion state;
[0112] The anti-shake submodule is used to obtain a second anti-shake data frame after recording the target video starting from the image frame to be spliced, determine an anti-shake path according to the second anti-shake data frame and the first anti-shake data frame, and perform anti-shake processing on the image frame to be processed contained in the first anti-shake data frame and the image frame to be processed contained in the second anti-shake data frame according to the anti-shake path.
[0113] Optionally, the anti-shake submodule includes:
[0114] a coordinate submodule, configured to determine a first three-dimensional coordinate corresponding to the first anti-shake data frame according to the first anti-shake data frame, and calculate a second three-dimensional coordinate corresponding to the second anti-shake data frame according to the second anti-shake data frame;
[0115] The anti-shake path submodule is used to determine the motion trajectory of the electronic device according to the first three-dimensional coordinates and the second three-dimensional coordinates, and to smooth the motion trajectory to obtain an anti-shake path.
[0116] Optionally, the determining module includes:
[0117] a selection submodule, configured to, when the latest image frame collected when the electronic device enters the abnormal motion state includes a moving object, send a static picture selection prompt message to the user to prompt the user to select an image frame from the historical image frames;
[0118] The image frame determination submodule is used to determine the image frame selected by the user as the image frame to be spliced in response to the user's selection operation on the image frame.
[0119] Optionally, the device further comprises:
[0120] A first extraction submodule, configured to perform a contour extraction operation on the image frame to be spliced, to obtain a first contour corresponding to the image frame to be spliced;
[0121] A second extraction submodule is used to perform an object contour extraction operation on the target image frame to obtain a second contour line corresponding to the target image frame;
[0122] The display submodule is used to display the first contour line and the second contour line in a superimposed manner in a viewfinder image.
[0123] In summary, a video recording device provided by an embodiment of the present application includes, in the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, then pausing the recording of the target video; determining the image frame to be spliced from the historical image frames collected before the electronic device was in the abnormal motion state; and starting recording the target video from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity. The present application can suspend recording the target video when an abnormal motion state of the electronic device is detected, and continue recording the target video when the target image frame collected by the camera matches the image frame to be spliced collected before pausing recording, so that the target video finally shot will not contain the picture collected by the electronic device in the abnormal motion state, so that the transition of the pictures shot before and after the pause is smooth, and the success rate of shooting the target video by the electronic device is improved.
[0124] The video recording device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or other devices other than a terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0125] The video recording device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0126] The video recording device provided in the embodiment of the present application can achieve Figures 1 to 4 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0127] Alternatively, if Figure 6As shown, an embodiment of the present application also provides an electronic device M00, including a processor M01 and a memory M02, wherein the memory M02 stores programs or instructions that can be executed on the processor M01, and when the program or instructions are executed by the processor M01, the various steps of the above-mentioned video recording method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0128] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0129] Figure 7 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0130] The electronic device 100 includes but is not limited to components such as a radio frequency unit 101, a network module 102, an audio output unit 103, an input unit 104, a sensor 105, a display unit 106, a user input unit 107, an interface unit 108, a memory 109, and a processor 110.
[0131] Those skilled in the art will appreciate that the electronic device 100 may also include a power source (such as a battery) for supplying power to various components, and the power source may be logically connected to the processor 110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0132] Among them, the processor 110 is used to pause recording the target video if it is determined that the electronic device is in an abnormal motion state during the process of recording the target video according to the target image frame; determine the image frame to be spliced from the historical image frames collected before the electronic device is in the abnormal motion state; and start recording the target video from the image frame to be spliced when the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity.
[0133] In summary, a video recording method provided by an embodiment of the present application includes, in the process of recording a target video according to a target image frame, if it is determined that the electronic device is in an abnormal motion state, then pausing the recording of the target video; determining the image frame to be spliced from the historical image frames collected before the electronic device was in the abnormal motion state; when the similarity between the target image frame and the image frame to be spliced is greater than or equal to the preset similarity, starting to record the target video from the image frame to be spliced. The present application can suspend the recording of the target video when an abnormal motion state of the electronic device is detected, and continue to record the target video when the target image frame collected by the camera matches the image frame to be spliced collected before the recording is suspended, so that the target video finally shot will not contain the picture collected by the electronic device in the abnormal motion state, so that the transition of the pictures shot before and after the pause is smooth, and the success rate of shooting the target video by the electronic device is improved.
[0134] It should be understood that in the embodiment of the present application, the input unit 104 may include a graphics processor (Graphics Processing Unit, GPU) 1041 and a microphone 1042, and the graphics processor 1041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 106 may include a display panel 1061, and the display panel 1061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 107 includes a touch panel 1071 and at least one of other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include two parts: a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0135] The memory 109 can be used to store software programs and various data. The memory 109 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 109 may include a volatile memory or a non-volatile memory, or the memory 109 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0136] The processor 110 may include one or more processing units; optionally, the processor 110 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 110.
[0137] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned video recording method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0138] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0139] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned video recording method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0140] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0141] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned video recording method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0142] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0144] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A video recording method, characterized in that: The method comprises: During the process of recording the target video according to the target image frame, if it is determined that the electronic device is in an abnormal motion state, pausing the recording of the target video; Determining the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state; When the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity, recording the target video starting from the image frame to be spliced; The method further comprises: When it is determined that the electronic device is in an abnormal motion state, recording a target number of first anti-shake data frames; After recording the target video starting from the image frame to be spliced, a second anti-shake data frame is obtained, an anti-shake path is determined according to the second anti-shake data frame and the first anti-shake data frame, and anti-shake processing is performed on the image frame to be processed included in the first anti-shake data frame and the image frame to be processed included in the second anti-shake data frame according to the anti-shake path.
2. The method according to claim 1, characterized in that The determining the anti-shake path according to the second anti-shake data frame and the first anti-shake data frame includes: Determine a first three-dimensional coordinate corresponding to the first anti-shake data frame according to the first anti-shake data frame, and calculate a second three-dimensional coordinate corresponding to the second anti-shake data frame according to the second anti-shake data frame; The motion trajectory of the electronic device is determined according to the first three-dimensional coordinates and the second three-dimensional coordinates, and the motion trajectory is smoothed to obtain an anti-shake path.
3. The method according to claim 1, characterized in that The step of determining the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state comprises: In the case where the latest image frame collected when the electronic device enters the abnormal motion state includes a moving object, a static picture selection prompt message is sent to the user to prompt the user to select an image frame from the historical image frames; In response to the user's selection operation on the image frame, the image frame selected by the user is determined as the image frame to be spliced.
4. The method according to claim 1, characterized in that: After pausing the recording of the target video, the method further includes: Performing a contour line extraction operation on the image frame to be stitched to obtain a first contour line corresponding to the image frame to be stitched; Performing an object contour extraction operation on the target image frame to obtain a second contour line corresponding to the target image frame; The first contour line and the second contour line are superimposed and displayed in a viewfinder image.
5. A video recording device, characterized in that: The device comprises: A pause module, used for pausing the recording of the target video if it is determined that the electronic device is in an abnormal motion state during the process of recording the target video according to the target image frame; A determination module, used to determine the image frames to be spliced from the historical image frames collected before the electronic device is in an abnormal motion state; A recording module, configured to record the target video starting from the image frame to be spliced if the similarity between the target image frame and the image frame to be spliced is greater than or equal to a preset similarity; The device also includes: A first acquisition submodule, configured to record a target number of first anti-shake data frames when it is determined that the electronic device is in an abnormal motion state; The anti-shake submodule is used to obtain a second anti-shake data frame after recording the target video starting from the image frame to be spliced, determine an anti-shake path according to the second anti-shake data frame and the first anti-shake data frame, and perform anti-shake processing on the image frame to be processed contained in the first anti-shake data frame and the image frame to be processed contained in the second anti-shake data frame according to the anti-shake path.
6. The device according to claim 5, characterized in that The anti-shake submodule comprises: a coordinate submodule, configured to determine a first three-dimensional coordinate corresponding to the first anti-shake data frame according to the first anti-shake data frame, and calculate a second three-dimensional coordinate corresponding to the second anti-shake data frame according to the second anti-shake data frame; The anti-shake path submodule is used to determine the motion trajectory of the electronic device according to the first three-dimensional coordinates and the second three-dimensional coordinates, and to smooth the motion trajectory to obtain an anti-shake path.
7. The device according to claim 5, characterized in that The determination module comprises: a selection submodule, configured to, when the latest image frame collected when the electronic device enters the abnormal motion state includes a moving object, send a static picture selection prompt message to the user to prompt the user to select an image frame from the historical image frames; The image frame determination submodule is used to determine the image frame selected by the user as the image frame to be spliced in response to the user's selection operation on the image frame.
8. The device according to claim 5, characterized in that The device also includes: A first extraction submodule, configured to perform a contour extraction operation on the image frame to be spliced, to obtain a first contour corresponding to the image frame to be spliced; A second extraction submodule is used to perform an object contour extraction operation on the target image frame to obtain a second contour line corresponding to the target image frame; The display submodule is used to display the first contour line and the second contour line in a superimposed manner in a viewfinder image.
