| With the continuous progress of technology and the increasing level of intelligence,machine vision is increasingly widely applied in various fields.However,in order to ensure the effectiveness and accuracy of machine vision applications,it is crucial to obtain high-quality image captures.As a key means to achieve high quality image acquisition,autofocus technology has been widely used in various daily life and industrial fields.However,due to the limitations of imaging principles,autofocus systems often encounter focusing errors.Especially when focusing on moving targets,such as autonomous walking of smart robots,automatic driving of cars or engineering machinery,etc.,the object is always in a constantly moving state,which brings greater challenges to autofocus.Therefore,how to maintain continuous focus on moving targets has become a very important research task.Based on the research of autofocus technology at home and abroad,this article proposes an autofocus method for moving targets,focusing on the commonly used open-loop control autofocus system.The main research contents are as follows:Firstly,the basic theory of autofocus was studied.This paper explains the basic structure and working principle of autofocus system,analyzes the systematic errors,random errors,and dynamic errors that exist in the focusing process,which provides theoretical support for research on autofocus methods for moving targets.Secondly,autofocus algorithms for stationary targets were studied.Aiming at the hysteresis error or return error in the open-loop control autofocus system and the random error caused by image noise,an autofocus algorithm based on the similarity of focus measure data was proposed.The algorithm introduces data similarity algorithm on the basis of improving curve fitting algorithm,effectively accomplishing autofocus for stationary targets through the improvement and combination of the two algorithms.Experimental results showed that under the same conditions,the accuracy of this algorithm is about 30% higher than that of hillclimbing method and Fibonacci search method,and it has higher focusing accuracy and antinoise ability,which can effectively reduce the influence of random errors.Additionally,since the algorithm can directly adjust the lens to the optimal focus position without lens reset,it solves the problem of systematic error in the focusing process.It lays a foundation for the research of automatic focusing method for moving objects.Thirdly,the detection algorithm for moving targets was studied.Aiming at the problem of traditional motion target detection algorithms is easy to be affected by noise and has multiple detection boxes,an improved motion target detection algorithm was proposed.This algorithm uses the method of finding the maximum value in the difference image,and introduces the image segmentation technology on this basis,effectively achieving system detection and extraction of moving targets.Experimental results showed that the improved algorithm effectively removed the influence of noise on motion target detection compared to the previous algorithm and had higher noise resistance.Finally,the autofocus compensation algorithm for moving targets was studied.In response to the problem of dynamic errors caused by continuous movement of objects during focusing,a focus compensation algorithm for moving targets was proposed based on the principles of autofocus and optical imaging.This algorithm estimated the object’s movement state by continuously focusing and then solved the compensation amount of the lens movement to achieve focus compensation for moving targets.Experimental results showed that the images captured after compensation using this algorithm had higher focus measure values compared to those captured before compensation,effectively improving the autofocus accuracy for moving targets. |