Disclosure of Invention
The application provides an industrial camera and a control method thereof, which aim to solve the technical problem.
In order to achieve the above purpose, the embodiment of the present application adopts the following technical scheme:
in a first aspect, some embodiments of the present application provide a control method of an industrial camera, the method including:
determining an acquisition cache queue and an algorithm cache queue, wherein M acquisition cache data are arranged in the acquisition cache queue, the acquisition cache data comprise an acquisition sequence number, an acquisition locking state and acquisition cache contents, M algorithm cache data are arranged in the algorithm cache queue, and the algorithm cache data comprise an algorithm sequence number, an algorithm locking state and algorithm cache contents;
judging the acquisition locking state in the acquisition cache queue and the algorithm locking state in the algorithm cache queue;
if the acquisition cache data with the acquisition locking state of no exists in the acquisition cache queue, the acquisition serial number of the acquisition cache data is i (i is less than or equal to M), performing an image shooting processing step, and storing image content into the acquisition cache content of the ith acquisition cache data, wherein the acquisition locking state of the ith acquisition cache data is set to be yes;
if the acquisition cache queue contains acquisition cache data with the acquisition locking state being yes, the acquisition serial number is i (i is less than or equal to M), the acquisition cache content of the ith acquisition cache data is subjected to algorithm processing to obtain an algorithm processing result, and the acquisition locking state of the ith acquisition cache data is set to be no;
if the algorithm cache queue contains algorithm cache data with the algorithm locking state of no, the algorithm serial number of the algorithm cache queue is j (j is less than or equal to M), an algorithm processing result is stored in algorithm cache content of the jth algorithm cache data, and the algorithm locking state of the jth algorithm cache data is set to be yes;
if the algorithm cache queue contains algorithm cache data with the algorithm locking state being yes, the algorithm serial number of the algorithm cache data is j (j is less than or equal to M), the algorithm cache content of the jth algorithm cache data is subjected to a data transmission processing step, and the algorithm locking state of the jth algorithm cache data is set to be no.
In one possible implementation, the method further includes:
and if no acquisition cache data with the acquisition locking state being no exists in the acquisition cache queue, judging whether the acquisition cache data with the acquisition locking state being no exists in the acquisition cache queue or not after the preset time.
In one possible implementation, the method further includes:
and if the acquisition cache data with the acquisition locking state being yes does not exist in the acquisition cache queue, judging whether the acquisition cache data with the acquisition locking state being yes exists in the acquisition cache queue or not after the preset time.
In one possible implementation, the method further includes:
if no algorithm cache data with the algorithm locking state being no exists in the algorithm cache queue, judging whether collected cache data with the algorithm locking state being no exists in the algorithm cache queue or not after the preset time.
In one possible implementation, the method further includes:
if the algorithm cache data with the algorithm locking state being yes does not exist in the algorithm cache queue, judging whether the algorithm cache data with the algorithm locking state being no exists in the algorithm cache queue or not after the preset time.
In one possible implementation manner, the acquisition locking state is used for marking whether corresponding acquisition cache data is occupied;
if the acquisition locking state is yes, the corresponding acquisition cache data is occupied and can be used for algorithm processing;
if the acquisition locking state is negative, the corresponding acquisition cache data is not occupied and can be used for image shooting processing.
In one possible implementation manner, the algorithm locking state is used for marking whether corresponding algorithm cache data is occupied;
if the algorithm locking state is yes, the corresponding algorithm cache data is occupied and can be used for data transmission processing;
if the algorithm locking state is no, the corresponding algorithm cache data is not occupied and can be used for storing the algorithm processing result.
In one possible implementation, the method further includes:
acquiring a first mark, a second mark and a third mark;
stopping the operation of the industrial camera when the first mark, the second mark and the third mark all represent the end;
when at least one of the first flag, the second flag, and the third flag indicates not to end, the industrial camera continues to operate.
In a second aspect, some embodiments of the present application provide an industrial camera, the industrial camera including a processor, the processor having a plurality of cores, the plurality of cores respectively configured to process image capturing, algorithm processing, and data transmission; the industrial camera employs the control method of the first aspect.
In a second aspect, some embodiments of the present application provide a machine vision system comprising a light source, an industrial camera, a lens, an image acquisition and processing device; the industrial camera employs the control method of the first aspect.
According to the industrial camera and the control method thereof, the image shooting, the algorithm processing and the data transmission are respectively processed through the acquisition buffer queue, the algorithm buffer queue and the three processing branches, and the three processing branches are controlled through the acquisition locking state of the acquisition buffer queue and the algorithm locking state of the algorithm buffer queue, so that the three processing branches are mutually connected without being mutually restricted, for example: if the acquisition cache data with the acquisition locking state of no exists in the acquisition cache queue, the acquisition serial number is i, an image shooting processing step is carried out, and image content is stored into the acquisition cache content of the ith acquisition cache data, and the acquisition locking state of the ith acquisition cache data is set to be yes; according to the application, through the control method of the industrial camera, the running water type parallel processing is realized, so that the processing time of the industrial camera is shortened, and the detection efficiency is improved.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Each frame of picture in the industrial camera is required to be subjected to image shooting, algorithm processing and data transmission processing, and the three processing steps have dependence, because the image shooting is a plurality of 2D images shot under the synchronization of the industrial camera and the light source, and each 2D image has information of different light source characteristics; carrying out algorithm processing on a plurality of shot 2D images to obtain 3D data; the data transmission passes the 3D data to the image acquisition and processing device,
in order to solve the above problems, some embodiments of the present application provide a control method for an industrial camera, which controls an overall processing flow of the industrial camera by combining a pipeline working mode, and fully utilizes hardware resources by overlapping processing procedures in parallel, so as to improve an acquisition frequency of the industrial camera and an overall detection rate of a machine vision system.
The control method of the industrial camera provided by the application achieves the working mode shown in figure 2, the processing steps of each frame of image are overlapped in parallel, the hardware resources of the industrial camera are fully utilized, the acquisition frequency of the industrial camera is improved, the industrial camera can be a 3D industrial camera,
to achieve the operation mode shown in fig. 2, the control method of the industrial camera combines the pipeline operation mode with the buffer queue as shown in fig. 3, and the control method may include the following steps:
s101, determining an acquisition cache queue and an algorithm cache queue.
The acquisition buffer queue is provided with M acquisition buffer data, and the algorithm buffer queue is also provided with M algorithm buffer data.
As shown in fig. 4, the acquisition buffer data includes an acquisition sequence number I (i=1 to i=m), an acquisition lock state LG, and an acquisition buffer content TG. As shown in fig. 5, the algorithm cache data includes an algorithm number J (j=1 to j=m), an algorithm lock state LA, and an algorithm cache content TA.
S102, performing image shooting processing through a first thread.
The first thread has a first flag F1, and the first flag F1 is used to determine whether to end the first thread.
The acquisition locking state is used for marking whether corresponding acquisition cache data are occupied or not, and if the acquisition locking state is yes, the acquisition cache data are occupied and can be used for algorithm processing; if the acquisition locking state is no, the acquisition locking state is not occupied and can be used for image shooting processing.
And if the acquisition cache data with the acquisition locking state of no does not exist in the acquisition cache queue, judging after waiting for the preset time.
If the acquisition cache data with the acquisition locking state being no exists in the acquisition cache queue, the acquisition serial number is i, the image shooting processing step is carried out, the image content is stored into the acquisition cache content of the ith acquisition cache data, and the acquisition locking state of the ith acquisition cache data is set to be yes.
For example, firstly, whether the acquisition buffer queue has acquisition buffer data with the acquisition locking state being no is judged, if the acquisition buffer queue does not have the acquisition buffer data with the acquisition locking state being no, the processing is waited for 10 milliseconds, and whether the acquisition buffer queue has the acquisition buffer data with the acquisition locking state being no is judged again; if the collection cache queue contains collection cache data with a collection locking state of no, the collection serial number is 2, the image shooting processing step is executed, the image content is stored in the collection cache content of the 2 nd collection cache data, and the collection locking state of the 2 nd collection cache data is set to be yes. Finally, judging a first mark F1, and if the first mark F1 is yes, jumping out of the loop of the first thread; if the first flag F1 is negative, the loop of the first thread continues.
S103, performing algorithm processing through a second thread.
The second thread has a second flag F2, and the second flag F2 is used to determine whether to end the second thread.
Firstly, judging an acquisition locking state in an acquisition cache queue, wherein the acquisition locking state is used for marking whether corresponding acquisition cache data are occupied or not, and if the acquisition locking state is yes, the acquisition cache data are occupied and can be used for algorithm processing; if the acquisition locking state is no, the acquisition locking state is not occupied and can be used for image shooting processing.
And if the acquisition cache data with the acquisition locking state being yes does not exist in the acquisition cache queue, judging after waiting for a preset time.
If the acquisition cache data with the acquisition locking state being yes exists in the acquisition cache queue, the acquisition serial number is i, the acquisition cache content of the ith acquisition cache data is subjected to algorithm processing to obtain an algorithm processing result, and the acquisition locking state of the ith acquisition cache data is set to be no.
Then determining an algorithm locking state in an algorithm cache queue, wherein the algorithm locking state is used for marking whether corresponding algorithm cache data are occupied or not, and if the algorithm locking state is yes, the algorithm cache data are occupied and can be used for data transmission processing; if the algorithm locking state is no, the algorithm locking state is not occupied and can be used for saving the algorithm processing result.
If no algorithm cache data with the algorithm locking state being no exists in the algorithm cache queue, judging after waiting for a preset time.
If the algorithm cache queue contains algorithm cache data with the algorithm locking state of no, the algorithm serial number of the algorithm cache queue is j, an algorithm processing result is stored in the algorithm cache content of the jth algorithm cache data, and the algorithm locking state of the jth algorithm cache data is set to be yes.
For example, firstly, whether the acquisition buffer data with the acquisition locking state being yes exists in the acquisition buffer queue is judged, if the acquisition buffer data with the acquisition locking state being yes does not exist in the acquisition buffer queue, the waiting time is 10 milliseconds, and whether the acquisition buffer data with the acquisition locking state being yes exists in the acquisition buffer queue is judged again; if the collection cache queue contains collection cache data with the collection locking state being yes, the collection serial number is 2, the algorithm processing step is executed on the collection cache content of the 2 nd collection cache data, and the collection locking state of the 2 nd collection cache data is set to be no. Secondly, judging whether algorithm cache data with the algorithm locking state being NO exists in the algorithm cache queue, if no algorithm cache data with the algorithm locking state being NO exists in the algorithm cache queue, waiting for 10 milliseconds, and judging whether the algorithm cache data with the algorithm locking state being NO exists in the algorithm cache queue again; if the algorithm cache data with the algorithm locking state of no exists in the set cache queue, the algorithm serial number is 5, the algorithm processing step is executed on the algorithm cache content of the 5 th algorithm cache data, and the algorithm locking state of the 5 th algorithm cache data is set to be yes. Finally, judging a second mark F2, and if the second mark F2 is yes, jumping out of the loop of the second thread; if the second flag F2 is negative, the loop of the second thread continues.
S104, carrying out data transmission processing through a third thread.
The third thread has a third flag F3, and the third flag F3 is used to determine whether to end the third thread.
Judging an algorithm locking state in the algorithm cache queue, wherein the algorithm locking state is used for marking whether corresponding algorithm cache data are occupied or not, and if the algorithm locking state is yes, the algorithm cache data are occupied and can be used for data transmission processing; if the algorithm locking state is no, the algorithm locking state is not occupied and can be used for saving the algorithm processing result.
If the algorithm cache queue does not contain the algorithm cache data with the algorithm locking state being yes, judging after waiting for a preset time.
If the algorithm cache queue contains algorithm cache data with the algorithm locking state of yes, the algorithm serial number of the algorithm cache data is j, the algorithm cache content (namely an algorithm processing result) of the jth algorithm cache data is subjected to a data transmission processing step, and the algorithm locking state of the jth algorithm cache data is set to be no.
For example, firstly determining whether there is algorithm cache data with the algorithm locking state being yes in the algorithm cache queue, if there is no algorithm cache data with the algorithm locking state being yes in the algorithm cache queue, waiting for 10 ms, and determining whether there is algorithm cache data with the algorithm locking state being yes in the algorithm cache queue again; if the algorithm cache data with the algorithm locking state being yes exists in the set cache queue, the algorithm serial number is 5, the algorithm cache content (namely an algorithm processing result) of the 5 th algorithm cache data is transmitted, and the algorithm locking state of the 5 th algorithm cache data is set to be yes. Finally, judging a third mark F3, and if the third mark F3 is yes, jumping out of the loop of the third thread; if the third flag F3 is negative, the loop of the third thread continues.
S105, when the first flag, the second flag, and the third flag each indicate the end, the industrial camera ends the present control.
And clearing the acquisition buffer queue and the algorithm buffer queue, and closing the first thread, the second thread and the third thread.
In some embodiments, the industrial camera continues to perform the present control when at least one of the first flag, the second flag, and the third flag indicates not ended.
The application improves the acquisition frequency of the industrial camera by the control method of the industrial camera, and the specific time slice circulation condition which can be realized in the application is shown in the following figure 2:
at time slice 1: the 1 st frame is used for shooting images, and the 2 nd and 3 rd frames are not started yet;
at time slice 2: carrying out algorithm processing on the 1 st frame, carrying out image shooting on the 2 nd frame, and not beginning the 3 rd frame;
at time slice 3: carrying out data transmission on the 1 st frame, carrying out algorithm processing on the 2 nd frame, and carrying out image shooting on the 3 rd frame;
at time slice 4: the 1 st frame is finished, the 2 nd frame is subjected to data transmission, the 3 rd frame is subjected to algorithm processing, and the 4 th frame is subjected to image shooting;
at time slice N: ending the N-3 th frame, carrying out data transmission on the N-2 th frame, carrying out algorithm processing on the N-1 th frame, and carrying out image shooting on the N th frame;
at time slice n+3: ending the N frame, carrying out data transmission on the N+1st frame, carrying out algorithm processing on the N+2nd frame, and carrying out image shooting on the N+3rd frame;
from the above, the processing of N frames of pictures is completed in the existing working mode, and 3N time slices are required; the optimized assembly line working mode of the industrial camera control method provided by the application only needs n+3 time slices, so that the time is reduced and the efficiency is improved.
In one embodiment, the three steps of image capturing, algorithm processing, and data transmission in each frame of picture do not reach the same time length, so the length of each time slice is determined by the most time-consuming one of the steps that are currently in progress.
Some embodiments of the present application further provide an industrial camera, where the industrial camera includes a processor, where the processor has a plurality of cores, where the plurality of cores are respectively used to process image capturing, algorithm processing, and data transmission; the industrial camera adopts the control method.
Some embodiments of the present application also provide a machine vision system, where the machine vision system includes a light source, an industrial camera, a lens, and an image acquisition and processing device; the light source, the industrial camera and the image acquisition and processing equipment are connected, the industrial camera is connected with the lens, the control of the machine vision system is realized through the image acquisition and processing equipment, and the industrial camera adopts the control method.
In some embodiments, the machine vision system may further comprise a controller coupled to the industrial camera, the image acquisition and processing device for controlling the machine vision system.
According to the industrial camera and the control method thereof, the image shooting, the algorithm processing and the data transmission are respectively processed through the acquisition buffer queue, the algorithm buffer queue and the three processing branches, and the three processing branches are controlled through the acquisition locking state of the acquisition buffer queue and the algorithm locking state of the algorithm buffer queue, so that the three processing branches are mutually connected without being mutually restricted, for example: if the acquisition cache data with the acquisition locking state of no exists in the acquisition cache queue, the acquisition serial number of the acquisition cache data is i (i is less than or equal to M), performing an image shooting processing step, and storing image content into the acquisition cache content of the ith acquisition cache data, wherein the acquisition locking state of the ith acquisition cache data is set to be yes; according to the application, through the control method of the industrial camera, the running water type parallel processing is realized, so that the processing time of the industrial camera is shortened, and the detection efficiency is improved.
The above is only for illustrating the technical idea of the present application, and the protection scope of the present application is not limited by this, and any modification made on the basis of the technical scheme according to the technical idea of the present application falls within the protection scope of the claims of the present application.
Furthermore, the order in which the elements and sequences are presented, the use of numerical letters, or other designations are used in the application is not intended to limit the sequence of the processes and methods unless specifically recited in the claims. While certain presently useful embodiments have been discussed in the foregoing disclosure by way of various examples, it is to be understood that such details are for the purpose of illustration only and that the appended claims are not limited to the disclosed embodiments, but rather are intended to cover all modifications and equivalent combinations that fall within the spirit and scope of the embodiments of the present application. For example, while the system components described above may be implemented by hardware devices, they may also be implemented solely by software solutions, such as installing the described system on an existing server or mobile device.
Similarly, it should be appreciated that in order to simplify the present disclosure and thereby facilitate an understanding of one or more embodiments, various features are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure. This method of disclosure, however, is not intended to imply that more features than are required by the subject application. Indeed, less than all of the features of a single embodiment disclosed above.
Each patent, patent application publication, and other material, such as articles, books, specifications, publications, documents, etc., cited herein is hereby incorporated by reference in its entirety. Except for the application history file that is inconsistent or conflicting with this disclosure, the file (currently or later attached to this disclosure) that limits the broadest scope of the claims of this disclosure is also excluded. It is noted that the description, definition, and/or use of the term in the appended claims controls the description, definition, and/or use of the term in this application if there is a discrepancy or conflict between the description, definition, and/or use of the term in the appended claims.