Summary of the invention
For the problem that prior art exists, fundamental purpose of the present invention is to provide that a kind of data volume is little, storage speed fast, access easily Machine Vision Detection result's storage file and method.
For achieving the above object, the invention provides a kind of Machine Vision Detection result's storage file, for the testing result after the storage Machine Vision Detection.This Machine Vision Detection result's storage file comprises an image data file and an image list file, this image data file comprises one with the view data after the compression of epigraph with for the testing result data of this view data, the testing result data of this each image are followed by the back that is stored in the view data after the corresponding compression, this image list file comprises file header information and image set essential information, this document header is the foundation that all view data are compressed, and this document header only comprises quantization table and Huffman table, omit other file header information except quantization table and Huffman table in the common jpeg image, and only preserved file header information one time for all view data to be compressed.In addition, this image list file also comprise store in the image data file all the compression after view data and the positional information of testing result data, specifically, start address and the data length of view data after the positional information of the view data after the compression refers to compress in image data file, the positional information of testing result data in image data file refer to start address and the data length of testing result data in image data file.In addition, this image list file also comprises width and the elevation information of all view data of storing in the image data file.
The present invention also provides a kind of Machine Vision Detection result's storage means, and for the testing result after the storage Machine Vision Detection, this storage means comprises following steps:
(1) creates an image list file and an image data file;
The file header information of the foundation that (2) will compress as view data to be stored is kept in the image list file, and only preserve file header information one time for all view data to be compressed, this document header only comprises quantization table and Huffman table, omitted other file header information except quantization table and Huffman table in the common jpeg image, and this quantization table is to set up by the quality factor that input compressed images data need reach;
(3) view data to be stored is compressed according to the file header information of preserving in the image list file;
(4) view data after will compressing is stored in the image data file;
(5) positional information of view data in image data file after the compression of the current storage of record in the image list file, start address and the data length of view data after the positional information of view data after the compression of this image list file record in image data file refers to compress in image data file, in addition, width and the elevation information of image list file all view data of also storing in the recording image data file;
(6) with the back of the view data of the testing result data after the Machine Vision Detection after followed by the compression that is kept at current storage, the view data after the compression and testing result data consist of the storage to the current detection image;
(7) positional information of testing result data in image data file of the current storage of record in the image list file, the positional information of these testing result data in image data file refers to start address and the data length of testing result data in image data file;
Whether the remaining space of (8) judging disk can store lower piece image;
(9) if any the lower piece image of remaining space storage, then continue next view data to be stored is compressed; Otherwise, write end-of-file mark, finish the preservation of image.
View data to be stored compressed according to the file header information of preserving in the image list file comprises following steps:
(1) view data is divided into a plurality of 8 * 8 matrix, the multiple of less than 8 by 8 multiple 0 polishing;
(2) each matrix of 8 * 8 is done cosine transform, obtain a matrix of frequency coefficients;
(3) coefficient of frequency after the cosine transform being carried out data quantizes;
(4) to encode view data after namely obtaining compressing of the view data after quantizing.
In addition, when view data to be stored is gray level image, when then view data to be stored being compressed, only the Y value of gray level image is compressed, can greatly be improved the compression speed of view data.
Compared with prior art, beneficial effect of the present invention is: (1) data volume is little: all images are kept at after overcompression in the image data file, so data volume is very little; (2) storage speed is fast, safe: when processing gray level image, the data compression time only need be compressed the time of the jpeg format data about 1/3 of same data volume, has prevented from falling with the JPEG compress mode in high speed image storage the situation of figure.(3) common jpeg image is when storage, all need preserve file header information one time for each image, the present invention is when storing image data, omitted the file header information of some JPEG, as image recognition information, compressibility etc. have been omitted, and identical file header information such as quantization table, Huffman table, only preserve once for all images, suitable minimizing the size of file, and preserve again by after view data is compressed, then reduced greatly the data volume of file, be user-friendly to; (4) access fast: record view data after the compression and the listing file of testing result data essential information by creating an image data file and one, all view data and detection data all are stored together, can make things convenient for data copy and detect data transmission, can realizing also the testing result data follow to detect, picture is walked, be convenient to targetedly fast viewing files.And owing to only need just can find needed view data and testing result data by an image list file, also greatly improved speed and the convenience of access.
Embodiment
Below in conjunction with accompanying drawing, describe the specific embodiment of the present invention in detail.
As shown in Figure 1, be the structural drawing of JPEG in the prior art (Joint Photographic Experts Group) image.JPEG (Joint Photographic Experts Group) is an international digital image compression standard of being set up for still image by International Standards Organization (ISO:International Standardization Organization) and Consultative Committee on International Telephone and Telegraph (CCITT) (CCITT:Consultation Commitee of the International Telephone and Telegraph).The jpeg image 10 of process JPEG compression standard compression comprises view data 14 two parts after file header 12 and the compression, and wherein file header 12 comprises image recognition information 121, quantization table 122, Huffman table 123, compressibility 124 and image essential information 125 etc.Wherein quantization table 122 is to set up according to the quality factor of input, and the quality factor of input is larger, and then the compressibility after the compression of images 124 is higher.And image essential information 125 comprises width 1251, the height 1252 etc. of view data.
Specify the effect of these fields that comprise in the file header 12 below by the compression step of JPEG.The JPEG compression specifically comprises the steps:
(1) color conversion: because JPEG only supports that (Y represents gray-scale value to YUV, U, V represent colourity) data structure of color mode, and do not support RGB (Red, Green, Blue) data structure of image is so before coloured image is compressed, must be the image of YUV pattern with the image transitions of RGB pattern, if gray-scale map does not then need this step.Also need to carry out data sampling after converting.The general sampling ratio that adopts is 2: 1: 1 or 4: 2: 2.After having carried out sampling work, per two row data only keep delegation.Therefore, half that boil down to is original of image data amount after the sampling.
(2) dct transform.DCT (Discrete Consine Transform, discrete cosine transform) be with picture signal in the enterprising line translation of frequency field, isolate the processing procedure of high and low frequency information.And then the HFS of image compressed, to reach the purpose of compressing image data.At first image is divided into a plurality of 8 * 8 matrix, then each matrix is made dct transform, obtain a matrix of frequency coefficients after the conversion, coefficient of frequency wherein all is floating number.
(3) quantize.Coefficient of frequency after the conversion is quantized, convert it to integer.According to the input quality factor set up quantization table 122, quality factor choose with compress after picture quality and compressibility 124 close relationship is arranged.The value of quality factor is selected too much, can increase substantially compressibility 124, but picture quality is just poor; Otherwise quality factor is less, and picture quality is better, but compressibility 124 is lower.
(4) coding.The dct transform of front and quantification are to prepare for coding stage.Coding adopts two kinds of mechanism: one is the run length encoding of 0 value; The 2nd, entropy coding (Entropy Coding) is namely finished the compression of image after coding is finished.
Machine Vision Detection result's of the present invention storage file is for the testing result after the storage Machine Vision Detection.This Machine Vision Detection result's storage file comprises an image data file 40 and an image list file 20.
As shown in Figure 4, be the structural drawing of the image data file 40 of Machine Vision Detection result store file of the present invention.This image data file 40 comprises the image more than or, as shown in Figure 4, comprise [the 1st image], [the 2nd image] ... [n image], the quantity of image is by the size of every image and the common decision of size of disk, and all images all are stored in the image data file 40.Every image all comprises view data 14 and the testing result data 41 after the compression, and the view data of this storage is through overcompression, and compress mode can be identical with the compress mode of common JPEG.Characteristics are, the testing result data 41 of each image are followed by the back that is stored in the view data 14 after the corresponding compression, with convenient inquiry.It is pointed out that in this image data file 40 that view data 14 after the compression of storage does not comprise such as file header information such as the quantization table 122 that comprises in the common jpeg image, Huffman tables 123.
As shown in Figure 2, be image list file 20 structural drawing of Machine Vision Detection result store file of the present invention.These image list file 20 include file beginning flags 21, quantization table 122, Huffman table 123, image set essential information 22 and end-of-file mark 23.For all images in the image data file 40, only preserve the file header information that is once formed by quantization table 122, Huffman table 123, quantization table 122 is to set up by the quality factor that the input compressed images need reach, the quality factor of this input is determining compressibility and the compression quality of image, and these information are all for compressing to provide foundation to view data.It should be noted that the file header information that the image list file 20 is here preserved only comprises quantization table 122 and Huffman table 123, and omitted other file header information except quantization table 122 and Huffman table 123 in the common jpeg image.And for each image in the image data file 40, set up respectively image essential information 125, as shown in Figure 4, comprise [the image essential information 125 of the 1st image], [the image essential information 125 of the 2nd image] ..., until [the image essential information 125 of n image], common composition diagram image set essential information 22.
As shown in Figure 3, be the structural drawing of the image essential information 125 of image list file 20.The image essential information 125 of every image all comprises the width 1251 of view data, the height 1252 of view data, also comprises the positional information that view data 14 after the compression and testing result data 41 are stored in image data file 40.The start address 1253 of view data 14 after the positional information of view data 14 in image data file 40 after this compression comprises compression in image data file 40 and the data length 1254 of the view data after the compression; Equally, positional information inclusion test result data 41 start address 1255 in image data file 40 and the data length 1256 of testing result data 41 of testing result data 41 in image data file 40.The positional information that view data 14 after the compression of preserving according to image list file 20 and testing result data 41 stores in image data file 40 can find the position of need query image in image data file 40.
As shown in Figure 5, the storage means process flow diagram for Machine Vision Detection result of the present invention specifically comprises the steps:
S51, an image list file 20 of establishment and an image data file 40;
The file header information of S52, the foundation that will compress as view data to be stored is kept in the image list file 20, and only preserves file header information one time for all view data to be compressed.File header information comprises quantization table 122 and Huffman table 123, this quantization table 122 is to set up by the quality factor that the input compressed images need reach, setting up quantization table 122 rear regeneration Huffman tables 123, again quantization table 122 and Huffman table 123 are kept in the image list file 20 afterwards.It should be noted that the file header information that the image list file 20 is here preserved only comprises quantization table 122 and Huffman table 123, and omitted other file header information except quantization table 122 and Huffman table 123 in the common jpeg image;
S53, view data to be stored is compressed according to the file header information of preserving in the image list file 20.Specifically comprise the steps: at first view data to be divided into a plurality of 8 * 8 matrix, the multiple of less than 8 by 8 multiple 0 polishing; Secondly, each matrix is done cosine transform, obtain a matrix of frequency coefficients; Again, the coefficient of frequency after the cosine transform being carried out data quantizes; At last, the view data after quantizing is encoded, if view data is colored, then at first also needing the RGB image transitions is the YUV image.It should be noted that if for gray level image, then have some difference with common JPG compress mode.When using common JPG compress mode that gray level image is compressed, at first gray level image is become YUV (Y represents gray-scale value, and U, V represent colourity) form, wherein Y is exactly gray value data after changing.And for gray level image, U and V value all are 0.Common JPG compress mode is not only compressed Y value, also will the data value of U and V be compressed respectively.But in high speed machines vision system of the present invention, when gray level image is compressed, because the U in the gray level image and V value all are 0, if it is compressed processing, not only lose time, but also take up room data after the store compressed.Therefore in gray-scale map compression method of the present invention, only Y (gray-scale value) is compressed processing, directly give up U and V value.Proof by experiment, the compression speed of this compression method only be original 1/3rd, and the data volume after compressing has also reduced.
S54, the view data 14 after will compressing are stored in the image data file 40;
S55, in image list file 20, record the essential information of the view data 14 after the compression of image of current storage, comprise the width 1251 of view data, height 1252, the start address 1253 of the view data 14 after the compression in image data file 40 and the data length 1254 of the view data after the compression of view data;
The back of S56, the testing result data 41 after Vision Builder for Automated Inspection the processed view data 14 after followed by the compression that is kept at current storage, the storage that the view data 14 after the compression and testing result data 41 consist of the current detection image;
S57, in image list file 20, record the reference position 1255 of testing result data 41 in image data file 40 and the data length 1256 of testing result data 41 of the image of storage;
S58, judge whether the remaining space of disk can store lower piece image, if can also store lower piece image, then to S53, otherwise, to S59;
S59, write end-of-file mark, finish the preservation of image.
Behind the storage means storage file that uses Machine Vision Detection result as shown in Figure 5, as described in Figure 6, the process flow diagram for the present invention accesses Machine Vision Detection result store file specifically comprises the steps:
S61, open image list file 20 and image data file 40;
S62, find the position of view data 14 in image data file 40 after the compression that needs query image according to the start address 1253 of the view data 14 after the compression of the image of preserving in the image list file 20 and data length 1254;
S63, from image data file 40, read the view data 14 after the compression of the image that needs inquiry;
S64, the view data 14 after the compression in the image is decompressed, recover the view data before the compression;
Start address 1255 and the data length 1256 of the testing result data 41 of S65, the image preserved according to image list file 20 find the position of testing result data 41 in image data file 40 that needs query image;
S66, the testing result data 41 of reading image from image data file 40 finally obtain needing view data and the testing result data 41 of query image.
More than introduced Machine Vision Detection result's storage file and method, can make the file data quantitative change of storage little, storage speed is accelerated and convenient access.But the present invention is not limited to above embodiment, and any technical solution of the present invention that do not break away from is namely only carried out improvement or the change that those of ordinary skills know to it, all belongs within protection scope of the present invention.