Article sections
What does real-time image processing mean?The difference between latency, throughput, FPS, and jitterHow do you break down a latency budget?Why is average latency alone not enough?Where is the bottleneck?Is batching always beneficial?How do you preserve order in an asynchronous pipeline?Backpressure and the danger of long queuesHow do we relate conveyor distance to timing?How to benchmark FPS, and how not toThermal and sustained-load testingWhat should a performance report for site acceptance contain?Where should profiling measurement points be placed?How do you estimate processing pipeline capacity?How do you decide what needs optimizing?How do you determine the tolerance for the decision window?Cold starts and first-product issuesFairness in multi-GPU / multi-camera performance testingHow is Little's law used to interpret queues?Timestamp reliability when measuring jitterHow should p95, p99, and maximum latency be reported?Priorities in systems running multiple modelsAn example of making a decision based on profiling resultsWhich faults should be deliberately introduced during testing?What happens if we change the starting point of a time measurement?How do you justify a proposed performance improvement?How do we test an increase in product rate in advance?Example performance report: two different results on the same GPUFrequently asked questionsWhat does real-time image processing mean?
For an image processing system, "real-time" does not simply mean high FPS. As a product moves, the result derived from its captured image must be ready before a specific physical action takes place. This action may be a robot's gripping motion, an air valve rejecting a defective part, or an operator being alerted. Each has a different deadline and tolerance for latency.
For example, suppose the distance between a camera and the rejection point is 400 mm and the belt speed is 800 mm/s. The part takes 400/800 = 0.5 seconds, or 500 ms, to travel this distance. Image acquisition, processing, PLC transmission, and valve movement must fit within this window. A p50 latency of 60 ms is encouraging, but if p99 latency unexpectedly rises to 650 ms, rejection may not happen in time.
Real-time operation means validating the deadline both technically and operationally. A fixed rule of "at least 30 FPS" does not apply to every line. A camera producing 15 images per second may successfully perform the task if it provides sufficient, timely information for every part; a system producing 200 FPS but mixing up product identities fails.
The difference between latency, throughput, FPS, and jitter
Latency is the time elapsed between two defined events. We can measure the time from the camera trigger to the PLC acknowledging the decision; the time taken only for the model to receive its input and produce its output is called inference latency. Throughput is the number of jobs completed per unit time; FPS describes the frame production or consumption rate of the camera or processing pipeline. Jitter describes how much the measured latency of the same operation fluctuates.
Each of these metrics answers a different question. A system may process 100 images per second while an individual image spends 150 ms waiting in a queue. Using batch 8 may increase the GPU's total throughput per second, but the first product may wait longer while the batch fills. Application reports should therefore show throughput, individual end-to-end latency, and percentiles together.
Latency figures cannot be compared without defined start and end points. Two durations, one measured from completion of the camera's DMA transfer and the other from exposure, mean different things. A good benchmark report specifies input resolution, batch size, warm/cold start, hardware, runtime, power mode, and the start and end points of the measured interval.
How do you break down a latency budget?
A typical chain may include trigger latency, exposure, transfer, buffer delivery, preprocessing, tensor copying, model inference, postprocessing, PLC communication, and the physical actuator. The stages do not always add up as a simple arithmetic sum; some tasks run in parallel. However, identifying the most critical sequential path is an essential starting point. A time-critical system needs measurement points at every stage.
In an educational example, 3 ms of exposure, 7 ms of transfer, 9 ms of preprocessing, 20 ms of inference, 6 ms of postprocessing, and 10 ms of PLC communication add up to 55 ms. Queueing and mechanical response are not included. Reducing the model's time from 20 ms to 12 ms may bring the total to 47 ms; however, if transfer latency increases by 50 ms under load, the production benefit of that gain may disappear.
Optimizing broadly without knowing which component forms the critical path may solve the wrong problem. The latest permissible decision time and a safety margin should be calculated based on product movement, and the measured interval should be compared with that deadline.
Why is average latency alone not enough?
Rare but long delays matter in real-time production systems. p95 describes the duration below which 95% of samples fall; p99 describes the 99th percentile. In a service with an average of 35 ms, p95 of 59 ms, and p99 of 86 ms, most products are processed quickly, but some finish noticeably later. The sample count and test duration must also be known to interpret these figures correctly.
One misconception is to treat p99 as the absolute worst-case duration. p99 alone does not describe the slowest 1% of the observation set; the most extreme values may be higher. In processes with hard deadlines, worst-case behavior, system load, OS scheduling, thermal throttling, and network packet loss must be evaluated together. p99 alone does not provide a hard real-time guarantee.
Where is the bottleneck?
First, each stage of the system should be timed separately: camera frame ready, preprocessing started/finished, data copied to the GPU, inference started/finished, postprocessing finished, PLC message sent, ACK received. This makes the measurement reflect the actual process rather than just a function call. CPU sampling, a GPU profiler, network counters, and disk I/O logs can reveal which resource is causing a wait.
For example, if GPU utilization is low but total latency is high, CPU preprocessing, synchronization, or data transfer may be the bottleneck. If the GPU shows 100% utilization but the batch size is small, other parameters can be tried; high utilization alone does not mean the system is optimal. If network packet loss causes retransmissions, speeding up the model will not help.
Why can adding up stage durations produce a different result?
Asynchronous GPU calls can lead to misleading timing measurements because the CPU submits work to the GPU and immediately continues. The actual completion of GPU work should be measured using synchronization or an appropriate timing tool. Because parallel stages can overlap, the sum of all stage durations may differ from the end-to-end elapsed time. The report should clearly distinguish GPU-only latency, host latency, and system latency.
Is batching always beneficial?
Batching can improve the utilization of computing resources by processing multiple images in a single model call. However, waiting for the batch to fill introduces additional latency. If a camera produces 12 products per minute, batch 16 takes a long time to fill; this approach may be unsuitable for a line where each product must be sorted quickly. Achieving high throughput under saturation and achieving the lowest latency for a single image are different goals.
When dynamic batching is used, both the maximum waiting time and maximum batch size should be bounded. With a variable input stream, batch waiting may occur at low traffic levels and contention for GPU resources at high traffic levels. Benchmarks should cover both single-product and peak product-flow scenarios.
How do you preserve order in an asynchronous pipeline?
In a processing pipeline, the CPU can prepare the previous frame while the camera captures a new one and the GPU processes an older frame. This increases total throughput. However, with multiple cameras or jobs of different durations, results may return in a different order from their arrival from the camera. Every image should carry a product ID, trigger timestamp, and validity period.
In parallel processing, a fast result that is not matched to the correct product is just as harmful as a late result. When merging results, the result service may use a sequence number, product carrier ID, or encoded position. If FIFO alone is insufficient, matching and timeout mechanisms are needed.
Backpressure and the danger of long queues
When the image arrival rate exceeds processing capacity for a prolonged period, the queue grows. Enlarging the buffer can absorb a sudden fluctuation but does not solve a sustained capacity shortfall. Along with the number of queued items, the waiting time of the oldest item in ms should be monitored. The risk of a queue holding 20 frames depends on the time per frame and the belt speed.
In quality control, the safe approach is to explicitly represent any loss of an image or decision for each product. A "keep the latest frame, discard the old one" policy may be reasonable for tasks such as video monitoring, but a frame skipped without any trace is unacceptable in 100% part inspection. Missing products should trigger a stop, routing to a separate inspection line, or another policy approved for the process.
How do we relate conveyor distance to timing?
After a product leaves the camera's field of view, it moves toward the rejection mechanism. At a constant belt speed, if the camera-to-rejection distance is d and the speed is v, the theoretically available time is d/v. For example, with d = 400 mm and v = 800 mm/s, it is 500 ms. If total software time is 70 ms and the mechanical valve response is 35 ms, there is a nominal margin of 395 ms. However, latency fluctuations, conveyor acceleration, encoder resolution, and the area affected by the physical valve jet may reduce this margin.
The crucial point is that the model seeing the product does not mean the actuator will reach it in time. The position at which the valve acts on the product and the product's travel path must be verified through physical testing. Distance-based triggering using synchronized timestamps or an encoder counter may be more reliable; simple fixed-delay methods can introduce drift if the process hardware is unsuitable.
How to benchmark FPS, and how not to
Running a model thousands of times in a test loop and measuring how many inferences it performs per second is a useful microbenchmark. However, if camera transfer, data conversion, result filtering, and PLC communication are excluded, this is not the production line's FPS. Benchmark conditions should be fixed: input size, batch size, device, runtime, model version, memory layout, and GPU power/thermal state must be the same.
Model loading, graph compilation, and cache effects during the first few calls should also be reported separately. Warm-start measurements are meaningful during intensive production; however, what happens to the first product when the device is switched on again in the morning should be tested separately as an operational scenario.
Thermal and sustained-load testing
GPU speed may be good in a short benchmark but worse during a four-hour shift. Insufficient cooling, power limits, or resource sharing with other processes can reduce performance over the hours. Short and long tests should therefore monitor p50, p95, p99, frame loss, and temperature together. Long tests also expose problems such as memory leaks and disk logging queues.
Ambient temperature inside an enclosed factory electrical cabinet may be higher than in a desktop laboratory. Measuring airflow in the actual cabinet is as important as observing the device manufacturer's temperature limits. Latency fluctuations should not be attributed solely to GPU temperature; they should be analyzed alongside CPU load, network activity, and operating system events.
What should a performance report for site acceptance contain?
The best report is not simply a single page stating "maximum FPS: 120." Expected product rate, peak rate, camera count, normal/fault operating modes, p50/p95/p99 end-to-end times, lost frames, timeouts, product-matching errors, and results that miss the rejection point should be listed separately. Measurement start and end points must be explicit.
Tests should cover normal lighting, shiny surfaces, two products passing close together, reconnection, a 24-hour thermal load, and high network traffic. After a performance improvement, model decisions should also undergo regression testing: reducing image size to run faster may have made a small defect invisible.
Where should profiling measurement points be placed?
When selecting measurement points, marking the start and end of each module is a sufficient first step; however, with asynchronous GPU execution, the CPU function returning may not mean computation has finished. The difference between host-side wall-clock timing and GPU event-based timing must therefore be understood. If we are focusing on the production decision, the interval from the physical imaging event until the PLC acknowledges the valid result is what must be measured precisely.
Each event record may contain product ID, camera ID, model version, and timestamp fields. Example measurement steps are: trigger received, camera exposure started, frame completed, preprocessing started/finished, H2D copy finished, inference finished, postprocessing finished, PLC message sent, PLC ACK received. This trace reveals which stage was delayed. If clocks on different devices are not synchronized, differences between their timestamps may be unreliable.
A profiling experiment must also account for the cost of measurement itself. Writing detailed logs for every frame can increase the system's p99 latency. Appropriate sampling and lightweight timestamp collection methods enable analysis without disturbing the observed behavior.
How do you estimate processing pipeline capacity?
If a frame takes a total of 40 ms to process in a sequential system, the theoretical upper limit may appear to be 25 frames/s. However, when camera, CPU, and GPU stages overlap, the pipeline's long-term throughput can approach that of its slowest stage. Meanwhile, the latency between the first and last stages for one product may remain higher. This distinction is similar to pipelining in computer architecture.
For example, suppose the camera requires 5 ms, CPU preprocessing 15 ms, the GPU 25 ms, and postprocessing 5 ms. Fully sequential processing takes 50 ms for one frame. With sufficient buffering and parallelism, the steady-state bottleneck may be the GPU's 25 ms, and theoretical throughput can approach approximately 40 frames/s. This is only the ideal case, however; memory copies, ordering, buffer capacity, and actual device load affect the result.
Capacity planning identifies the slowest station and compares it against the target line speed. Peak rates and multi-camera scenarios must not be ignored. If input remains faster over time, the queue grows; a buffer allocated for short bursts provides only temporary tolerance.
How do you decide what needs optimizing?
First, CPU preprocessing time, GPU inference time, image transfer, PLC communication, and queue waiting time are reported separately. A controlled change is then applied to the bottleneck contributing most. For example, eliminating repeated image copies on the CPU may yield a greater gain than changing the model architecture. Conversely, if model inference accounts for 80% of total time, TensorRT or a precision conversion may be worth considering.
It matters which percentile of measured latency improves. If p50 improves while p99 worsens, the number of late production decisions may increase. Acceptance criteria for every optimization should therefore include p95/p99 and error rates, not just average FPS. Model quality metrics should also be compared; a smaller input resolution may make a fine defect invisible.
If a change affects several things at once, establishing cause and effect becomes difficult. Starting with a single-variable comparison, followed where necessary by experiments on interacting effects, provides more reliable information.
How do you determine the tolerance for the decision window?
In the example with a 400 mm distance between the camera and valve and an 800 mm/s belt speed, the nominal window is 500 ms. However, if the product is 60 mm long, the rejection valve's effective area is narrow, and belt speed fluctuates by 10%, the actual time window may shrink. The calculation should use maximum speed and product position tolerance rather than just one nominal speed.
For example, if speed increases to 880 mm/s, the same 400 mm distance is covered in approximately 455 ms. The valve's 35 ms movement time, PLC communication latency, and a safety margin are subtracted from this. If the image acquisition sensor triggers the product at varying positions relative to the valve center, distance error must also be included. Therefore, the system's latest permissible completion time must be verified through physical testing.
A valve's triggering performance is not just the solenoid's opening time. Product mass, air pressure, belt speed, and the rejection area affect successful separation. Even if the software becomes 20 ms faster, the problem remains unresolved if mechanical rejection fails.
Cold starts and first-product issues
Loading the GPU engine, building a cache, or compiling the ONNX graph can delay the first inference. Laboratory benchmarks exclude this time when warmup is performed. On a production line, however, what happens to the first part at morning startup must be defined. The system should issue its "Ready" signal only when the model is actually loaded, the camera is synchronized, and the PLC handshake has been verified.
Restarting a service may produce an immediate improvement; this can hide a persistent fault such as a memory leak or thermal problem. Restart intervals should be recorded in the long-term stability report, and the product's inspection status at each restart should be documented.
Fairness in multi-GPU / multi-camera performance testing
When comparing two models or two devices, input resolution, camera count, batch size, pre/postprocessing, and the result rule must be the same. Comparing only GPU inference metrics can be misleading when system architectures differ. If one device processes four cameras on a shared GPU while another processes two cameras, identical latency alone does not prove superiority.
In particular, the model pipeline should be fed real images. Uniform-color synthetic frames may be useful for measuring data transfer but may not realistically represent some preprocessing branches or compression behavior. A test dataset containing defective, good, shiny, and differently sized product examples is more meaningful.
How is Little's law used to interpret queues?
In a stable system, Little's law relates the average number of jobs in the system to the average arrival rate and average time spent in the system: L = λW. For example, in a stable flow processing 50 products per second with an average end-to-end system time of 0.12 seconds, there may be approximately six product jobs in the system on average. This calculation applies within the defined scope and under the stationarity assumption; the same interpretation cannot be used if the system is continuously accumulating work.
Camera FPS and the product arrival rate may not be the same. If three camera images are captured for each product, the image queue's rate differs from the product decision queue's rate. When analyzing with Little's law, it must be stated explicitly whether the unit of "work" is an image or a product. This is particularly important in systems where multiple images form a single decision.
Timestamp reliability when measuring jitter
Mixing camera, PC, and PLC clocks when measuring latency can make it appear that jitter is high. First, verify whether the measured events share the same clock reference. Measurements become clearer when using monotonic timestamps on the CPU, an appropriate timer on the GPU, and a common reference across devices.
Millisecond timestamp precision does not mean sub-millisecond differences are measured reliably. Invocation of a camera's frame-ready callback may be affected by operating system scheduling latency. Genuine hard timing requirements call for considering appropriate hardware timestamps, a control system, and, if necessary, a real-time operating infrastructure.
How should p95, p99, and maximum latency be reported?
When 10,000 products are processed in a test, p99 approximately describes the boundary of the slowest one percent. However, p99 results from two separate tests should not be compared directly unless their load conditions and sample counts are the same. Maximum latency and the actual number of products that exceed the deadline should also be reported. Operationally, "zero products exceeded the 500 ms decision window" may sometimes be a more important indicator than "p99 is 70 ms."
Examining the distribution as a histogram or timeline shows when faults become more frequent. For example, high latency near the end of shifts may be caused by thermal stress, log rotation, or a scheduled archiving job. A single percentile value does not explain every cause.
Priorities in systems running multiple models
If a camera runs classification, segmentation, and OCR on the same image, the execution order of the models and the components required for the final decision must be explicit. Holding a defect-rejection decision that does not depend on OCR until OCR finishes can create unnecessary latency. Conversely, if product identity is established through OCR, issuing a decision without the OCR result may cause incorrect matching.
The model graph should therefore be divided according to task dependencies. The shortest path required for the critical decision can be identified; informational analysis can run at a lower priority. However, because resources on the GPU are shared, even low-priority work may affect critical-path latency. Real-time load testing must be performed with concurrent jobs enabled.
An example of making a decision based on profiling results
Suppose a system's total p99 latency is measured at 140 ms. Its breakdown is 9 ms for camera transfer, 70 ms for preprocessing, 25 ms for inference, 8 ms for postprocessing, and 28 ms for other waiting. The largest bottlenecks are preprocessing and waiting. Reducing model time from 25 ms to 15 ms theoretically brings the total to 130 ms, whereas reducing unnecessary preprocessing copies may yield a greater gain.
Although these figures are illustrative, the method is general: first show which component lies on the critical path, then change one variable. After optimization, measure both quality and p99 again. This experimentally verifies the difference between a "faster model" and a "faster system."
Which faults should be deliberately introduced during testing?
Performance acceptance testing can cover not just normal traffic but also events such as a larger ROI due to low camera illumination, increased product traffic, MES network traffic, GPU thermal throttling, a late PLC ACK, and a brief camera disconnection. Each scenario records whether a product was lost, whether the decision fit within its valid time window, and which alarm the operator saw.
When the system makes a late decision, it is wrong to count this as success because "the correct result was produced." A correct model prediction that misses the production action is functionally invalid. A reliable design reports this condition with an explicit error code and applies the procedure approved for the process.
What happens if we change the starting point of a time measurement?
Suppose a system takes 12 ms to deliver an image from the camera to the application, 7 ms for preprocessing, 20 ms for inference, and 10 ms for PLC communication. Looking only at inference, we would call it a "20 ms system"; measuring from image delivery to the PLC ACK gives 49 ms. Adding exposure and trigger latency produces a longer duration. Moreover, the valve's mechanical response is not included in this calculation. All performance reports must therefore specify their measurement start and end events.
Timestamps used at hardware and operating system level must be synchronized. Subtracting timestamps from different machines without converting them to the same time base may produce negative or artificially high durations. This is not a model performance problem; it concerns the accuracy of the measurement system.
How do you justify a proposed performance improvement?
Where possible, a slowdown report should begin with the current state and target: "At peak line speed, p99 end-to-end latency is 210 ms; the acceptance limit is 180 ms." Measurements then identify the bottleneck. For example, if CPU preprocessing takes 80 ms, inference 30 ms, and queue waiting 60 ms, switching to TensorRT alone may not resolve most of the problem. Controlled changes to preprocessing and queueing are planned.
The new version is compared using the same load distribution for p50, p95, p99, lost products, and quality metrics. The improvement should be repeatable, not based on a single chance test run. Even if the result fits within the nominal decision window, it should be verified by a sustained thermal test whose duration and load coverage are determined by facility risk and operating conditions.
How do we test an increase in product rate in advance?
Suppose the system's camera rate is currently 40 frames per second and the target is 55 frames per second. Looking at single-inference time may suggest sufficient capacity. However, if CPU preprocessing takes 23 ms, that stage's theoretical capacity is approximately 43 frames/s. Unless preprocessing is parallelized, the queue may grow. Capacity testing should therefore cover the entire pipeline and different parallelism settings.
A short burst is a different case: if 55 frames per second arrive for only three seconds, a suitable buffer can absorb the surge. However, if the system's average rate is 40 frames/s, sustained input at 55 frames/s fills a finite buffer and new jobs may be lost; the queue grows without bound only under an unlimited-buffer assumption. Simply enlarging the buffer without making this distinction hides a long-term fault.
Example performance report: two different results on the same GPU
Suppose a model's microbenchmark measures 11 ms, while the average latency of the entire image processing system is 74 ms. At first glance, the model appears fast; however, 74 ms determines the actual field decision. Examining timestamps may reveal 13 ms for image acquisition, 9 ms for preprocessing, 11 ms for inference, 7 ms for postprocessing, 18 ms for queueing, and 16 ms for communication. These values are only an educational example; what matters is being able to show which stages make up total latency.
Reducing inference time from 11 ms to 7 ms on the same device theoretically saves 4 ms. Yet if queue waiting is 18 ms and the input rate is observed to increase at certain hours, the real performance shortfall may lie in the queueing discipline. Examining image processing order, multi-camera load, dedicated GPU streams, and bounded buffer usage may be more effective. The outcome of the change must be verified with the same load profile.
The report should include at least three different experiments. The first is a nominal workload with fixed product spacing. The second is the peak load caused by a brief increase in line speed. The third covers the thermal and memory effects of prolonged operation. Every experiment reports p50, p95, p99, the proportion of products with on-time results, and the number of lost/missing images. Adding latency subgroups by product family provides a more accurate view of production behavior than a single average.
If a change reduces the average to 60 ms while increasing p99 to 180 ms, the engineering decision becomes more difficult. If the physical rejection window is 150 ms, some products may have experienced a regression rather than an improvement. Optimization success is therefore measured against the system's agreed business objectives, not just a large FPS number on a benchmark screen.
Frequently asked questions
Does a system running at 100 FPS have 10 ms latency?
No. FPS measures the rate of completed frames; latency measures the time from a single frame's entry to the result point. Because of parallel processing and queueing, these values are not directly reciprocal.
Does p99 latency provide a hard real-time guarantee?
No. p99 is a percentile of observed data; more extreme samples may exist. A hard real-time requirement needs separate scheduling, hardware, and validation methodologies.
Should a larger model be chosen if GPU utilization is low?
First, CPU preprocessing, data copying, SDK buffering, and synchronization bottlenecks should be measured. Low GPU utilization does not always mean there is spare computing capacity.
Should batch size be chosen for maximum throughput?
No. It should be optimized together with the maximum permitted end-to-end latency, product arrival pattern, and quality requirements.
Interactive tool: latency and rejection distance
The six durations are added assuming a sequential critical path and constant speed. Adding the p99 values of separate stages does not give end-to-end p99. Zero time margin leaves no reserve; this calculation is not a safety or production-suitability approval.
Important distinction for percentiles: Adding the individually measured p99 values of stages does not give the p99 of total latency. The breakdown above is an illustrative example explaining the critical path of the same individual slow event; end-to-end p99 must be measured separately from per-product start and end times.
Technical sources and verification
Manufacturers' and standards organizations' documentation forms the basis for details of standards and runtimes used by these methods. Unless explicitly stated otherwise, all example figures are for educational purposes.
Visual note: The nine technical diagrams are original, and numerical examples are for educational purposes. The illustrations are not actual device benchmarks, facility measurements, or factory acceptance tests.