A performance detection method for a reflective photoelectric switch of a camera
Patent Information
- Application Number
- CN202611210246.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-10-16
AI Technical Summary
[0004]然而,随着摄影机性能的不断提升,特别是高速工业相机和高端旗舰机型在快门延迟、自动对焦速度及视频帧率等方面的严苛要求,上述传统检测方法逐渐暴露出局限性
1、通过构建高精度时间基准与多模态同步采集模型,将反射式光电开关的触发信号与数据采集卡统一时钟域下的开关信号、电机位置信号及视频流同步记录,显著提升了多模态数据在微秒级精度上的时间对齐能力,减少了因设备独立计时或触发延迟导致的测量偏差;
Smart Images

Figure CN122933889A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of performance testing, and in particular to a performance testing method for a reflective photoelectric switch used in a camera. Background Technology
[0002] With the development of film and television production, security monitoring, and industrial visual inspection, the performance indicators of cameras, including digital cameras, mirrorless cameras, and industrial cameras, such as shutter lag, autofocus speed, video frame rate stability, and image stabilization effectiveness, have become key parameters for measuring equipment quality. Reflective photoelectric switches, as a type of non-contact sensor, work by integrating the emitter and receiver into the same housing. They output a switching signal by detecting changes in the intensity of light reflected from the object being tested. Due to their fast response speed, compact installation space, and ease of integration with test benches, they have been widely used as high-precision external trigger references and time anchors in camera performance testing systems.
[0003] Currently, there are mature solutions in the industry for using reflective photoelectric switches to test camera performance. A typical testing method involves fixing the reflective photoelectric switch to a test platform, aligning its optical axis with a movable test target (such as a high-reflectivity white card or focus map). When the test target, driven by a motor or electromagnetic actuator, suddenly enters the camera's field of view, the photoelectric switch detects the sudden change in reflected light intensity and outputs a rising edge signal. This signal is recorded as a zero-point time by a high-speed acquisition card or oscilloscope. Simultaneously, the camera is triggered by this signal to take a picture or begin recording. The captured footage typically includes an independent, externally driven millisecond-level timer. By manually reviewing the recording afterward and reading the timer's display, the camera's shutter delay can be calculated.
[0004] However, with the continuous improvement of camera performance, especially the stringent requirements of high-speed industrial cameras and high-end flagship models in terms of shutter lag, autofocus speed, and video frame rate, the aforementioned traditional testing methods have gradually revealed their limitations. On the one hand, the response bandwidth of ordinary reflective photoelectric switches is limited, making it difficult to accurately capture the shutter trigger moment at the microsecond level; on the other hand, the data processing method that relies on manually playing back the video and reading the timer in the frame is not only inefficient and prone to introducing human error, but also cannot quantitatively evaluate complex dynamic performance such as continuous contrast changes during autofocus and frame-by-frame jitter in video frame rate. Summary of the Invention
[0005] To enable fully automatic and high-precision testing of camera shutter lag, autofocus speed, video frame rate, and image stabilization performance, this application provides a performance testing method for a reflective photoelectric switch used in a camera.
[0006] The above-mentioned objective of this application is achieved through the following technical solution: A performance testing method for a reflective photoelectric switch used in a camera, the method comprising: A high-precision time base and multimodal acquisition model are constructed. The camera is triggered by the output signal of a reflective photoelectric switch, and the switch signal, motor position signal and video stream are recorded synchronously with the data acquisition card. Based on inter-frame difference and gradient analysis, the target appearance frames and focus frames are detected from the video stream, and the shutter delay and autofocus time are calculated. Based on the true frequency reference of high-frequency rotary encoder disk and reflective photoelectric switch, the video frame rate jitter and rolling shutter distortion are analyzed frame by frame. By integrating the displacement truth values of the inertial measurement unit and the reflective photoelectric switch, the camera's image stabilization performance is triangulated.
[0007] Preferably, the construction of the high-precision time base and multimodal acquisition model specifically includes: Connect the output signal of the reflective photoelectric switch to both the external trigger interface of the camera and the digital input channel of the data acquisition card. The data acquisition card synchronously acquires the switch signals, linear motor position encoder signals, and video stream output by the camera, and generates multi-data packets with timestamps under a unified clock domain.
[0008] Preferably, the generation of timestamped multi-source data packets under a unified clock domain specifically includes: The rising edge time of the switch signal is obtained from the data acquisition card and used as the hardware time zero point; The position data of the position encoder at each sampling point is acquired and time-aligned with the hardware time zero point to obtain the target displacement trajectory. Each frame of the video stream is associated with the nearest hardware time zero point to generate a frame-time mapping table for subsequent frame location.
[0009] Preferably, the step of detecting target appearance frames and focus frames from the video stream based on inter-frame difference and gradient analysis specifically includes: An adaptive inter-frame difference method is used, with a preset multiple of the standard deviation of the average difference of the preset number of frames in the past as a dynamic threshold, to locate the first frame in which the target appears, and record it as the target appearance frame; In the continuous frame sequence following the appearance of the target, the Laplacian variance operator is applied to calculate the sharpness evaluation value of the target region, generate a focus curve, and determine the frame corresponding to the peak of the focus curve as the in-focus frame.
[0010] Preferably, the step of employing an adaptive inter-frame difference method, using a preset multiple of the standard deviation of the average difference of a preset number of past frames as a dynamic threshold, to locate the frame in which the target first appears, specifically includes: The grayscale difference map between the current frame and the previous frame is calculated frame by frame from the video stream to obtain the difference pixel matrix; The number of pixels in the differential pixel matrix whose brightness values exceed a preset baseline is counted. When the number of pixels is greater than the dynamic threshold, the current frame is marked as the target occurrence frame.
[0011] Preferably, the step of analyzing video frame rate jitter and rolling shutter distortion frame by frame based on the true frequency reference of a high-frequency rotating encoder disk and a reflective photoelectric switch specifically includes: The periodic reflection changes of the rotating encoder disk are monitored by a mirror-reflective photoelectric switch, and a square wave signal that is strictly synchronized with the rotation frequency is generated as the true frequency. The brightness and phase changes of the encoded disk image in the video are analyzed frame by frame to generate a measured frequency sequence; Frame rate jitter is detected by comparing the instantaneous deviation between the measured frequency sequence and the true frequency, and the shutter exposure time difference is inferred from the phase offset of pixels in different rows within a single frame.
[0012] Preferably, the step of analyzing the brightness and phase changes of the encoded disk image in the frame-by-frame recording to generate a measured frequency sequence specifically includes: Extract the gray value sequence of the region where the encoding disk is located in each frame of the image, and perform a fast Fourier transform on the gray value sequence to obtain the main frequency component; The dominant frequency component is taken as the corresponding measured frequency and compared with the true frequency to obtain the frequency deviation value; The frequency deviation values of all frames are arranged in chronological order to form the measured frequency sequence.
[0013] Preferably, the true displacement values of the fusion inertial measurement unit and the reflective photoelectric switch are used to triangulate the camera's image stabilization performance, specifically including: The actual displacement trajectory is obtained by integrating the acceleration and angular velocity output by the inertial measurement unit fixed on the vibration table surface twice. The absolute displacement of the target on the vibration table is measured by using a reflective photoelectric switch fixed outside the vibration table, and the switch displacement trajectory is obtained. The image stabilization compensation displacement trajectory output by the camera is time-aligned with the actual displacement trajectory and the switch displacement trajectory. The residual between the image stabilization compensation displacement trajectory and the actual displacement trajectory is calculated. The image stabilization performance is then determined to be qualified based on the correlation coefficient between the image stabilization compensation displacement trajectory and the switch displacement trajectory.
[0014] In summary, this application includes at least one of the following beneficial technical effects: 1. By constructing a high-precision time reference and a multi-modal synchronous acquisition model, the trigger signal of the reflective photoelectric switch is synchronously recorded with the switch signal, motor position signal and video stream under the unified clock domain of the data acquisition card. This significantly improves the time alignment capability of multi-modal data at the microsecond level and reduces measurement deviations caused by independent timing or trigger delay of the equipment. 2. An automated image analysis method based on inter-frame difference and Laplacian variance operator is adopted to autonomously locate the target appearance frame and focus frame from the video stream, realizing the objective calculation of shutter delay and autofocus time consumption. This replaces the traditional manual playback video interpretation method, greatly improving detection efficiency and eliminating human interpretation errors. 3. By integrating the true frequency reference of the high-frequency rotating encoder disk and the reflective photoelectric switch, and the dual displacement true value of the inertial measurement unit and the photoelectric switch, the quantitative evaluation and triangulation of video frame rate jitter, rolling shutter distortion and image stabilization performance are realized simultaneously in the same detection process, and a comprehensive detection system covering time response, focus speed, frame rate stability and image stabilization effectiveness is constructed. Attached Figure Description
[0015] Figure 1 This is a flowchart of a performance testing method for a reflective photoelectric switch for a camera according to one embodiment of this application; Detailed Implementation The present application will be further described in detail below with reference to the accompanying drawings.
[0016] In one embodiment, such as Figure 1 As shown, this application discloses a performance testing method for a reflective photoelectric switch used in a camera, specifically including the following steps: S10: Construct a high-precision time base and multi-modal acquisition model, trigger the camera through the output signal of the reflective photoelectric switch, and synchronously record the switch signal, motor position signal and video stream with the data acquisition card.
[0017] In this embodiment, a high-precision time reference refers to a unified time coordinate system established with microsecond-level precision, used to ensure that data collected by different sensors can be aligned under the same time reference system. The multimodal acquisition model refers to an acquisition architecture that integrates three heterogeneous data sources—the switching signals of a reflective photoelectric switch, the position encoder signals of a linear motor, and the video stream output by a camera—into a structured data set through hardware synchronization.
[0018] Specifically, during camera performance testing, the camera under test is first fixed on a test platform, and a test target driven by a linear motor is placed in front of its lens. The target's surface is made of a white diffuse-reflective material with high reflectivity. On the same plane next to the target, a reflective photoelectric switch is installed, with its optical axis aligned with the target surface. This reflective photoelectric switch is a high-speed model with a response time better than 1 microsecond to ensure accurate capture of the target's movement. The output signal of this high-speed reflective photoelectric switch is split into two paths: one path is directly connected to the camera's general-purpose input / output external trigger interface to trigger the camera to start exposure or recording; the other path is connected to the digital input channel of a high-precision data acquisition card with a sampling rate of at least 1 megapixel per second. Simultaneously, the data acquisition card also synchronously acquires the position encoder signal of the linear motor to record the precise displacement data of the target during its movement. Furthermore, the camera outputs a real-time video stream to the data acquisition card or a connected industrial control computer via a high-definition multimedia interface or a mobile industrial processor interface. All signals are tagged within the data acquisition card using a unified clock domain, generating multi-data packets containing timestamps, switch states, motor positions, and video frames, which are then stored in the industrial computer's memory. In this way, when the linear motor-driven target suddenly enters the camera's field of view, the reflective photoelectric switch detects the sudden change in reflected light intensity and outputs a rising edge signal. This signal simultaneously triggers the camera to start operating and the data acquisition card to record at zero time, ensuring strict synchronization between the triggering event and data recording. This establishes a reliable time reference for the subsequent accurate measurement of various performance parameters.
[0019] S20: Based on inter-frame difference and gradient analysis, detect target appearance frames and focus frames from the video stream, and calculate shutter delay and autofocus time.
[0020] In this embodiment, inter-frame difference refers to a technique for detecting image changes by calculating the grayscale difference between two adjacent frames in a video stream. Gradient analysis refers to a method for calculating image sharpness evaluation values using image gradient operators. The target appearance frame refers to the frame in which the target first appears in the camera's field of view, and the focus frame refers to the frame in which the image is sharpest after the camera has completed autofocus.
[0021] Specifically, after completing multimodal data acquisition, the industrial control computer extracts video stream data from the stored multi-data packets and starts an automated image analysis program. First, the algorithm uses an adaptive inter-frame difference method to locate the target's appearance frame. Specifically, it calculates the grayscale difference image between the current frame and the previous frame frame by frame, obtaining a difference pixel matrix, and then counts the number of pixels in this matrix whose brightness values exceed a preset baseline. This dynamic threshold is set to three times the standard deviation of the average difference value of the past 100 frames. When the number of significantly changed pixels exceeds this dynamic threshold, the current frame is determined to be the first frame in which the target appears, and is recorded as the target appearance frame. Subsequently, the hardware time zero point corresponding to the timestamp of this frame is obtained from the data acquisition card, and the difference between the two yields the camera's shutter delay time. After locating the target appearance frame, the algorithm continues to analyze the target's region in subsequent consecutive frame sequences. Specifically, it applies the Laplacian variance operator to calculate the sharpness evaluation value of the target region in each frame. The Laplacian variance operator detects edge strength by performing second-order differential operations on the image; the sharper the edge, the higher the evaluation value. These evaluation values are plotted as a curve in frame order, forming the focus curve. The frame corresponding to the peak point of this curve is the in-focus frame, indicating that the camera completed autofocus at that moment. Subtracting the timestamp of the in-focus frame from the timestamp of the target appearance frame yields the autofocus time. This completely replaces traditional manual playback of video and visual interpretation, significantly improving detection efficiency and ensuring the objectivity and repeatability of the measurement results through mathematical calculations.
[0022] S30: Based on the true frequency reference of a high-frequency rotating encoder disk and a reflective photoelectric switch, it analyzes video frame rate jitter and rolling shutter distortion frame by frame.
[0023] In this embodiment, the high-frequency rotating encoder disk refers to a disk with alternating light and dark radial stripes printed on its surface, driven by a servo motor to rotate at a constant high speed. The true frequency reference refers to a standard frequency signal extracted from the encoder disk's rotation by a reflective photoelectric switch, which is strictly synchronized with the mechanical rotation frequency. Video frame rate jitter refers to the instantaneous fluctuation where the actual recorded frame rate deviates from the nominal frame rate. Rolling shutter distortion refers to the phenomenon where moving objects appear tilted or distorted in the frame due to the line-by-line exposure characteristics of a rolling shutter.
[0024] Specifically, after testing shutter lag and autofocus time, the test station is switched or the camera is aimed at another test device. The core of this device is a rotating encoder disk driven by a high-precision servo motor. The disk surface is printed with alternating black and white radial stripes, the stripe density designed so that the frequency of brightness changes during rotation is 100 Hz. A specular reflective photoelectric switch is fixed to one side of the encoder disk, its optical axis aligned with a fixed fan-shaped area on the disk surface. As the encoder disk rotates, the reflectivity of this area changes periodically with the alternation of black and white stripes. The specular reflective photoelectric switch outputs a square wave signal strictly synchronized with the rotation frequency, which is recorded by the data acquisition card as the true frequency. Simultaneously, the camera records the rotating encoder disk, generating a video stream containing the encoder disk image. In the post-processing stage, the algorithm analyzes the image of the area containing the encoder disk frame by frame. For each frame, the grayscale value sequence of the encoder disk area is extracted, and then a Fast Fourier Transform is performed on the sequence to obtain the dominant frequency component of that frame as the measured frequency. The measured frequency is compared with the true frequency, and the instantaneous deviation between the two is calculated. The deviation values of all frames are arranged chronologically to form a measured frequency sequence. By observing the fluctuations in this sequence, frame rate jitter during camera recording can be detected. Furthermore, the algorithm analyzes pixels in different rows within a single frame. Because the rolling shutter exposes line by line, pixels in different rows of the same frame are actually captured at different times. Therefore, bright and dark stripes at the same position on the encoder disk will exhibit phase shifts across different rows. By measuring the relationship between this phase shift and the number of rows, the exposure time difference required for line-by-line scanning by the rolling shutter can be deduced, thereby quantitatively evaluating the sensor's readout speed characteristics. Integrating frame rate stability and sensor readout characteristics into the same testing process improves detection efficiency and information richness.
[0025] S40: Combines the true displacement values of the inertial measurement unit and the reflective photoelectric switch to perform triangulation verification of the camera's image stabilization performance.
[0026] In this embodiment, the inertial measurement unit (IMU) refers to a sensor module integrating an accelerometer and a gyroscope, used to measure the acceleration and angular velocity of an object. The true displacement value refers to displacement data obtained through physical measurement methods independent of the camera, reflecting the actual motion state of the shaking table. Triangulation is an evaluation method that uses three independent data sources (IMU, reflective photoelectric switch, and camera output) for cross-validation.
[0027] Specifically, during image stabilization performance testing, the camera under test is rigidly fixed to a six-degree-of-freedom vibration table, which can move along a preset trajectory (such as sinusoidal frequency sweep or random vibration). A high-precision inertial measurement unit (IMU) and a high-reflectivity target are simultaneously mounted on the table surface. The IMU outputs real-time acceleration and angular velocity data of the table surface in three axes. These data are recorded by a data acquisition card, and the true displacement trajectory and attitude change trajectory of the table surface are obtained through quadratic integration, serving as the true attitude value. Simultaneously, a mirror-reflective photoelectric switch is fixed outside the vibration table, with its optical axis aligned with the target on the table. When the table moves, the distance between the target and the photoelectric switch changes, causing a change in reflected light intensity. The photoelectric switch outputs a displacement-related signal. By calibrating the correspondence between this signal and displacement, the absolute displacement trajectory of the table in the photoelectric switch's measurement direction can be obtained, serving as the true displacement value. The camera continuously records video during the vibration process, and its built-in electronic or optical image stabilization algorithm outputs an estimated stabilization compensation displacement trajectory based on its gyroscope or image analysis results. In the post-processing stage, the algorithm precisely aligns the three trajectories (the actual displacement trajectory of the inertial measurement unit, the switching displacement trajectory of the reflective photoelectric switch, and the camera's image stabilization compensation displacement trajectory) on the time axis. Then, it calculates the residual between the image stabilization compensation displacement trajectory and the actual displacement trajectory; the magnitude of the residual reflects the motion components that the image stabilization algorithm failed to fully compensate for. Simultaneously, it calculates the correlation coefficient between the image stabilization compensation trajectory and the switching displacement trajectory to determine whether the direction of image stabilization compensation is correct. If the two are negatively correlated, it indicates that the direction of image stabilization compensation is opposite to the direction of vibration, which is as expected; if they are positively correlated, it indicates that image stabilization compensation has actually exacerbated the shaking. Through a comprehensive evaluation of these two indicators, an objective and comprehensive judgment can be made on the camera's image stabilization performance. By introducing two independent truth measurement sources, a triangulation mechanism is constructed, improving the reliability and credibility of the image stabilization performance evaluation.
[0028] In this embodiment, by constructing a high-precision time reference and a multi-modal acquisition model, the output signal of the reflective photoelectric switch is simultaneously used to trigger the camera and the data acquisition card. This allows the switch signal, motor position signal, and video stream to be recorded in a unified time coordinate system, improving the time alignment accuracy between different modal data and reducing measurement deviations caused by clock asynchrony. An automated detection method based on inter-frame difference and gradient analysis automatically locates the target appearance frame and the focus frame in the video stream, thereby calculating the shutter delay and autofocus time, improving detection efficiency and reducing human interpretation errors. By using a true frequency reference generated by a high-frequency rotating encoder disk and the reflective photoelectric switch, the instantaneous jitter of the video frame rate is analyzed frame by frame. The exposure time difference of the rolling shutter is deduced based on the phase offset of pixels in different rows within a single frame, achieving a quantitative evaluation of frame rate stability and sensor readout characteristics. By fusing the true displacement values provided by the inertial measurement unit and the reflective photoelectric switch, the camera's image stabilization performance is triangulated. This cross-validation of the stabilization algorithm's actual compensation effect from multiple independent measurement sources reduces the potential bias associated with relying solely on internal camera data. Overall, this method simultaneously covers performance evaluation across four dimensions—time response, focus speed, frame rate distortion, and image stabilization effectiveness—within a single detection process, enhancing the systematic nature and data reliability of the detection.
[0029] In one embodiment, step S10, namely constructing a high-precision time base and multimodal acquisition model, specifically includes: S11: Connect the output signal of the reflective photoelectric switch to both the external trigger interface of the camera and the digital input channel of the data acquisition card.
[0030] In this embodiment, connecting the output signal of the reflective photoelectric switch to both the external trigger interface of the camera and the digital input channel of the data acquisition card means that through the branching design of the physical circuit, the same switch signal can drive two different receiving ends in parallel, thereby achieving synchronous start of triggering and recording.
[0031] Specifically, during the test bench setup phase, a high-speed reflective photoelectric switch with a response time better than 1 microsecond was selected, and its signal output pin was led out through a BNC coaxial cable. A T-type BNC adapter was installed at the end of the cable to split the signal into two paths: one path was connected via a shielded cable to the universal input / output external trigger interface on the side of the camera body. This interface typically supports rising edge trigger mode; when the rising edge of the switch signal is received, the camera immediately begins exposure or recording. The other path was connected via another coaxial cable to any digital input channel of a high-precision data acquisition card, which continuously samples at a rate of no less than 1 mega-samples per second. To ensure signal integrity, the cable lengths of the two branches were kept consistent, and no additional impedance mismatch was introduced at the T-type connector. With this connection method, when the linear motor drives the target into the lens's field of view, the reflective photoelectric switch detects the sudden change in reflected light intensity and outputs a rising edge signal. This signal arrives at the camera and the data acquisition card almost simultaneously, thus ensuring strict synchronization between the trigger event and data recording in time. This parallel connection method eliminates the millisecond-level latency differences that may be introduced by separate triggering in traditional schemes, laying the foundation for subsequent high-precision time measurement.
[0032] S12: Synchronously acquire switch signals, linear motor position encoder signals and video streams output by the camera through the data acquisition card, and generate multi-data packets with timestamps under a unified clock domain.
[0033] In this embodiment, the data acquisition card synchronously acquires switch signals, linear motor position encoder signals, and video streams output by the camera, and generates multi-data packets with timestamps under a unified clock domain. This means incorporating three different types of signals into the same acquisition system and using the high-precision clock inside the acquisition card to assign a unified time tag to each sampling point.
[0034] Specifically, the data acquisition card selects a model with multi-channel synchronous sampling function, such as NI PCIe-6363 or a product of equivalent specification. The output signal of the reflective photoelectric switch is connected to the PFI0 digital input channel of the acquisition card, the position encoder of the linear motor (incremental encoder, outputting A / B / Z three-phase pulses) is connected to the counter / encoder input channel of the acquisition card, and the video stream output by the camera through the HDMI or SDI interface is connected to the frame grabber module matched with the acquisition card or synchronized to the same industrial personal computer through an independent video acquisition card. The main clock frequency inside the acquisition card is 100 megahertz, and the sampling of all channels is synchronously triggered based on this clock. The acquisition program is configured as follows: the digital input channel records the level change of the switch signal at a rate of 1 megasample per second, the counter channel records the cumulative value of the encoder pulses at the same rate so as to convert it into position data, and the frame grabber module records the clock count value at the arrival time of each frame of video data when it arrives. All data are packaged into a data stream in chronological order, and each record contains a timestamp, a data type identifier and a value. Finally, a multi-element data packet is formed in the memory of the industrial personal computer, and the time difference between any two records in the data packet can be accurately calculated through the timestamp, realizing the time alignment of the three heterogeneous data with microsecond-level accuracy.
[0035] In this embodiment, by connecting the output signal of the reflective photoelectric switch to the external trigger interface of the camera and the digital input channel of the data acquisition card at the same time, the same physical event (reflected light change caused by the appearance of the target) can simultaneously trigger the camera to start exposure or recording, and be recorded by the data acquisition card as a time reference signal, thereby eliminating the delay difference of the trigger signal on the transmission path and improving the consistency of the trigger moment. The switch signal, the linear motor position encoder signal and the video stream output by the camera are synchronously collected through the data acquisition card, and a timestamped multi-element data packet is generated in a unified clock domain, which ensures that the three different types of data (digital switch quantity, analog position quantity, video stream) share a common time reference system, reduces the time misalignment problem that may be caused by independent timing of each device, and makes the calculation of the time difference between any two data points in subsequent analysis more reliable. At the same time, the timestamped multi-element data packet structure facilitates quick retrieval and association during subsequent data processing, improving the efficiency of data analysis. In general, by optimizing the signal connection mode and data acquisition architecture, the alignment accuracy of multi-modal data in the time dimension is improved.
[0036] In one embodiment, in step S12, that is, generating a timestamped multi-element data packet in a unified clock domain, specifically includes: S121: Obtain the rising edge moment of the switch signal from the data acquisition card as the hardware time zero point.
[0037] In this embodiment, obtaining the rising edge of the switch signal from the data acquisition card as the hardware time zero point means identifying the instant when the level jumps from low to high from the acquired digital signal waveform and taking the clock count value corresponding to that instant as the time origin of the entire test process.
[0038] Specifically, after the data acquisition card completes one round of synchronous acquisition, the industrial control computer reads the stored multi-data packets and extracts the recording sequence of the digital input channel. This sequence contains a series of timestamps and corresponding level values (0 or 1). The program uses an edge detection algorithm to traverse the sequence and find the moment when the level value jumps from 0 to 1. To improve detection accuracy, the algorithm uses a linear interpolation method: several sampling points are taken before and after the jump, a transition curve is fitted, and the moment corresponding to the midpoint of the curve is accurately calculated as the rising edge moment of the switch signal. This moment is the hardware time zero point, denoted as T0. T0 represents the physical instant when the sudden change in the intensity of the target reflected light is captured by the photoelectric switch, and it is the benchmark for all time measurements in the entire testing process. In subsequent calculations of shutter delay or autofocus time consumption, subtraction is performed with T0 as the reference point. Since T0 is derived directly from hardware recording and has undergone interpolation refinement, its accuracy can reach the sub-microsecond level, which is far higher than the time benchmarks that rely on the camera's internal clock or software triggering in traditional methods. The establishment of this hardware zero point makes time measurement results comparable between different test batches and different camera models, improving the consistency and reliability of the detection.
[0039] S122: Obtain the position data of the position encoder at each sampling point and align it with the hardware time zero point to obtain the target displacement trajectory.
[0040] In this embodiment, the position data of the position encoder at each sampling point is obtained and time-aligned with the hardware time zero point to obtain the target displacement trajectory. This means that the relative position information recorded by the encoder is associated with T0 to form a complete displacement-time curve of the target from rest to movement and then into the field of view.
[0041] Specifically, the counter channel of the data acquisition card continuously records the accumulated pulse value of the encoder during the acquisition process. Since the number of pulses output by the encoder per revolution is proportional to the lead of the linear motor lead screw, the displacement corresponding to each pulse (e.g., 0.01 mm per pulse) can be obtained through calibration. The acquisition program multiplies the accumulated pulse value of each sampling point by a calibration coefficient, converting it into an absolute position value in millimeters. Each position value is also accompanied by a timestamp. After obtaining the hardware time zero point T0, the program subtracts T0 from the timestamps of all position data to obtain the relative time relative to the zero point. These relative times and corresponding position values are plotted as a scatter plot, and spline interpolation is performed to obtain the target's displacement trajectory curve. This curve clearly shows the target's motion state before and after time T0: before T0, the target may be stationary, its position unchanged; near T0, the linear motor begins to accelerate, and the target quickly enters the camera's field of view; after T0, the target continues to move to the predetermined position and then stops. By analyzing this displacement trajectory, it is possible to determine whether the target's entry speed into the field of view is constant and whether there is any camera shake. This information is valuable for evaluating the camera's response performance to dynamic targets. This displacement trajectory is also used in conjunction with a subsequent frame-time mapping table to further analyze the relationship between the camera's shutter opening moment and the target's actual position.
[0042] S123: Associate each frame of the video stream with the nearest hardware time zero point to generate a frame-time mapping table for subsequent frame location.
[0043] In this embodiment, associating each frame of the video stream with the nearest hardware time zero point to generate a frame-time mapping table means assigning a precise time tag to each frame of the video stream, establishing a traceable correspondence between it and the hardware time zero point, which facilitates subsequent frame positioning operations.
[0044] Specifically, when the frame capture module of the data acquisition card receives the video stream output from the camera, it records the clock count value of the arrival time of each complete frame and stores this count value along with the frame sequence number in a multi-data packet. During post-processing, the program iterates through all frame records. For each frame, it calculates the difference between its timestamp and the hardware time zero point T0 to obtain the frame's offset time relative to T0. All frame sequences and offset times are organized into a two-dimensional table, namely the frame-time mapping table. Each row in this table contains the frame sequence number (incrementing from 0) and the corresponding offset time (in microseconds). Because the camera's frame rate may fluctuate slightly, the time interval between adjacent frames is not strictly equal; therefore, this mapping table accurately reflects the actual capture time of each frame. In subsequent steps, when the algorithm locates the target frame or a focused frame through image analysis, it only needs to look up the frame sequence number in the table to obtain the precise time of that frame relative to T0, and then calculate the shutter delay or autofocus time. This lookup table method avoids the hassle of repeatedly calculating frame intervals, and because the timestamps are recorded by hardware, they are not affected by the accuracy of the camera's internal timestamps, thus improving the accuracy of time measurement. The frame-time mapping table can also be used as a reference when detecting frame rate jitter, helping to determine frame rate stability by comparing the time interval between adjacent frames with the nominal frame interval.
[0045] In this embodiment, the rising edge of the switch signal obtained from the data acquisition card is used as the hardware time zero point. This time zero point directly originates from the instant the photoelectric switch detects a change in target reflection, representing the true moment of the physical event and avoiding processing delays that may be introduced by software triggering. By acquiring the position data of the position encoder at each sampling point and aligning it with the hardware time zero point, the target displacement trajectory is obtained. This establishes a precise correspondence between the target's spatial motion and the time axis, reflecting the complete process of the target moving from a stationary state to motion and then entering the lens's field of view. This helps in analyzing the temporal relationship between the camera response and the target's motion. By associating each frame of the video stream with the nearest hardware time zero point, a frame-time mapping table is generated, assigning a precise time label to each frame. This allows subsequent steps to directly obtain the time offset relative to the hardware time zero point when locating the target's appearance frame and focus frame, reducing the uncertainty caused by frame number conversion. By working together these three sub-steps, the three heterogeneous data sources—photoelectric switches, encoders, and video streams—are unified under the same time base, improving the integration of multi-source data in the time dimension and providing structured data support for subsequent automated analysis and parameter calculation.
[0046] In one embodiment, step S20, namely detecting target appearance frames and focus frames from the video stream based on inter-frame difference and gradient analysis, specifically includes: S21: Adaptive inter-frame difference method is adopted, and the standard deviation of the preset multiple of the average difference of the preset number of frames in the past is used as a dynamic threshold to locate the first frame in which the target appears, and record it as the target appearance frame. In this embodiment, an adaptive inter-frame difference method is adopted, using a preset multiple of the standard deviation of the average difference of the preset number of frames in the past as a dynamic threshold to locate the first frame in which the target appears. This means using the grayscale difference between adjacent frames in the video stream to detect sudden changes in the image, and dynamically adjusting the judgment threshold through statistical methods to adapt to the detection needs under different lighting and noise conditions.
[0047] Specifically, after obtaining the video stream and frame-time mapping table, the algorithm processes each frame starting from frame N (N is the preset number of buffer frames, e.g., 100 frames). For the current frame i, it calculates the grayscale difference image between it and the previous frame i-1: converting the two frames into grayscale images, then subtracting them pixel by pixel and taking the absolute value, resulting in a difference pixel matrix of the same size as the image. The value of each element in the matrix represents the grayscale change of that pixel position between the two frames. Then, it counts the number of pixels in the matrix whose brightness value exceeds a preset baseline (e.g., 10 grayscale levels), denoted as C_i. Simultaneously, the algorithm maintains a sliding window of length 100, storing the C values of the most recent 100 frames. After processing each frame, it updates the mean μ and standard deviation σ within the window. The dynamic threshold is set to μ + 3σ. When C_i is greater than this dynamic threshold, the current frame is determined to be the first frame in which the target appears. The principle behind this adaptive mechanism is as follows: before the target appears, image changes are mainly caused by noise and minor vibrations, resulting in a small C-value with minimal fluctuations. Consequently, μ and σ are also small, leading to a low threshold, which is beneficial for detecting subtle changes when the target enters. Once the target appears, the C-value increases significantly. However, because the window contains previous low C-values, μ and σ are pulled up. Even if the C-value of subsequent frames remains high, it may still be below the dynamic threshold, thus avoiding misjudging subsequent frames in the same event as new target appearance frames. This design makes the localization of target appearance frames more accurate and robust.
[0048] S22: In the continuous frame sequence after the target appears, the Laplacian variance operator is applied to calculate the sharpness evaluation value of the target area, generate the focus curve, and determine the frame corresponding to the peak of the focus curve as the in-focus frame.
[0049] In this embodiment, in the continuous frame sequence after the target appears, the Laplacian variance operator is applied to calculate the sharpness evaluation value of the target area, generate a focus curve, and determine the frame corresponding to the peak of the focus curve as the in-focus frame. This means using image gradient information to quantitatively evaluate the sharpness of the image, and determining the moment when autofocus is completed by finding the maximum value of the evaluation value.
[0050] Specifically, after locating the target in frame F_target, the algorithm takes M consecutive frames (M is set empirically, for example, 200 frames, covering the time range within which autofocus may be completed) starting from F_target. For each frame, the target tracking algorithm (such as a mean-shift algorithm based on color histograms or a template-matching algorithm) is first used to determine the target's location region in the current frame, and this region is cropped as the region of interest. Then, the Laplacian variance operator is applied to the region of interest: first, the Laplacian kernel (e.g., a 3x3 kernel [[0,-1,0],[-1,4,-1],[0,-1,0]]) is used to convolve the region image to obtain the Laplacian response map; then, the variance of all pixel values in the response map is calculated, and this variance value is the sharpness evaluation value of the frame. The Laplacian operator is sensitive to edges and textures in the image. When the image is sharp, the edges are sharp, the response value is large, and the variance is large; when the image is blurry, the edges are smooth, the response value is small, and the variance is small. Therefore, the sharpness evaluation value can effectively reflect the degree of focus. Plotting the evaluation value of each frame as a curve according to frame number creates the focus curve. This curve typically exhibits a single-peak shape, rising first and then falling; the frame corresponding to the peak point is the in-focus frame, F_focus. The algorithm determines the peak position by searching for the global maximum value on the curve. If multiple similar peaks exist on the curve, the first peak is taken as the in-focus frame to reflect the fastest focusing moment. In this way, the autofocus time is precisely calculated as the time difference between F_focus and F_target.
[0051] In this embodiment, a difference pixel matrix is obtained by calculating the grayscale difference map between the current frame and the previous frame frame by frame from the video stream. This operation can highlight the local brightness changes caused by the appearance of the target between frames, while suppressing relatively stable parts of the background. By counting the number of pixels in the difference pixel matrix whose brightness values exceed a preset baseline, this baseline is used to eliminate spurious changes caused by minor noise, retaining only significant brightness differences. When the number of these significantly changing pixels is greater than a dynamic threshold, the current frame is marked as a target appearance frame. The dynamic threshold here is calculated based on the difference mean and standard deviation of a preset number of past frames, which can adaptively reflect the level of change in the recent video frame. For example, when the target has not yet appeared, the video frame is relatively still, the difference mean and standard deviation are small, and the dynamic threshold is correspondingly low, which is conducive to quickly detecting the slight changes when the target appears; while after the target has appeared, the amplitude of the frame change increases, and the dynamic threshold increases accordingly, reducing the possibility of subsequent frames being misjudged as target appearance frames. This adaptive mechanism based on statistical characteristics makes the localization of target appearance frames more robust, especially in test environments with unstable lighting conditions or slight vibrations, effectively reducing the false alarm rate. By refining the differential calculation and threshold determination processes, the accuracy and environmental adaptability of target appearance frame detection are improved.
[0052] In one embodiment, step S21, namely, using an adaptive inter-frame difference method, uses a preset multiple of the standard deviation of the average difference of past preset frame numbers as a dynamic threshold to locate the frame where the target first appears, specifically includes: S211: Calculate the grayscale difference map between the current frame and the previous frame frame by frame from the video stream to obtain the difference pixel matrix.
[0053] In this embodiment, the grayscale difference map between the current frame and the previous frame is calculated frame by frame from the video stream to obtain the difference pixel matrix. This means that by comparing the grayscale at the pixel level, the change magnitude of each position between the two frames is quantified, providing basic data for subsequent statistics.
[0054] Specifically, the algorithm processes the video stream frame by frame, starting from the second frame. For the current frame i, it is first converted to a grayscale image, resulting in a grayscale matrix G_i, with dimensions W times its height H, and each element ranging from 0 to 255. Similarly, the grayscale matrix of the previous frame i-1 is G{i-1}. Then, the difference matrix D_i = |G_i - G{i-1}| is calculated, which is the absolute value of the difference between the grayscale values of corresponding pixels. The size of this difference matrix D_i is the same as the original image, and the value of each element represents the magnitude of the grayscale change of that pixel between the two frames. For example, if a white target suddenly appears from a black background, the grayscale value of the pixels in the target's edge region will jump from 0 to 255, resulting in a difference value as high as 255; while the background region remains unchanged, the difference value is close to 0. This pixel-by-pixel difference operation can accurately capture the position and intensity of any local changes in the image, unaffected by overall brightness changes. The calculated difference pixel matrix will be used for the next step of statistical judgment. To reduce computational load, the algorithm can employ interlaced sampling or downsampling, for example, scaling the image to one-quarter of its original size before calculating the difference, thereby improving processing speed while maintaining detection sensitivity.
[0055] S212: Count the number of pixels in the differential pixel matrix whose brightness values exceed the preset baseline.
[0056] In this embodiment, counting the number of pixels in the differential pixel matrix whose brightness values exceed a preset baseline means setting a minimum change threshold and only considering those pixels with sufficiently large changes to exclude the influence of noise and minor disturbances.
[0057] Specifically, after obtaining the difference pixel matrix D_i, the algorithm iterates through all elements in the matrix and counts the number of elements whose values are greater than the preset baseline B, denoted as C_i. The preset baseline B is an empirical value, usually set to 10 to 20 gray levels, representing the smallest meaningful change that the human eye or sensor can distinguish. The purpose of setting the baseline is to filter out spurious changes caused by sensor thermal noise, quantization errors, and small fluctuations in ambient light. For example, in a static scene, even without a target, some pixels in the difference matrix will have a difference value of 1 or 2, but these values are usually less than the baseline and will not be counted as valid change pixels. Only when a target enters the field of view, causing a large area of significant brightness change, will a large number of pixels have difference values exceeding the baseline, thus significantly increasing C_i. The selection of the baseline value requires a trade-off between sensitivity and noise resistance: a baseline that is too low will cause noise to be misjudged as change, while a baseline that is too high will miss the appearance of weak but real targets. In practical applications, the baseline value can be determined by acquiring a video in a target-free state and statistically analyzing the distribution of the difference values, usually taking about three times the standard deviation of the noise. This statistical process compresses the original difference matrix into a single numerical value C_i, which intuitively reflects the degree of significant change of the current frame relative to the previous frame, providing a concise and effective input for subsequent dynamic threshold comparisons.
[0058] S213: When the number of pixels exceeds the dynamic threshold, mark the current frame as the target occurrence frame.
[0059] In this embodiment, when the number of pixels is greater than the dynamic threshold, the current frame is marked as the target appearance frame. This means that the number of effective changed pixels obtained by statistics is compared with the adaptively calculated dynamic threshold. Once the threshold is exceeded, it is determined that the target has entered the field of view for the first time.
[0060] Specifically, the algorithm maintains a sliding window of length L (e.g., 100 frames) to store the C-value sequence of the most recent L frames. After processing each frame, the mean μ and standard deviation σ within the window are updated. The dynamic threshold T_dynamic = μ + K × σ, where K is a preset multiple, typically 3. For the current frame i, if C_i > T_dynamic, the current frame is determined to be a target occurrence frame, and differential detection of subsequent frames is immediately stopped. The advantage of this adaptive threshold design is its ability to adapt to the varying baseline values in different scenarios. For example, in a dimly lit environment, even without a target, the baseline level of the C-value may be high. In this case, μ and σ increase accordingly, and the dynamic threshold automatically increases, avoiding false triggers caused by changes in ambient light. In a bright environment with stable lighting, the baseline of the C-value is low, and the dynamic threshold is also low, which is beneficial for quickly detecting weak signals indicating the presence of a target. Furthermore, due to the limited window length, once the target appears, the C-value of subsequent frames increases significantly and enters the window, causing μ and σ to rise rapidly. This also raises the dynamic threshold, making it difficult for subsequent frames to exceed the threshold even if they still have a large C-value. This ensures that only the first frame is marked as the target appearance frame, avoiding duplicate marking. Through this mechanism, the localization of target appearance frames combines sensitivity and specificity, adapting to various testing environments.
[0061] In this embodiment, a square wave signal, strictly synchronized with the rotation frequency, is generated by monitoring the periodic reflection changes of the rotating encoder disk using a specular reflective photoelectric switch. This square wave signal is directly derived from the physical laws of mechanical rotation and is unaffected by internal camera clock drift or frame rate fluctuations. Therefore, it can serve as an independent reference benchmark for evaluating the accuracy of the camera's frame rate. By analyzing the brightness and phase changes of the encoder disk image in the recording frame by frame, a measured frequency sequence is generated. This sequence reflects the change of the actual recorded rotation frequency over time. By comparing the instantaneous deviation between the measured frequency sequence and the true frequency, frame rate jitter can be detected during recording, i.e., brief fluctuations in the actual frame rate deviating from the nominal frame rate. This frame-by-frame deviation detection is more precise than traditional average frame rate statistics and can detect anomalies in single frames or a few frames. By inferring the exposure time difference of the rolling shutter based on the phase shift of pixels in different rows within a single frame, and considering the line-by-line exposure characteristic of the rolling shutter, pixels in different rows of the same image are actually exposed at different times. Therefore, bright and dark stripes at the same position on the rotating encoder disk will exhibit phase shifts in different rows. By measuring this shift, the time required for line-by-line scanning of the rolling shutter can be quantitatively calculated, thereby evaluating the sensor's readout speed characteristics. Integrating frame rate stability and sensor readout characteristics into the same testing process improves detection efficiency and information richness.
[0062] In one embodiment, step S30, which involves analyzing video frame rate jitter and rolling shutter distortion frame by frame based on the true frequency reference of the high-frequency rotating encoder disk and the reflective photoelectric switch, specifically includes: S31: The periodic reflection changes of the rotating encoder disk are monitored by a mirror-reflective photoelectric switch to generate a square wave signal that is strictly synchronized with the rotation frequency, which is used as the true frequency.
[0063] In this embodiment, a mirror-reflective photoelectric switch is used to monitor the periodic reflection changes of the rotating encoder disk, generating a square wave signal that is strictly synchronized with the rotation frequency. This square wave signal serves as the true frequency, which refers to an independent frequency reference generated by detecting the alternating reflections of bright and dark stripes on the encoder disk surface through the photoelectric switch, unaffected by the camera clock.
[0064] Specifically, a rotating encoder disk driven by a high-precision servo motor is installed on the test bench. The encoder disk surface is printed with alternating black and white radial stripes. The number of black and white sectors is designed so that N light-dark cycles (e.g., N=100) are generated per rotation. A mirror-reflective photoelectric switch is fixed to one side of the encoder disk, its optical axis perpendicularly aligned with a fixed sector area on the encoder disk surface. The mirror-reflective photoelectric switch contains a emitter and a receiver. When the encoder disk rotates, the white sector has high reflectivity, the receiver receives a strong signal, and the switch outputs a high level; the black sector has low reflectivity, the receiver receives a weak signal, and the switch outputs a low level. Therefore, as the encoder disk rotates at a constant speed, the photoelectric switch outputs a square wave signal strictly synchronized with the rotation frequency. The frequency of this square wave is f_ref = (motor speed rpm / 60) × N. For example, if the motor speed is 6000 revolutions per minute and N=100, then f_ref = 10000 Hz. This frequency, determined by mechanical rotation and unaffected by any electronic clock drift, can therefore serve as an independent benchmark for evaluating the accuracy of the camera's frame rate. The square wave signal output from the photoelectric switch is connected to the digital input channel of the data acquisition card and recorded synchronously with the camera's video stream, ensuring that the true frequency is aligned with the video data in the same time coordinate system. The stability of this true frequency depends on the rotational speed accuracy of the servo motor, typically reaching a few parts per million, far exceeding the accuracy of the camera's internal crystal oscillator.
[0065] S32: Analyze the phase changes of brightness and darkness in the encoded disk image frame by frame in the video recording to generate a measured frequency sequence.
[0066] In this embodiment, analyzing the brightness and darkness phase changes of the encoder disc image in the video frame by frame to generate a measured frequency sequence means extracting the brightness information of the encoder disc area in each frame of the video recorded by the camera, and inferring the actual rotation frequency perceived by the camera by analyzing the change in brightness over time.
[0067] Specifically, after the camera finishes recording the rotating encoder disk, the industrial control computer reads the video stream. For each frame, the algorithm first extracts the region of interest (ROI) where the encoder disk is located using template matching or fixed coordinate cropping. Since the encoder disk's position in the frame is relatively fixed, it can be directly cropped using a pre-calibrated rectangular frame. Then, the grayscale values of all pixels within the ROI are averaged to obtain a value L_i representing the overall brightness of the frame. Due to the alternation of black and white stripes on the encoder disk, L_i will change approximately like a sine wave or square wave with the frame number. By plotting L_i as a waveform according to the frame number, the periodic changes in brightness can be observed. However, since the camera frame rate may not be exactly an integer multiple of the encoder disk rotation frequency, the waveform of L_i may exhibit phase jumps or envelope modulation. To extract frequencies more accurately, the algorithm performs spectral analysis on the L_i sequence. Specifically, the L_i values of several consecutive frames (e.g., 1024 frames) are taken to form a time series, and a Fast Fourier Transform is performed on it to obtain a spectrum. The dominant frequency in the spectrogram is the frequency of the encoder disk rotation recorded by the camera, denoted as f_cam. The video stream is segmented (e.g., every 256 frames is a window, with a step of 128 frames), and an f_cam value is calculated within each window, thus obtaining a measured frequency sequence that changes over time. This sequence reflects the camera's perceived frequency change for the same physical rotation throughout the recording process and forms the basis for subsequent frame rate jitter detection.
[0068] S33: Frame rate jitter is detected by comparing the instantaneous deviation between the measured frequency sequence and the true frequency, and the shutter exposure time difference is inferred from the phase offset of pixels in different rows within a single frame.
[0069] In this embodiment, frame rate jitter is detected by comparing the instantaneous deviation between the measured frequency sequence and the true frequency, and the shutter exposure time difference is inferred from the phase offset of pixels in different rows within a single frame. This means that the frame rate stability is evaluated by using frequency deviation, and the sensor readout speed is measured by using the line-by-line exposure characteristics of the shutter.
[0070] Specifically, the measured frequency sequence f_cam(t) is compared point by point with the obtained true frequency f_ref, and the instantaneous deviation Δf(t) = f_cam(t) - f_ref is calculated. Δf(t) is plotted as a curve. Under normal circumstances, Δf should fluctuate slightly around zero (e.g., within ±0.1 Hz). If obvious positive or negative peaks appear, it indicates that the camera experienced frame rate jitter during that time period. For example, if Δf suddenly increases, it means that the encoder disk rotation frequency recorded by the camera during that period is too high, i.e., the actual frame rate is lower than the nominal frame rate, resulting in image stretching; conversely, the opposite is also true. By statistically analyzing the number and magnitude of Δf exceeding a preset threshold, the frame rate stability index can be quantified. Simultaneously, the algorithm also utilizes the characteristics of the rolling shutter for distortion analysis. For a single frame image, the black and white stripe boundaries on the encoder disk should be straight lines perpendicular to the scanning direction in the image. However, due to the rolling shutter's line-by-line exposure, the pixel acquisition time for different lines is different, causing the moving stripe boundaries to appear tilted in the image. The algorithm detects the position of the black-and-white boundary in each line and calculates the slope of the boundary position change with the line number. This slope is proportional to the exposure time difference of the rolling shutter. Through calibration, the slope can be converted into the exposure time difference between each line, thus obtaining the total readout time of the rolling shutter. This parameter is of great significance for evaluating the degree of distortion when shooting high-speed motion.
[0071] In this embodiment, a square wave signal, strictly synchronized with the rotation frequency, is generated by monitoring the periodic reflection changes of the rotating encoder disk using a specular reflective photoelectric switch. This square wave signal is directly derived from the physical laws of mechanical rotation and is unaffected by internal camera clock drift or frame rate fluctuations. Therefore, it can serve as an independent reference benchmark for evaluating the accuracy of the camera's frame rate. By analyzing the brightness and phase changes of the encoder disk image in the recording frame by frame, a measured frequency sequence is generated. This sequence reflects the change of the actual recorded rotation frequency over time. By comparing the instantaneous deviation between the measured frequency sequence and the true frequency, frame rate jitter can be detected during recording, i.e., brief fluctuations in the actual frame rate deviating from the nominal frame rate. This frame-by-frame deviation detection is more precise than traditional average frame rate statistics and can detect anomalies in single frames or a few frames. By inferring the exposure time difference of the rolling shutter based on the phase shift of pixels in different rows within a single frame, and considering the line-by-line exposure characteristic of the rolling shutter, pixels in different rows of the same image are actually exposed at different times. Therefore, bright and dark stripes at the same position on the rotating encoder disk will exhibit phase shifts in different rows. By measuring this shift, the time required for line-by-line scanning of the rolling shutter can be quantitatively calculated, thereby evaluating the sensor's readout speed characteristics. Integrating frame rate stability and sensor readout characteristics into the same testing process improves detection efficiency and information richness.
[0072] In one embodiment, step S32, namely analyzing the brightness and phase changes of the encoded disc image in the video frame by frame to generate a measured frequency sequence, specifically includes: S321: Extract the gray value sequence of the region where the encoding disk is located in each frame of the image, and perform a fast Fourier transform on the gray value sequence to obtain the main frequency component.
[0073] In this embodiment, the gray value sequence of the region where the encoder disk is located in each frame of the image is extracted, and the gray value sequence is subjected to fast Fourier transform to obtain the dominant frequency component. This means that the dominant component of the encoder disk rotation frequency is extracted from the image brightness information through frequency domain analysis to improve the anti-interference capability of frequency measurement.
[0074] Specifically, for each frame in the video stream, the algorithm first extracts the region of interest (ROI) where the encoder disk is located using a pre-defined coordinate frame. This region is typically located near the center of the image and is about one-tenth of the total image area. Then, the average grayscale value of all pixels within this region is calculated to obtain a scalar value, L_i. The L_i values of N consecutive frames (e.g., 512 frames) are arranged by frame number to form a real number sequence of length N. A Hanning window function is applied to this sequence to reduce spectral leakage, followed by a Fast Fourier Transform (FFT) to obtain a complex spectrum. The amplitude spectrum is then analyzed, and the frequency value corresponding to the frequency component with the largest amplitude is identified as the dominant frequency component, f_main, of the video segment. Since the encoder disk's rotation frequency is the only strong periodic signal, while the energy of interference components such as ambient light fluctuations and sensor noise is usually distributed across multiple frequencies, the dominant frequency component reliably represents the encoder disk rotation frequency recorded by the camera. If the video is long, a sliding window approach can be used, recalculating the dominant frequency every frame or several frames to obtain a frequency sequence that changes over time. The Fast Fourier Transform (FFT) is computationally efficient; processing a 512-point FFT on an industrial computer takes only microseconds, meeting real-time or near-real-time analysis requirements. This method allows for accurate extraction of the dominant frequency component even in images with slight noise or dirt on the encoder disk surface, improving the robustness of frequency measurements.
[0075] S322: Take the main frequency component as the corresponding measured frequency and compare it with the true frequency to obtain the frequency deviation value.
[0076] In this embodiment, the main frequency component is taken as the corresponding measured frequency and compared with the true frequency to obtain the frequency deviation value. This means that the frequency value obtained by frequency domain analysis is subtracted from the standard frequency provided by the photoelectric switch, which quantifies the frame rate error of the camera in that time period.
[0077] Specifically, after obtaining the main frequency component f_main for each video window, the true frequency f_ref for the corresponding time period is retrieved from the synchronously recorded data. Since the true frequency is determined by the servo motor speed and remains constant for a short period, the average value within that time period can be directly taken as f_ref. Then, the frequency deviation value Δf = f_main - f_ref is calculated. This deviation value can be positive or negative. A positive value indicates that the frequency recorded by the camera is higher than the actual frequency, meaning the actual frame rate of the camera is lower than the nominal frame rate (because recording the same number of stripes requires more frames, meaning a longer frame interval); a negative value indicates that the actual frame rate of the camera is higher than the nominal frame rate. The absolute value of the deviation value reflects the degree of frame rate deviation. For example, if the nominal frame rate is 60 frames per second and the true frequency is 10000 Hz, theoretically each frame should record approximately 166.67 cycles. However, if the actual frame rate is only 59.5 frames per second, the number of cycles recorded per frame will increase, resulting in a higher f_main. By calculating Δf, the frame rate error can be quantified to the Hertz level. This deviation value can be further converted into a frame rate error percentage, facilitating comparison with industry standards. The frequency deviation value is a direct input for subsequent frame rate jitter detection and a key indicator for determining the accuracy of the camera's frame rate.
[0078] S323: Arrange the frequency deviation values of all frames in chronological order to form a measured frequency sequence.
[0079] In this embodiment, the frequency deviation values of all frames are arranged in chronological order to form a measured frequency sequence. This means that the deviation values obtained from each analysis window are organized into a data sequence that changes over time, which is used to observe the dynamic evolution trend of the frame rate deviation.
[0080] Specifically, assuming the total video length is T seconds, using sliding window analysis with a window length of 512 frames and a step size of 128 frames, approximately (T × fps / 128) analysis windows can be obtained. Each window corresponds to a time interval, and its center moment is taken as the time label for the deviation value. Arranging the deviation values Δf_k (k=1,2,...) and their time labels t_k of all windows in chronological order yields the measured frequency deviation sequence. This sequence can be visualized as a line graph, with time on the horizontal axis and frequency deviation value on the vertical axis. By observing this sequence, various frame rate anomaly patterns can be identified: if the deviation value fluctuates slightly around zero for most of the time, it indicates stable frame rate; if periodic alternation of positive and negative values occurs, it may suggest frame rate lock loop oscillation in the camera; if isolated spikes appear, it indicates that a dropped or skipped frame occurred at that moment; if the deviation value is generally biased towards positive or negative values, it indicates a systematic shift in frame rate. Furthermore, the mean and standard deviation of this sequence can be calculated as quantitative indicators of frame rate stability. The mean reflects the systematic bias, while the standard deviation reflects the amplitude of random jitter. Combining this sequence with the aforementioned rolling shutter distortion data allows for a comprehensive evaluation of the camera's time-base performance. The generation of the measured frequency sequence summarizes the frame-by-frame microscopic analysis results into macroscopic trend data, facilitating rapid identification of problematic time periods by inspection personnel.
[0081] In this embodiment, the grayscale value sequence of the region where the encoder disk is located in each frame image is extracted, and a Fast Fourier Transform (FFT) is performed on the sequence to obtain the dominant frequency component. The FFT converts grayscale changes in the time domain into a spectral distribution in the frequency domain, where the frequency component with the largest amplitude represents the rotation frequency of the encoder disk in that frame. This method utilizes the spatial periodicity of the encoder disk stripes; even if there is some noise or distortion in the image, the FFT can still accurately extract the dominant frequency component, reducing the error that may be introduced by directly counting the number of stripes. By using the dominant frequency component as the corresponding measured frequency and comparing it with the true frequency, a frequency deviation value is obtained. This deviation value quantifies the difference between the rotation frequency recorded by the camera in that frame and the true rotation frequency; a positive value indicates a higher recorded frequency, and a negative value indicates a lower recorded frequency. By arranging the frequency deviation values of all frames in chronological order, a measured frequency sequence is formed. This sequence visually displays the dynamic trend of frame rate deviation throughout the recording process. By observing the fluctuation amplitude and frequency of this sequence, abnormal patterns such as periodic jitter or sudden frame drops can be identified. Frequency domain analysis improves the anti-interference capability and accuracy of frequency extraction, and presents the frame rate jitter detection results as a continuous deviation sequence, which facilitates subsequent statistical analysis or threshold determination.
[0082] In one embodiment, step S40, which involves fusing the true displacement values of the inertial measurement unit and the reflective photoelectric switch to perform triangulation verification of the camera's image stabilization performance, specifically includes: S41: The actual displacement trajectory is obtained by integrating the acceleration and angular velocity output by the inertial measurement unit fixed on the vibration table surface twice.
[0083] In this embodiment, the acceleration and angular velocity output by the inertial measurement unit fixed on the vibration table are used to obtain the true displacement trajectory after double integration. This means that the motion acceleration and angular velocity data of the table are converted into displacement and attitude information through the inertial navigation principle, which serves as the true attitude value for evaluating the anti-shake performance.
[0084] Specifically, a six-axis inertial measurement unit (IMU) is rigidly fixed on the vibration table surface, integrating a three-axis accelerometer and a three-axis gyroscope. This IMU connects to a data acquisition card via a serial port or CAN bus, outputting accelerations a_x, a_y, a_z and angular velocities ω_x, ω_y, ω_z at a sampling rate of at least 1 kHz. Before the vibration table begins movement, the IMU is held stationary for a period of time to collect static data for zero bias determination and calibration. The vibration table moves along a preset trajectory (e.g., a sinusoidal sweep along the X-axis, with frequencies from 1 Hz to 20 Hz and an amplitude of 5 mm). The data acquisition card synchronously records the output of the IMU and the signal from the reflective photoelectric switch. In post-processing, the algorithm first removes the gravity component from the acceleration data and performs high-pass filtering to eliminate low-frequency drift. Then, the acceleration is integrated once to obtain velocity, and then integrated again to obtain displacement. The angular velocity is integrated to obtain attitude angles (pitch, roll, and yaw). Because the integration of the inertial measurement unit (IMU) accumulates errors, it is necessary to combine it with the true displacement value from the reflective photoelectric switch for auxiliary correction. However, as an independent attitude truth value, the displacement trajectory provided by the IMU can reflect the actual motion state of the shaking table in three-dimensional space, especially the rotational motion that the photoelectric switch cannot detect. This true displacement trajectory is one of the important benchmarks for subsequent comparison with the camera's image stabilization compensation trajectory.
[0085] S42: The absolute displacement of the target on the vibration table is measured by using a reflective photoelectric switch fixed outside the vibration table to obtain the switch displacement trajectory.
[0086] In this embodiment, a reflective photoelectric switch fixed outside the vibration table is used to measure the absolute displacement of the target on the vibration table and obtain the switch displacement trajectory. This means that the photoelectric switch detects the position change of the target relative to a fixed reference point, providing another independent source of displacement measurement, which is used to verify the results of the inertial measurement unit.
[0087] Specifically, a highly reflective target, which can be a white diffuse reflector or a specular reflector, is installed on the vibration table surface. A specular reflective photoelectric switch is installed at a fixed location outside the vibration table, with its optical axis aligned with the target on the vibration table. As the vibration table moves, the distance between the target and the photoelectric switch changes, causing a corresponding change in the intensity of the light reflected back to the receiver. For the specular reflective photoelectric switch, the relationship between its output signal and distance is approximately linear within a certain range. A mapping relationship between the output signal voltage (or digital value) and the target displacement is established through pre-calibration. The calibration method involves moving the vibration table to a series of known positions (e.g., measured using a laser interferometer), recording the output values of the photoelectric switch, and then fitting a calibration curve. During formal testing, the data acquisition card records the output values of the photoelectric switch in real time and converts them into displacement values based on the calibration curve. Because the photoelectric switch has a very high sampling rate (up to 1 megasamples per second) and a simple and direct measurement principle, unaffected by integral drift, the displacement trajectory it provides has high accuracy on a short timescale. The switch displacement trajectory primarily reflects the linear displacement of the vibration table along the optical axis of the photoelectric switch. It cannot measure rotational motion, but it can be cross-validated with the three-dimensional displacement trajectory of the inertial measurement unit in the overlapping dimension. If the displacement curves of the two are highly consistent in the same direction, the measurement result is reliable; if there is a discrepancy, it may indicate integral drift in the inertial measurement unit or calibration error in the photoelectric switch.
[0088] S43: Time-align the image stabilization compensation displacement trajectory output by the camera with the real displacement trajectory and the switch displacement trajectory, calculate the residual between the image stabilization compensation displacement trajectory and the real displacement trajectory, and determine whether the image stabilization performance is qualified based on the correlation coefficient between the image stabilization compensation displacement trajectory and the switch displacement trajectory.
[0089] In this embodiment, the image stabilization compensation displacement trajectory output by the camera is time-aligned with the real displacement trajectory and the switch displacement trajectory. The residual between the image stabilization compensation displacement trajectory and the real displacement trajectory is calculated. The image stabilization performance is then determined based on the correlation coefficient between the image stabilization compensation displacement trajectory and the switch displacement trajectory. This means that the real effect of the image stabilization algorithm is comprehensively evaluated from two dimensions: residual and correlation, through multi-source data fusion analysis.
[0090] Specifically, after completing the vibration test, the industrial personal computer acquires three sets of data: the anti-shake compensation displacement trajectory D_eis output by the camera through its built-in anti-shake algorithm (usually embedded in the video file in the form of metadata, or output through a dedicated interface), the real displacement trajectory D_imu obtained by integrating the inertial measurement unit, and the switch displacement trajectory D_switch obtained by calibration using the reflective photoelectric switch. First, the time axes of the three trajectories are aligned to the same reference frame using the established hardware time zero point. Since D_eis may be output in units of frames, while D_imu and D_switch are output at a high sampling rate, it is necessary to perform downsampling or interpolation on D_imu and D_switch to align them with the time points of D_eis. Then, the residual vector R = D_eis - D_imu is calculated. The root mean square value of the residual reflects the average displacement that the anti-shake algorithm fails to compensate, and a smaller residual indicates a better anti-shake effect. At the same time, the Pearson correlation coefficient ρ between D_eis and D_switch is calculated. If ρ is close to -1, it indicates that D_eis and D_switch are strongly negatively correlated, that is, the anti-shake compensation direction is opposite to the vibration direction, and the compensation is correct; if ρ is close to +1, it indicates that the compensation direction is the same as the vibration direction, which instead aggravates the shake; if ρ is close to 0, it indicates that the compensation is unrelated to the vibration, and the anti-shake algorithm may not take effect. By integrating the two indicators of residual and correlation coefficient, a judgment criterion can be set: for example, when the root mean square of the residual is less than 0.1 mm and ρ is less than -0.8, the anti-shake performance is judged to be qualified; otherwise, it is judged to be unqualified. This triangular verification method utilizes two independent true value sources, effectively avoiding the systematic deviation that may exist in a single reference, and improving the reliability of the evaluation result.
[0091] In this embodiment, the actual displacement trajectory is obtained by integrating the acceleration and angular velocity output by an inertial measurement unit fixed to the vibration table surface twice. The inertial measurement unit directly measures the motion state of the table surface, and its integration result reflects the actual displacement and attitude changes of the vibration table in three-dimensional space, serving as one of the benchmarks for evaluating image stabilization performance. The absolute displacement of the target on the vibration table is measured using a reflective photoelectric switch fixed outside the vibration table, obtaining the switch displacement trajectory. The reflective photoelectric switch senses the positional change of the target relative to a fixed reference point by detecting changes in the reflected light from the target. Its measurement results are not affected by the kinematic model error of the vibration table itself, providing another independent source of displacement measurement. After time-aligning the image stabilization compensation displacement trajectory output by the camera with the actual displacement trajectory and the switch displacement trajectory, the residual between the image stabilization compensation displacement trajectory and the actual displacement trajectory is calculated. The magnitude of the residual reflects the motion components that the image stabilization algorithm failed to fully compensate for; the smaller the residual, the better the image stabilization effect. By analyzing the correlation coefficient between the stabilization compensation displacement trajectory and the switch displacement trajectory, the correctness of the stabilization compensation direction is determined. A negative correlation indicates that the stabilization compensation direction is opposite to the vibration direction, which is expected; a positive correlation indicates that the stabilization compensation actually exacerbates the shaking. By introducing two independent truth measurement sources, a triangulation mechanism is constructed, improving the objectivity and reliability of stabilization performance evaluation and reducing the systematic bias that may exist when relying on a single reference.
[0092] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0093] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application 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. Such 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 this application, and should all be included within the protection scope of this application.
Claims
1. A method for testing the performance of a reflective photoelectric switch used in a camera, characterized in that, The performance testing method for the reflective photoelectric switch used in a camera includes: A high-precision time base and multimodal acquisition model are constructed. The camera is triggered by the output signal of a reflective photoelectric switch, and the switch signal, motor position signal and video stream are recorded synchronously with the data acquisition card. Based on inter-frame difference and gradient analysis, the target appearance frames and focus frames are detected from the video stream, and the shutter delay and autofocus time are calculated. Based on the true frequency reference of high-frequency rotary encoder disk and reflective photoelectric switch, the video frame rate jitter and rolling shutter distortion are analyzed frame by frame. By integrating the displacement truth values of the inertial measurement unit and the reflective photoelectric switch, the camera's image stabilization performance is triangulated.
2. The performance testing method for a reflective photoelectric switch for a camera according to claim 1, characterized in that, The construction of the high-precision time base and multimodal acquisition model specifically includes: Connect the output signal of the reflective photoelectric switch to both the external trigger interface of the camera and the digital input channel of the data acquisition card. The data acquisition card synchronously acquires the switch signals, linear motor position encoder signals, and video stream output by the camera, and generates multi-data packets with timestamps under a unified clock domain.
3. The performance testing method for a reflective photoelectric switch for a camera according to claim 2, characterized in that, The generation of timestamped multi-source data packets under a unified clock domain specifically includes: The rising edge time of the switch signal is obtained from the data acquisition card and used as the hardware time zero point; The position data of the position encoder at each sampling point is acquired and time-aligned with the hardware time zero point to obtain the target displacement trajectory. Each frame of the video stream is associated with the nearest hardware time zero point to generate a frame-time mapping table for subsequent frame location.
4. The performance testing method for a reflective photoelectric switch for a camera according to claim 1, characterized in that, The method of detecting target appearance frames and focus frames from the video stream based on inter-frame difference and gradient analysis specifically includes: An adaptive inter-frame difference method is used, with a preset multiple of the standard deviation of the average difference of the preset number of frames in the past as a dynamic threshold, to locate the first frame in which the target appears, and record it as the target appearance frame; In the continuous frame sequence following the appearance of the target, the Laplacian variance operator is applied to calculate the sharpness evaluation value of the target region, generate a focus curve, and determine the frame corresponding to the peak of the focus curve as the in-focus frame.
5. The performance testing method for a reflective photoelectric switch for a camera according to claim 4, characterized in that, The method employs an adaptive inter-frame difference approach, using a preset multiple of the standard deviation of the average difference of past preset frame counts as a dynamic threshold to locate the first frame in which the target appears. Specifically, this includes: The grayscale difference map between the current frame and the previous frame is calculated frame by frame from the video stream to obtain the difference pixel matrix; The number of pixels in the differential pixel matrix whose brightness values exceed a preset baseline is counted. When the number of pixels is greater than the dynamic threshold, the current frame is marked as the target occurrence frame.
6. The performance testing method for a reflective photoelectric switch for a camera according to claim 1, characterized in that, The true frequency reference based on a high-frequency rotating encoder disk and a reflective photoelectric switch is used to analyze video frame rate jitter and rolling shutter distortion frame by frame, specifically including: The periodic reflection changes of the rotating encoder disk are monitored by a mirror-reflective photoelectric switch, and a square wave signal that is strictly synchronized with the rotation frequency is generated as the true frequency. The brightness and phase changes of the encoded disk image in the video are analyzed frame by frame to generate a measured frequency sequence; Frame rate jitter is detected by comparing the instantaneous deviation between the measured frequency sequence and the true frequency, and the shutter exposure time difference is inferred from the phase offset of pixels in different rows within a single frame.
7. The performance testing method for a reflective photoelectric switch for a camera according to claim 6, characterized in that, The step-by-frame analysis of the brightness and phase changes of the encoded disk image in the video recording to generate a measured frequency sequence specifically includes: Extract the gray value sequence of the region where the encoding disk is located in each frame of the image, and perform a fast Fourier transform on the gray value sequence to obtain the main frequency component; The dominant frequency component is taken as the corresponding measured frequency and compared with the true frequency to obtain the frequency deviation value; The frequency deviation values of all frames are arranged in chronological order to form the measured frequency sequence.
8. The performance testing method for a reflective photoelectric switch for a camera according to claim 1, characterized in that, The true displacement values of the fusion inertial measurement unit and the reflective photoelectric switch are used to triangulate the camera's image stabilization performance, specifically including: The actual displacement trajectory is obtained by integrating the acceleration and angular velocity output by the inertial measurement unit fixed on the vibration table surface twice. The absolute displacement of the target on the vibration table is measured by using a reflective photoelectric switch fixed outside the vibration table, and the switch displacement trajectory is obtained. The image stabilization compensation displacement trajectory output by the camera is time-aligned with the actual displacement trajectory and the switch displacement trajectory. The residual between the image stabilization compensation displacement trajectory and the actual displacement trajectory is calculated. The image stabilization performance is then determined to be qualified based on the correlation coefficient between the image stabilization compensation displacement trajectory and the switch displacement trajectory.