Angle detection method and device for overturning camera of equipment, equipment and storage medium
By detecting motion contours from camera video streams and filtering valid contours, and combining centroid coordinates to calculate the flip angle, the problem of high cost and low accuracy in camera flip angle detection in existing technologies is solved, achieving high-precision and low-cost angle detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, camera flip angle detection relies on external mechanical sensors, which suffers from high hardware costs, susceptibility to external interference, and drift issues with long-term use, making it difficult to achieve high-precision, low-cost flip angle detection.
By detecting motion contours from the camera's video stream, filtering out valid contours using contour geometry parameters, and calculating the flip angle using centroid coordinates, high-precision angle detection without the need for external mechanical sensors is achieved.
Without relying on external mechanical sensors, high-precision and low-cost flip camera angle detection was achieved, reducing equipment cost investment and improving detection accuracy and robustness.
Smart Images

Figure CN121661082A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method, apparatus, device, and storage medium for detecting the angle of a device flipping a camera. Background Technology
[0002] In applications such as learning machines, smart terminal devices, and industrial rotary monitoring with flip-up cameras, the accuracy of the flip angle directly impacts the product's functionality (photography, recognition, etc.), thus requiring the detection of the camera's actual flip angle. Traditional angle detection methods typically rely on mechanical sensors (such as angle sensors, gyroscopes, and encoders), which suffer from high hardware costs, susceptibility to external interference, and drift issues with long-term use. Therefore, achieving high-precision, low-cost flip angle detection without relying on external mechanical sensors has become a pressing problem. Summary of the Invention
[0003] This invention provides a method, apparatus, device, and storage medium for detecting the angle of a flip camera, which solves the problems of low accuracy and high cost in the detection of camera flip angle in the prior art, and realizes high-precision and low-cost detection of the flip angle of a flip camera without relying on external mechanical sensors.
[0004] This invention provides a method for detecting the angle of a device flipping a camera, comprising the following steps: Detect at least one motion profile corresponding to the flip camera from the video stream of the device under test containing the flip camera; Based on preset contour geometry parameters, at least one of the motion contours is filtered to determine the effective contour of the flip camera; The flip angle of the flip camera is detected based on the effective contour.
[0005] According to the present invention, a method for detecting the angle of a device flip camera is provided, wherein the contour geometric parameters include at least one of the contour area, roundness, and fill rate.
[0006] The step of filtering at least one motion contour according to preset contour geometry parameters to determine the effective contour of the flip camera includes: Calculate the contour area, contour roundness, and contour fill rate for each of the motion contours; Based on the contour area, contour roundness and contour fill rate of each of the motion contours, a contour that meets the preset conditions is selected from at least one of the motion contours as the effective contour. The preset conditions are that the contour area is greater than or equal to a preset area threshold, the contour roundness is within a preset roundness threshold range, and the contour fill rate is greater than or equal to a preset fill rate threshold.
[0007] According to the present invention, a method for detecting the angle of a device flipping camera includes calculating the contour area, contour roundness, and contour fill rate of each motion contour, comprising: The area of the contour is obtained by performing discrete integration on the coordinate sequence of the boundary pixels of the motion contour; The circularity of the contour is calculated based on the area of the contour and the perimeter of the moving contour. Calculate the ratio of the area of the contour to the area of the minimum bounding rectangle of the motion contour, and use the ratio as the contour fill rate.
[0008] According to a method for detecting the angle of a device flip camera provided by the present invention, the step of detecting the flip angle of the flip camera based on the effective contour includes: Determine the centroid coordinates of the effective contour in multiple video frames; The flip angle of the flip camera is determined based on multiple centroid coordinates and pre-calibrated rotation center point coordinates.
[0009] According to a method for detecting the angle of a device flip camera provided by the present invention, determining the flip angle of the flip camera based on multiple centroid coordinates and pre-calibrated rotation center point coordinates includes: Based on the coordinates of the initial centroid and the coordinates of the rotation center point, determine the first angle value between the initial centroid and the rotation center point; Based on the centroid coordinates of the i-th frame and the rotation center point coordinates, determine the second angle value between the centroid of the i-th frame and the rotation center point; i is an integer greater than 1. Calculate the angle difference between the first angle value and the second angle value, and determine the angle difference as the flip angle of the flip camera in the i-th frame.
[0010] According to a method for detecting the angle of a device flipping a camera provided by the present invention, determining the centroid coordinates of the effective contour in multiple video frames includes: If multiple valid contours exist, the valid contour with the largest area is selected as the target valid contour. For each video frame, extract the set of boundary pixels of the effective contour of the target; Based on the coordinates of the boundary pixel set, the geometric center of the effective contour of the target is calculated, and the geometric center is used as the centroid coordinates.
[0011] According to a method for detecting the angle of a device flip camera provided by the present invention, the step of detecting at least one motion contour corresponding to the flip camera from a video stream of a device under test including the flip camera includes: The difference between the video frames in the video stream and the reference frame is calculated to obtain a difference image; the reference frame is the first frame in the video stream before the flip camera starts moving. The difference image is binarized to distinguish between moving areas and static backgrounds; Morphological optimization is performed on the binary image after binarization to optimize the contour of the motion region; the morphological optimization includes opening and closing operations, the opening operation is used to eliminate noise in the binary image, and the closing operation is used to fill the holes inside the motion region; From the optimized binary image, detect at least one motion contour corresponding to the flip camera.
[0012] The present invention also provides an angle detection device for a device flipping a camera, comprising the following modules: A motion contour detection module is used to detect at least one motion contour corresponding to the flip camera from a video stream of a device under test containing a flip camera. An effective contour determination module is used to filter at least one of the motion contours according to preset contour geometric parameters in order to determine the effective contour of the flip camera. A flip angle detection module is used to detect the flip angle of the flip camera based on the effective contour.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the angle detection method for flipping the camera as described above.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the angle detection method for flipping a camera as described in any of the above embodiments.
[0015] The present invention provides a method, apparatus, device, and storage medium for detecting the angle of a flip camera. This involves detecting at least one motion contour corresponding to the flip camera from a video stream of a device under test containing the flip camera; filtering the at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera; and detecting the flip angle of the flip camera based on the effective contour. The present invention achieves highly robust recognition of the flip camera contour through visual analysis combined with a collaborative filtering mechanism based on contour geometric parameters, thereby enabling high-precision and low-cost detection of the flip angle of the flip camera without relying on external mechanical sensors. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the device flip camera angle detection method provided by the present invention.
[0018] Figure 2 This is a schematic diagram of the test scenario provided by the present invention.
[0019] Figure 3 This is a schematic diagram of the flip area of the learning machine camera provided by the present invention.
[0020] Figure 4 This is a schematic diagram of the centroid and rotation center point provided by the present invention.
[0021] Figure 5 This is a schematic diagram of the structure of the device for detecting the angle of a flip camera provided by the present invention.
[0022] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0024] In related technologies, angle detection methods based on physical sensors mainly include: 1) Mechanical angle sensors: Mechanical angle sensors rely on physical contact measurement. Their core principle is to obtain angle signals through mechanical structures such as sliding brushes, gear meshing, or grating displacement. Although these sensors have high accuracy in static scenarios, their accuracy has a large error in dynamic flip detection.
[0025] 2) Inertial sensors: Although inertial sensors, represented by gyroscopes, can achieve non-contact angle detection, they rely on angular velocity integration to calculate the angle.
[0026] In addition, the angle detection and analysis method based on high-speed cameras is as follows: In industry, high-speed cameras can be used to capture fast-moving objects, and then frame-by-frame analysis can be performed. Computer vision methods can be used to calculate and analyze the changes in motion characteristics of each frame, thereby obtaining the changes in motion amount in the complete motion process.
[0027] The above angle detection method has the following drawbacks: The drawbacks of mechanical angle sensor methods include: ① High installation complexity: Precise matching of the coaxiality of the camera's rotation axis and the sensor's rotation axis is required; otherwise, eccentricity errors will be introduced. For example, in flip-type learning machines, due to the limitations of the device's slim design, it is difficult to reserve sufficient space for mechanical installation. ② Contact wear and lifespan issues: Long-term friction can lead to brush aging or encoder contamination, especially in high-frequency industrial flipping scenarios, where the mechanical lifespan may be less than six months, requiring frequent maintenance and replacement. ③ Dynamic response delay: The inertia of the mechanical structure causes signal lag during high-speed flipping, which cannot meet real-time control requirements.
[0028] Limitations of the inertial sensor method: ① Temperature changes can alter the sensor's zero bias, while mechanical vibrations may excite high-frequency noise in the gyroscope, further amplifying the integration error. ② Although short-term drift can be suppressed by Kalman filtering, after long-term continuous operation, the error of a pure inertial system without external reference may still exceed 10 degrees.
[0029] Limitations of high-speed camera analysis methods: ① Hardware cost and deployment bottlenecks: High-speed cameras are typically expensive, while small electronic product production lines require multiple inspection stations, making the overall cost prohibitive. Furthermore, system integration is complex, requiring high-power light sources, dedicated image acquisition cards, and cooling devices, significantly increasing production line space and energy consumption, contradicting the lightweight and high-density manufacturing requirements of consumer electronics. ② Real-time limitations: The ultra-high-definition video streams generated by high-speed cameras rely on GPUs (Graphics Processing Units) for dense optical flow or feature point tracking calculations, resulting in single-frame processing latency exceeding 50ms, failing to meet the real-time control requirements of ≤10ms response time.
[0030] Based on the above problems, the problem that this invention needs to solve is: 1) Overcomes the limitations of traditional sensor detection methods by building a non-contact test scenario, overcoming interference and measurement errors caused by the hardware itself, and providing accuracy in the dynamic real-time angle detection process; 2) Based on the established test scenario and computer vision algorithm processing, it can effectively solve the angle detection in special scenarios such as noise interference, angle jump (such as angle detection from 360 degrees back to 1 degree), and multi-turn repetition detection, providing an effective detection method for flip-type product testing; 3) Reduce the cost of testing equipment. Both sensor-based testing methods and high-speed camera-based analysis methods require a large investment in equipment. The method provided by this invention can reduce the cost of equipment.
[0031] The following is combined Figures 1-6 The present invention describes a method, apparatus, device, and storage medium for detecting the angle of a device flip camera.
[0032] Figure 1 This is a flowchart illustrating the device flip camera angle detection method provided by the present invention, as shown below. Figure 1 As shown, the method includes the following: Step 101: Detect at least one motion profile corresponding to the flip camera from the video stream of the device under test containing the flip camera.
[0033] To provide a stable, reliable, and interference-free physical testing environment, a test scenario needs to be set up. The required equipment mainly includes: Image acquisition equipment (such as industrial cameras): to capture the flipping process of the camera during testing; Sliding rails: enable free adjustment in both horizontal and vertical directions to ensure a horizontal viewing angle; Device under test (including flip camera): Products under test that include flip cameras, mainly learning machines; Planar adjustable light source: provides adjustable uniform white light in the horizontal direction, overcoming the influence of external lighting environment; Light-shielding enclosure: The sides are made of dark-colored, opaque acrylic panels to block external light.
[0034] like Figure 2As shown, a height-adjustable camera bracket is used to fix the camera device. The fixing clamp of the learning machine product can be adjusted in the up, down, left, and right directions to ensure that the camera's viewing angle and the flipped side of the learning machine are always on the same plane during the test, thus overcoming the measurement deviation caused by angle obstruction. A planar adjustable light source is located directly in front of the camera, providing a positive, uniform, and adjustable light source to reduce the influence of environmental factors caused by uneven external lighting. The entire test scene is located in a shielded enclosure, with sides constructed of dark, opaque acrylic sheets to minimize interference from external light sources on the camera's image acquisition.
[0035] It should be understood that a flip camera refers to a camera module on the device under test that can be rotated by a motor or manually. Motion profile refers to a series of closed sets of pixels that stand out in the differential image (the difference between the current frame and the reference frame) in a video stream due to the motion of the flip camera. It represents the projected shape and position of the flip camera on the two-dimensional image plane.
[0036] Motion contours are closed boundaries that characterize the spatial location and shape features of moving targets, extracted from video sequences using motion detection algorithms.
[0037] Acquire video streams from the device under test (DUT) that includes a flip-up camera. For example, in a test scenario, point a fixed reference camera at the DUT (such as a learning machine) that includes a flip-up camera, ensuring that the flip-up camera of the DUT is within the field of view of the reference camera. Read the video stream from the reference camera in real time and decode it into image frames arranged in a time sequence.
[0038] The image frames in the video stream undergo preprocessing, including: converting the image frames from RGB color space to grayscale images, blurring the grayscale images using a Gaussian kernel to suppress noise, and standardizing the size of the blurred images to a preset size. It should be understood that while setting up a test scenario can maximize the reduction of external environmental interference and create a black-and-white test environment, some interference is still unavoidable during image acquisition. Therefore, for the acquired image information, grayscale processing is first required, converting the RGB color images to grayscale images, followed by Gaussian blurring to eliminate noise interference. For example, Gaussian blur filtering is used, with a 5×5 Gaussian kernel for smoothing. Finally, for the image information processed frame by frame, its size information is standardized to ensure a balance between processing speed and accuracy.
[0039] The process involves detecting at least one motion contour corresponding to the flip camera from the preprocessed video stream. For example, in each frame of the video stream, a preset region where the flip camera is located is determined as the initial region of interest (ROI). For consecutive video frames within the ROI, a background subtraction algorithm is applied to extract a set of moving foreground pixels relative to the static device subject. After optimizing the moving foreground pixel set, a contour search algorithm is executed to extract all connected contours from the optimized binary image, serving as candidate motion contours. Based on prior geometric and motion knowledge of the flip camera, the final motion contour is selected from the candidate motion contours. The features used for contour selection may include: the aspect ratio of the contour's bounding rectangle, the variation of the contour area in consecutive frames, and the centroid trajectory of the contour. For example, during the selection process based on the variation of the contour area in consecutive frames, contours whose contour area shows a monotonically increasing or decreasing variation in consecutive frames are prioritized, as this variation corresponds to the pop-up or retraction process of the flip camera.
[0040] Step 102: Based on preset contour geometry parameters, at least one of the motion contours is filtered to determine the effective contour of the flip camera.
[0041] It should be understood that during the movement of the flip camera, its image representation is a series of dynamically changing motion contours. Given that the flipping motion is essentially an arc-shaped trajectory rotating around an axis, the geometric properties of its projected contours follow specific physical constraints. Therefore, not all detected motion contours can effectively represent the true state of the flip camera; contours that are too large or too small, or have unreasonable shapes, will introduce calculation errors. To improve the accuracy and scientific rigor of contour detection, this invention introduces a three-level joint screening mechanism. This mechanism, based on prior knowledge of the motion characteristics of the flip camera, sets targeted threshold conditions from three independent and complementary geometric dimensions: contour area, contour roundness, and contour fill rate. Through this three-level screening, the system can progressively eliminate invalid contours that do not conform to physical constraints (such as noise with too small an area, false detection areas with too large an area, circular screw interference, and narrow or hollow non-solid areas), thereby accurately screening out effective contours that highly match the characteristics of the flip camera in terms of size, shape, and solidity.
[0042] Contour geometry parameters are a series of mathematical descriptors extracted from an image to accurately describe the shape, size, and structural characteristics of a contour. Contour geometry parameters include at least one of the contour's area, roundness, and fill rate. Area refers to the total number of pixels in an image occupied by the region enclosed by the contour. The purpose of filtering moving contours based on area is to filter out noise with areas that are too large or too small. It should be understood that the projected area of the flip camera is within a predictable range; an area that is too small may be sensor noise or minor reflections; an area that is too large may be an incorrect detection area or a sudden change in background. Retaining contours with areas within a preset threshold range can effectively eliminate most irrelevant interference.
[0043] Circularity measures the regularity of a contour. A circularity value closer to 1 indicates a near-circular motion trajectory, while a value closer to 1 indicates a more irregular trajectory. The purpose of filtering motion contours based on circularity is to filter based on the physical shape characteristics of the flip camera. It should be understood that a flip camera is typically a compact, near-rectangular or cylindrical structure, resulting in a high degree of circularity in its projection. Conversely, contours caused by motion blur and lighting interference are often irregular or elongated, with low circularity. By setting a circularity threshold range, these interfering contours that do not conform to the target's physical shape can be effectively filtered out.
[0044] Fill rate, also known as contour density, refers to the ratio of the area of a contour itself to the area of its smallest bounding rectangle. It measures how fully a contour fills its bounding rectangle. The purpose of filtering moving contours based on fill rate is to ensure that the contours are solid, full, blocky objects, excluding hollow, fragmented, or severely recessed areas. It should be understood that the projected contour of a physically solid flip camera should be relatively full and compact, while contours formed by multiple discrete noise points connected by chance, or contours with internal voids due to complex reflections, will have a low fill rate. By setting a high fill rate threshold, it is possible to ultimately ensure that the filtered contours are high-quality regions representing solid physical targets.
[0045] An effective contour refers to the contour that is determined to stably and accurately represent the flip camera itself after a three-level screening process based on area, roundness, and fill rate among all motion contours obtained from the video stream through motion detection.
[0046] For each motion contour, a set of contour geometric parameters is calculated, including contour area, contour circularity, and contour fill rate. Based on the calculated contour area, contour circularity, and contour fill rate, the motion contour is judged. When the motion contour simultaneously meets the conditions set by the above parameters, it is determined as the valid contour of the flip camera.
[0047] In one embodiment, the motion contour can be further filtered in multiple levels based on contour area, contour roundness, and contour fill rate, wherein the order in which the multiple filtering parameters are used is arbitrary. For example, motion contours with a contour area greater than or equal to a preset area threshold are retained as a first candidate set. From the first candidate set, motion contours with a contour roundness lower than a preset roundness threshold are retained as a second candidate set. From the second candidate set, motion contours with a contour fill rate greater than or equal to a preset fill rate threshold are retained as the final candidate set, i.e., valid contours.
[0048] In one embodiment, the contour geometry parameters further include at least two of the contour area, roundness, and fill rate. For each moving contour, at least two selected contour geometry parameters are calculated in parallel, and each calculated contour geometry parameter is compared with a threshold condition that is independently preset for it, generating a series of Boolean judgment results; wherein the threshold condition includes at least two of the following: Area condition: Determine whether the area of the outline is greater than or equal to a preset area threshold; Circularity condition: Determines whether the circularity of the contour is within the preset circularity threshold range; Fill rate condition: Determine whether the outline fill rate is greater than or equal to the preset fill rate threshold.
[0049] For each motion contour, a logical AND operation is performed on the conditional judgment results of all calculated contour geometric parameters. The motion contours whose logical AND operation result is true are determined as valid contours for the flip camera. If multiple valid contours are selected through the logical AND operation, they are sorted according to the values of one or more geometric parameters, and the valid contour that ranks first in the sort is taken as the final target valid contour.
[0050] Step 103: Detect the flip angle of the flip camera based on the effective contour.
[0051] The flip angle refers to the angle that a flip camera rotates around its physical axis of rotation from a defined initial position (or reference position) to the current detection position.
[0052] The flip angle of the flip camera is detected based on the effective contour. For example, the orientation angle of the effective contour is calculated, which can be obtained by calculating the direction of the long side of the smallest bounding rectangle of the contour, or by calculating the principal axis direction of the contour. In the video frame, a fixed reference baseline is determined, where the reference baseline is the horizontal bottom edge of the device under test in the image, or the standard orientation line of the flip camera's contour when it is fully retracted. The angle between the orientation angle of the effective contour and the reference baseline is calculated and mapped to the current flip angle of the flip camera. A temporal filtering algorithm is applied to smooth a series of current flip angles calculated in consecutive video frames, and the smoothed angle value is output as the final flip angle detection result.
[0053] In one embodiment, the principal axis direction of the contour can be calculated using the image moment method. For example, the second central moment of the effective contour can be calculated to construct the covariance matrix; the eigenvectors of the covariance matrix can be calculated, where the direction of the eigenvector corresponding to the largest eigenvalue is the principal axis direction of the contour.
[0054] The present invention provides a method for detecting the angle of a flip camera in a device. This method involves detecting at least one motion contour corresponding to the flip camera from the video stream of the device under test, which includes the flip camera; filtering the at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera; and detecting the flip angle of the flip camera based on the effective contour. This invention achieves highly robust recognition of the flip camera contour through visual analysis combined with a collaborative filtering mechanism based on contour geometric parameters, thereby enabling high-precision and low-cost detection of the flip angle of the flip camera without relying on external mechanical sensors.
[0055] Based on the above embodiments, the step of filtering at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera includes: Calculate the contour area, contour roundness, and contour fill rate for each of the motion contours; Based on the contour area, contour roundness and contour fill rate of each of the motion contours, a contour that meets the preset conditions is selected from at least one of the motion contours as the effective contour. The preset conditions are that the contour area is greater than or equal to a preset area threshold, the contour roundness is within a preset roundness threshold range, and the contour fill rate is greater than or equal to a preset fill rate threshold.
[0056] It should be understood that the area threshold can be determined based on the expected projected size range of the flip camera in the image, used for initial size screening. The roundness threshold is used to ensure that the contour is sufficiently compact, thereby excluding elongated, irregular, non-target contours. The fill rate threshold is used to ensure the fullness of the contour, thereby excluding invalid areas that are hollow, fragmented, or have internal holes.
[0057] For each motion contour, its contour area, contour roundness, and contour fill rate are calculated in parallel. The contour area is determined to be greater than or equal to an area threshold, the contour roundness is determined to be within a roundness threshold range, and the contour fill rate is determined to be greater than or equal to a fill rate threshold. For each motion contour, the results of the area, roundness, and fill rate condition judgments are logically ANDed. Motion contours whose logical AND operation result is true are determined as valid contours for the flip camera.
[0058] This invention, through the introduction of a three-dimensional collaborative screening mechanism comprised of area, roundness, and fill rate, can accurately identify contours highly matching the physical characteristics of a flip camera from complex moving backgrounds. The area threshold ensures a reasonable target size, effectively filtering out noise points and excessively large interference areas; the roundness threshold, based on the compact physical shape of the camera, excludes elongated or irregular contours caused by motion blur or occlusion; and the fill rate threshold, by judging the fullness of the contour, filters out invalid areas with internal voids or scattered edges. This screening strategy ensures the reliability of the contour data upon which subsequent angle calculations rely, thus laying the foundation for high-precision non-contact angle detection.
[0059] Based on the above embodiments, calculating the contour area, contour roundness, and contour fill rate of each motion contour includes: The area of the contour is obtained by performing discrete integration on the coordinate sequence of the boundary pixels of the motion contour; The circularity of the contour is calculated based on the area of the contour and the perimeter of the moving contour. Calculate the ratio of the area of the contour to the area of the minimum bounding rectangle of the motion contour, and use the ratio as the contour fill rate.
[0060] Based on Green's theorem, the area enclosed by the contour is calculated using the coordinate sequence of the boundary pixels of the moving contour. (Reference) Figure 3 , Figure 3This is a schematic diagram of the flipped area of the learning machine camera provided by the present invention. The explanation is based on the calculation of the contour area after the learning machine camera flips. For example, the parameterized representation of the closed boundary curve of the motion contour in the discrete pixel coordinate system is obtained, that is, a sequence of boundary pixel coordinates arranged in a clockwise or counterclockwise direction. Applying the discrete form of Green's theorem, the calculation of the area enclosed by the closed boundary curve is transformed into a discrete line integral along the closed boundary curve. For example, the following discrete integral formula is used to calculate the contour area: ; in, The first in the coordinate sequence The coordinates of each pixel This represents the total number of pixels on the contour boundary. The area is the outline area.
[0061] The absolute value of the discrete linear integral calculation result is determined as the area of the contour enclosed in the current frame during the flipping process.
[0062] Calculate the ratio of the contour area to the square of the contour perimeter, and multiply this ratio by a constant coefficient to obtain the contour roundness. For example, to obtain the contour area and perimeter in pixels, calculate the contour roundness using the standard roundness calculation formula: ; in, For the roundness of the outline, This is the perimeter of the outline.
[0063] In one embodiment, the perimeter of the contour is obtained by one of the following methods: calculating the sum of Euclidean distances between adjacent pixels in the sequence of pixels on the contour boundary; or calculating based on the geometric moments of the contour.
[0064] Calculate the minimum bounding rectangle of the motion profile. The minimum bounding rectangle is the rectangle with the smallest area that completely encloses the motion profile. Calculate the area of this minimum bounding rectangle. For example, the profile fill rate can be calculated using the following formula: ; in, For contour fill rate, It is the area of the minimum bounding rectangle of the motion profile.
[0065] This invention employs discrete integration to calculate the contour area, ensuring the accuracy of the area value. Based on the area and perimeter, it calculates roundness, precisely characterizing the compactness and regularity of the contour shape in a dimensionless form, effectively distinguishing targets from noise. The fill rate is defined by the ratio of the contour area to the area of its smallest bounding rectangle, intuitively reflecting the fullness of the contour and filtering out hollow, scattered, non-solid areas. These calculation methods together constitute a hierarchical and mutually verifying evaluation system, ensuring that the final selected valid contours accurately correspond to the flip camera from three dimensions: size, shape, and structural integrity.
[0066] Based on the above embodiments, detecting the flip angle of the flip camera according to the effective contour includes: Determine the centroid coordinates of the effective contour in multiple video frames; The flip angle of the flip camera is determined based on multiple centroid coordinates and pre-calibrated rotation center point coordinates.
[0067] Centroid coordinates refer to the pixel coordinates that represent the geometric center of the moving parts of the flip camera, calculated by image processing algorithms in each frame of video image. They can be understood as the balance point or center of gravity of the contour on the image.
[0068] The pre-calibrated rotation center point coordinates are fixed, pre-determined pixel coordinates in the image, representing the projected position of the physical rotation axis of the flip camera on the two-dimensional image plane. In one embodiment, after the system enters calibration mode, the user is prompted to manually control the flip camera to perform a complete pop-up or retraction movement; during this period, the system acquires device images of the flip camera at at least three different flip angles. In each acquired image, the user manually selects a fixed feature point on the flip camera, where the fixed feature point is a point on the flip camera directly associated with the physical rotation axis and clearly visible in the image during the flipping process. The system receives the coordinates of the fixed feature points selected by the user in at least three images, calculates an optimal fitting circle based on these coordinates using a circular fitting algorithm, and calculates and stores the center coordinates of this fitted circle as the pre-calibrated rotation center point coordinates of the device. Furthermore, control the flip camera to move to a verification angle not used for calibration, calculate the distance between the coordinates of the manually selected fixed feature point and the calibrated rotation center point, and verify whether the distance is consistent with the radius of the fitted circle within the preset tolerance range. If consistent, the calibration is confirmed to be effective.
[0069] Determine the centroid coordinates of the valid contour across multiple video frames. For example, for each valid contour in a video frame, calculate its image moments; based on the zeroth and first moments in the image moments, calculate the centroid coordinates.
[0070] The flip angle of the camera is determined based on multiple centroid coordinates and pre-calibrated rotation center point coordinates. For example, a reference direction is determined based on at least one reference centroid coordinate and rotation center point coordinate; the current direction is determined based on the centroid coordinate and rotation center point coordinate of the current frame; the angle between the current direction and the reference direction is calculated, and this angle is used as the flip angle. Alternatively, the corresponding direction vectors are calculated based on the rotation center point coordinates and the centroid coordinates of different video frames; the flip angle of the camera is determined by calculating the angle between these direction vectors.
[0071] This invention simplifies the problem of measuring the flip angle by transforming complex contour morphology analysis into motion tracking of a single, stable centroid point and introducing a pre-calibrated rotation center. This transforms the problem into a high-precision vector angle calculation. The method cleverly utilizes the core physical characteristic that flip motion involves the centroid rotating around a fixed axis, allowing the algorithm to eliminate interference from contour deformation and focus solely on the core rotational displacement. Ultimately, it achieves high-precision, low-cost, non-contact angle detection without relying on external mechanical sensors.
[0072] Based on the above embodiments, determining the flip angle of the flip camera according to the plurality of centroid coordinates and the pre-calibrated rotation center point coordinates includes: Based on the coordinates of the initial centroid and the coordinates of the rotation center point, determine the first angle value between the initial centroid and the rotation center point; Based on the centroid coordinates of the i-th frame and the rotation center point coordinates, determine the second angle value between the centroid of the i-th frame and the rotation center point; i is an integer greater than 1. Calculate the angle difference between the first angle value and the second angle value, and determine the angle difference as the flip angle of the flip camera in the i-th frame.
[0073] The first angle value refers to the angle formed by the line connecting the centroid of the effective contour and the pre-calibrated rotation center at the initial moment when the flip camera begins to move (i.e., the starting frame), and a preset coordinate system reference axis (usually the horizontal axis).
[0074] The second angle value refers to the angle formed by the line connecting the centroid of the current effective contour and the same rotation center in any i-th frame during the movement of the flipping camera, and the same preset coordinate system reference axis. The second angle value represents the instantaneous spatial direction of the centroid of the flipping camera at a specific moment (i-th frame) during the movement.
[0075] Based on the initial centroid coordinates and the rotation center coordinates, determine the first angle value between them. For example, calculate the vector pointing from the initial centroid coordinates to the rotation center coordinates, calculate the direction angle of this vector relative to the preset coordinate system reference axis, and use this direction angle as the first angle value. The direction angle of the vector can be calculated using the arctangent function, and the first angle value can be expressed in radians.
[0076] In one embodiment, based on the mechanical model of the flip camera, a fixed angle compensation value is applied to the first angle value to correct the angle offset caused by the physical connection between the camera's center of mass and the rotation center, so that the first angle value can accurately reflect the physical flip angle of the camera.
[0077] Based on the centroid coordinates and rotation center coordinates of the i-th frame, a second angle value between the centroid and rotation center of the i-th frame is determined. For example, a vector pointing from the centroid coordinates of the i-th frame to the rotation center coordinates is calculated, and the direction angle of this vector relative to a preset coordinate system reference axis is calculated. This direction angle is used as the second angle value. The calculation of the second angle value is performed in real-time in each video frame to form a series of continuous second angle values. The direction angle of the vector can be calculated using the arctangent function.
[0078] In one embodiment, the second angle value sequence is filtered in real time using a first-order low-pass filter or a moving average filter to suppress high-frequency angle noise caused by fluctuations in centroid coordinate calculation. Furthermore, when calculating the second angle value, if the magnitude of the detected vector is less than a preset minimum effective length threshold, the centroid detection for that frame is deemed unreliable, and the second angle value calculation result for that frame is discarded.
[0079] Calculate the angle difference between the first angle value and the second angle value, and determine the angle difference as the flip angle of the flip camera in the i-th frame.
[0080] In one embodiment, such as Figure 4 As shown, based on the changes during the flipping process, effective motion frames can be selected through preprocessing, and then based on the rotation center point... Initial centroid , No. Position of frame centroid The angle change during the motion process is calculated in real time: Calculate the angle between the initial centroid and the center of rotation. : ; Calculate the first step during the motion Angle value between frame and rotation center point : ; When the movement reaches the... The rotation angle (i.e., flip angle) of the camera at each frame. : .
[0081] This invention successfully transforms absolute angle measurement into relative displacement detection by introducing a first angle value as an initial reference and comparing it with a subsequent second angle value using differential comparison. This method not only effectively eliminates systematic errors caused by the camera's installation position and angle, but also ensures that the measurement results directly reflect the true rotation amplitude of the flip camera relative to its initial position. This guarantees the accuracy, consistency, and anti-interference capability of the angle detection data in complex real-world application environments.
[0082] Based on the above embodiments, determining the centroid coordinates of the effective contour in multiple video frames includes: If multiple valid contours exist, the valid contour with the largest area is selected as the target valid contour. For each video frame, extract the set of boundary pixels of the effective contour of the target; Based on the coordinates of the boundary pixel set, the geometric center of the effective contour of the target is calculated, and the geometric center is used as the centroid coordinates.
[0083] If multiple valid contours are selected, the contour areas of all valid contours are calculated and compared. The contour with the largest area is selected and designated as the target valid contour for subsequent angle calculations and motion analysis. If two or more valid contours have the same maximum area, their fill rates are calculated, and the valid contour with the highest fill rate is selected as the target valid contour.
[0084] In one embodiment, after determining the effective contour of the target, it is determined whether the contour area of the effective contour of the target is within a reasonable area range estimated based on the physical size of the flip camera and the camera distance; if the contour area exceeds the upper limit of the reasonable area range, the detection is determined to be unreliable and the detection result of the current frame is discarded.
[0085] In one embodiment, if multiple valid contours exist, the Euclidean distance between the centroid of each valid contour and a preset rotation center point is calculated, and the valid contour with the smallest distance is selected as the target valid contour. Alternatively, based on a contour tracking algorithm, the valid contour with the maximum overlap with the target valid contour of the previous frame is selected as the target valid contour of the current frame. Alternatively, the valid contour with the highest comprehensive score is selected as the target valid contour; the comprehensive score is calculated by weighting at least two parameters among the contour's area, roundness, and fill rate.
[0086] For each video frame, the set of boundary pixels of the target's effective contour is extracted. For example, a boundary tracing algorithm is used to sequentially search and record the coordinates of pixels that constitute the outer boundary of the target's effective contour in the binary image, forming an ordered sequence of boundary pixels. Specifically, the binary image is scanned to find the first boundary pixel belonging to the target's effective contour, and this point is used as the starting point for boundary tracing. Starting from the starting point, its pixel neighborhood is checked according to a preset search direction to find the next pixel belonging to the same contour boundary; the coordinates of the found pixel are recorded in the boundary point sequence, and this new point is used as the current point to repeat the above neighborhood search process; when the tracing process returns to the starting point again, and the next tracing point is the same as the second point in the sequence, the tracing is terminated, forming a closed, ordered sequence of boundary pixels.
[0087] Based on the coordinates of the boundary pixel set, calculate the geometric center of the effective contour of the target and use the geometric center as the centroid coordinates. For example, take the arithmetic mean of the x-coordinates of all pixels in the boundary pixel set to obtain the x-coordinate of the centroid; take the arithmetic mean of the y-coordinates of all pixels in the boundary pixel set to obtain the y-coordinate of the centroid.
[0088] This invention employs the principle of maximizing area to identify the most probable target contour. Based on this, it calculates the geometric center using a set of contour boundary points as the centroid, forming a stable and reliable target localization and tracking mechanism. This strategy effectively eliminates interference from multiple candidate contours, ensuring the uniqueness of the motion-tracked object. Furthermore, the geometric center calculated based on a complete set of boundary points is more stable than other feature points and less sensitive to local contour deformation and noise. This provides high-precision centroid coordinate data for subsequent angle calculations, ultimately guaranteeing the accuracy and reliability of the flip angle detection results.
[0089] Based on the above embodiments, detecting at least one motion contour corresponding to the flip camera from the video stream of the device under test including the flip camera includes: The difference between the video frames in the video stream and the reference frame is calculated to obtain a difference image. The difference image is binarized to distinguish between moving areas and static backgrounds; Morphological optimization is performed on the binary image after binarization to optimize the contour of the motion region; the morphological optimization includes opening and closing operations, the opening operation is used to eliminate noise in the binary image, and the closing operation is used to fill the holes inside the motion region; From the optimized binary image, detect at least one motion contour corresponding to the flip camera.
[0090] The reference frame is the first frame in the video stream before the flip camera begins to move. Specifically, the reference frame refers to the first video image captured when the detection system has completed initialization and the device under test is in a stable initial state (i.e., the flip camera is not moving and the ambient lighting is stable).
[0091] In one embodiment, the reference frame can also be obtained by averaging multiple consecutive frames of images before the flip camera begins to move.
[0092] In one embodiment, after detecting that the flip camera has stopped moving and remained stationary for more than a preset time, the current frame is updated to a new reference frame. For example, when the area of the motion region detected based on the difference image is lower than a set threshold for several consecutive video frames, it is determined that the flip camera has stopped moving; then a timer is started, and if it maintains this stationary state for more than a preset stabilization time threshold, a reference frame update is triggered. After the update is triggered, multiple consecutive frames of images immediately following the stabilization time threshold are acquired, and they are processed by grayscale conversion, Gaussian blurring, and averaging to generate a new reference frame. The new reference frame replaces the original reference frame and is used for frame difference calculation in subsequent video streams.
[0093] A difference image is a new image obtained by calculating the frame difference between the current video frame and the reference frame. Each pixel value in this image represents the degree of difference between the current scene and the reference background.
[0094] The absolute difference between the pixel values of the current frame and the reference frame is calculated pixel by pixel to generate an initial difference image. This initial difference image is then Gaussian blurred to suppress image noise, resulting in the final difference image. For example, from the beginning of a video stream sequence, one or more frames are acquired when the flip camera is in a stationary, retracted state. These frames are then grayscaled and Gaussian blurred, and the average value is used to generate the reference frame. For each subsequent frame in the video stream, feature point matching and perspective transformation are performed between it and the reference frame to eliminate overall displacement caused by slight camera shake. The aligned current frame is then similarly grayscaled and Gaussian blurred. Finally, the absolute difference between each pixel in the pre-processed and aligned current frame and the reference frame is calculated. The calculation formula is: ; in, These are the pixel values of each point in the current frame. These are the pixel values of each point in the reference frame.
[0095] Binarization is performed on the difference image. For example, using Otsu's method or a Gaussian weighted average method based on local pixel neighborhood, an adaptive threshold (grayscale threshold) is calculated to distinguish the foreground from the background. The grayscale value of each pixel in the difference image is compared with the adaptive threshold. Regions with grayscale values greater than or equal to the adaptive threshold are set to a first value (e.g., 255), and regions with grayscale values less than the adaptive threshold are set to a second value (e.g., 0), thus generating a binary image. The pixel region with a value of 255 is initially defined as the motion region.
[0096] It should be understood that the purpose of binarizing the difference image is to convert the gray-level difference image containing gradient information into a binary image that is either black or white by using a preset gray-level threshold, thereby clearly segmenting the blurred change area into a clear moving target and a stationary background.
[0097] Morphological optimization is performed on the binarized image. For example, a structuring element with a predefined shape and size is selected for the morphological operation. This structuring element can be a rectangle, cross, or ellipse with a size of 3×3 or 5×5. The specific shape and size of the structuring element can be selected based on the estimated size of the motion region and the noise size in the image from the flipped camera. A dilation operation is performed on the binary image to expand the boundary of the white motion region, thereby bridging narrow breaks and filling internal holes smaller than the structuring element. Then, an erosion operation is performed on the dilated image to roughly restore the boundary of the region to its original position, but the previously existing internal holes have been filled. The sequence of dilation followed by erosion is the closing operation. After the closing operation, an erosion operation is performed on the image to shrink the boundary of the white motion region, thereby eliminating isolated noise points and smoothing irregular edges. Then, a dilation operation is performed on the eroded image to roughly restore the remaining main region to its original size. The sequence of erosion followed by dilation is the opening operation.
[0098] It should be understood that opening operations can effectively eliminate small-area noise generated after binarization, improving the cleanliness of motion detection. For example, erosion operations using a 3×3 elliptical kernel can remove isolated noise points with an area of less than 9 pixels. Closing operations can fill small holes inside moving targets, obtaining a more complete contour of the moving target. For example, dilation operations using a 5×5 elliptical kernel can connect disconnected regions.
[0099] From the optimized binary image, at least one motion contour corresponding to the flipping camera is detected. For example, a boundary tracking algorithm is used to scan the morphologically optimized binary image, find all connected closed boundaries composed of white pixels, and each closed boundary is a candidate motion contour. The coordinate sequence of its boundary pixels is obtained. While searching for contours, a hierarchical relationship between contours is established to distinguish between outer and inner contours. All inner contours are ignored, and only the outermost contour is retained to eliminate interfering contours caused by tiny holes remaining inside the motion region. Based on the geometric features of the contours, the found outer contours are initially screened. The geometric features include at least the contour area. Contours with an area smaller than a preset minimum effective area threshold are directly filtered out, and finally, the motion contour corresponding to the flipping camera is obtained.
[0100] This invention uses frame difference method to accurately separate moving targets from static backgrounds, and uses binarization to clearly segment moving regions. Combined with morphological optimization of opening and closing operations, it effectively suppresses noise interference and ensures the integrity and connectivity of motion contours. Thus, it can stably and reliably extract motion contours corresponding to flipping cameras from complex video streams, providing high-quality, low-noise input data for subsequent contour filtering and angle calculation.
[0101] The angle detection device for a device flip camera provided by the present invention is described below. The angle detection device for a device flip camera described below and the angle detection method for a device flip camera described above can be referred to in correspondence with each other.
[0102] refer to Figure 5 The device for detecting the angle of a flip camera provided by the present invention includes a motion contour detection module 501, an effective contour determination module 502, and a flip angle detection module 503.
[0103] The motion contour detection module 501 is used to detect at least one motion contour corresponding to the flip camera from the video stream of the device under test, which includes the flip camera. The effective contour determination module 502 is used to filter at least one of the motion contours according to preset contour geometric parameters in order to determine the effective contour of the flip camera. The flip angle detection module 503 is used to detect the flip angle of the flip camera based on the effective contour.
[0104] The device for detecting the angle of a flip camera provided by this invention detects at least one motion contour corresponding to the flip camera from the video stream of the device under test, which includes the flip camera; filters the at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera; and detects the flip angle of the flip camera based on the effective contour. This invention achieves highly robust recognition of the flip camera contour through visual analysis combined with a collaborative filtering mechanism based on contour geometric parameters, thereby enabling high-precision and low-cost detection of the flip angle of the flip camera without relying on external mechanical sensors.
[0105] In one embodiment, the contour geometry parameters include at least one of the contour area, roundness, and fill rate.
[0106] In one embodiment, the effective contour determination module 502 is used for: Calculate the contour area, contour roundness, and contour fill rate for each of the motion contours; Based on the contour area, contour roundness and contour fill rate of each of the motion contours, a contour that meets the preset conditions is selected from at least one of the motion contours as the effective contour. The preset conditions are that the contour area is greater than or equal to a preset area threshold, the contour roundness is within a preset roundness threshold range, and the contour fill rate is greater than or equal to a preset fill rate threshold.
[0107] In one embodiment, the effective contour determination module 502 is used for: The area of the contour is obtained by performing discrete integration on the coordinate sequence of the boundary pixels of the motion contour; The circularity of the contour is calculated based on the area of the contour and the perimeter of the moving contour. Calculate the ratio of the area of the contour to the area of the minimum bounding rectangle of the motion contour, and use the ratio as the contour fill rate.
[0108] In one embodiment, the flip angle detection module 503 is used for: Determine the centroid coordinates of the effective contour in multiple video frames; The flip angle of the flip camera is determined based on multiple centroid coordinates and pre-calibrated rotation center point coordinates.
[0109] In one embodiment, the flip angle detection module 503 is used for: Based on the coordinates of the initial centroid and the coordinates of the rotation center point, determine the first angle value between the initial centroid and the rotation center point; Based on the centroid coordinates of the i-th frame and the rotation center point coordinates, determine the second angle value between the centroid of the i-th frame and the rotation center point; i is an integer greater than 1. Calculate the angle difference between the first angle value and the second angle value, and determine the angle difference as the flip angle of the flip camera in the i-th frame.
[0110] In one embodiment, the flip angle detection module 503 is used for: If multiple valid contours exist, the valid contour with the largest area is selected as the target valid contour. For each video frame, extract the set of boundary pixels of the effective contour of the target; Based on the coordinates of the boundary pixel set, the geometric center of the effective contour of the target is calculated, and the geometric center is used as the centroid coordinates.
[0111] In one embodiment, the motion contour detection module 501 is used for: The difference between the video frames in the video stream and the reference frame is calculated to obtain a difference image; the reference frame is the first frame in the video stream before the flip camera starts moving. The difference image is binarized to distinguish between moving areas and static backgrounds; Morphological optimization is performed on the binary image after binarization to optimize the contour of the motion region; the morphological optimization includes opening and closing operations, the opening operation is used to eliminate noise in the binary image, and the closing operation is used to fill the holes inside the motion region; From the optimized binary image, detect at least one motion contour corresponding to the flip camera.
[0112] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, communications interface 620, and memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a method for detecting the angle of a flip camera. This method includes: detecting at least one motion contour corresponding to the flip camera from a video stream of the device under test containing the flip camera; filtering the at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera; and detecting the flip angle of the flip camera based on the effective contour.
[0113] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0114] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the device flip camera angle detection method provided by the above methods. The method includes: detecting at least one motion contour corresponding to the flip camera from a video stream of a device under test containing the flip camera; filtering the at least one motion contour according to preset contour geometric parameters to determine the effective contour of the flip camera; and detecting the flip angle of the flip camera according to the effective contour.
[0115] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements a device flip camera angle detection method provided by the methods described above. The method includes: detecting at least one motion contour corresponding to the flip camera from a video stream of a device under test containing the flip camera; filtering the at least one motion contour according to preset contour geometric parameters to determine a valid contour of the flip camera; and detecting the flip angle of the flip camera according to the valid contour.
[0116] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0117] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting the angle of a device flipping a camera, characterized in that, include: Detect at least one motion profile corresponding to the flip camera from the video stream of the device under test containing the flip camera; Based on preset contour geometry parameters, at least one of the motion contours is filtered to determine the effective contour of the flip camera; The flip angle of the flip camera is detected based on the effective contour.
2. The method for detecting the angle of a flip camera according to claim 1, characterized in that, The contour geometry parameters include at least one of the contour area, roundness, and fill rate.
3. The method for detecting the angle of a flip camera according to claim 2, characterized in that, The step of filtering at least one motion contour according to preset contour geometry parameters to determine the effective contour of the flip camera includes: Calculate the contour area, contour roundness, and contour fill rate for each of the motion contours; Based on the contour area, contour roundness and contour fill rate of each of the motion contours, a contour that meets the preset conditions is selected from at least one of the motion contours as the effective contour. The preset conditions are that the contour area is greater than or equal to a preset area threshold, the contour roundness is within a preset roundness threshold range, and the contour fill rate is greater than or equal to a preset fill rate threshold.
4. The method for detecting the angle of a flip camera according to claim 3, characterized in that, The calculation of the contour area, contour roundness, and contour fill rate of each motion contour includes: The area of the contour is obtained by performing discrete integration on the coordinate sequence of the boundary pixels of the motion contour; The circularity of the contour is calculated based on the area of the contour and the perimeter of the moving contour. Calculate the ratio of the area of the contour to the area of the minimum bounding rectangle of the motion contour, and use the ratio as the contour fill rate.
5. The method for detecting the angle of a flip camera according to claim 1, characterized in that, The step of detecting the flip angle of the flip camera based on the effective contour includes: Determine the centroid coordinates of the effective contour in multiple video frames; The flip angle of the flip camera is determined based on multiple centroid coordinates and pre-calibrated rotation center point coordinates.
6. The method for detecting the angle of a flip camera according to claim 5, characterized in that, Determining the flip angle of the flip camera based on multiple centroid coordinates and pre-calibrated rotation center point coordinates includes: Based on the coordinates of the initial centroid and the coordinates of the rotation center point, determine the first angle value between the initial centroid and the rotation center point; Based on the centroid coordinates of the i-th frame and the rotation center point coordinates, determine the second angle value between the centroid of the i-th frame and the rotation center point; i is an integer greater than 1. Calculate the angle difference between the first angle value and the second angle value, and determine the angle difference as the flip angle of the flip camera in the i-th frame.
7. The method for detecting the angle of a flip camera according to claim 5, characterized in that, Determining the centroid coordinates of the effective contour in multiple video frames includes: If multiple valid contours exist, the valid contour with the largest area is selected as the target valid contour. For each video frame, extract the set of boundary pixels of the effective contour of the target; Based on the coordinates of the boundary pixel set, the geometric center of the effective contour of the target is calculated, and the geometric center is used as the centroid coordinates.
8. The method for detecting the angle of a flip camera according to claim 1, characterized in that, Detecting at least one motion contour corresponding to the flip camera from the video stream of the device under test, which includes the flip camera, includes: The difference between the video frames in the video stream and the reference frame is calculated to obtain a difference image; the reference frame is the first frame in the video stream before the flip camera starts moving. The difference image is binarized to distinguish between moving areas and static backgrounds; Morphological optimization is performed on the binary image after binarization to optimize the contour of the motion region; the morphological optimization includes opening and closing operations, the opening operation is used to eliminate noise in the binary image, and the closing operation is used to fill the holes inside the motion region; From the optimized binary image, detect at least one motion contour corresponding to the flip camera.
9. An angle detection device for a flip camera, characterized in that, include: A motion contour detection module is used to detect at least one motion contour corresponding to the flip camera from a video stream of a device under test containing a flip camera. An effective contour determination module is used to filter at least one of the motion contours according to preset contour geometric parameters in order to determine the effective contour of the flip camera. A flip angle detection module is used to detect the flip angle of the flip camera based on the effective contour.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the device flip camera angle detection method as described in any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the device flip camera angle detection method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Portable detection device and detection method for surface quality of continuous casting billet finished product
CN112255243A
Camera shielding detection method and device, camera equipment and storage medium
CN116249015A
Red date defect identification method and system based on machine vision
CN120971435A
Digital video filter and image processing
WO2010027348A1
External environment recognition device
WO2020110435A1