직접 읽기 모드를 사용하여 IT 부서에 이미지 전송
이미지를 직접 전달하는 경우, varargin 매개변수에는 두 개의 추가 mxArray 가 포함됩니다. 하나는 적절한 유형(부호 있는 또는 부호 없는 8, 16 또는 32비트 정수)의 이미지 데이터를 포함하고, 다른 하나는 이미지를 디코딩(또는 재구성)하는 데 필요한 정보를 포함하는 JSON 형식의 char*입니다 .
rawFile 매개변수는 mxCreateNumericMatrix() 함수를 사용하여 생성되며, 이 함수에는 행 수( 1 ), 이미지 배열 크기, 데이터 형식을 나타내는 상수( mxINT8_CLASS , mxUINT8_CLASS , mxINT16_CLASS , mxUINT16_CLASS , mxINT32_CLASS 또는 mxUINT32_CLASS 중 하나), 그리고 상수 mxReal 이 전달됩니다. 다음으로, mxFree() 함수를 사용하여 원본 데이터를 할당 해제하고, setData() 함수를 호출하여 이미지 배열을 mxArray 매개변수에 복사합니다.
varargin 매개변수는 Cell Array 형식의 mxArray 입니다. mxCreateCellMatrix() 함수를 사용하여 배열을 생성한 다음 mxSetCell() 함수를 사용하여 추가 인수를 배열에 추가합니다.
RGB 및 RAW 이미지의 경우 JSON 객체에는 이미지 너비 , 높이 , 색상 수(ncolors), 파일 루트 및 확장자가 포함되어야 합니다. RAW 이미지인 경우, Read Raw 유틸리티를 사용하여 INI 파일에 구성된 확장자를 사용하고, 그렇지 않은 경우 아래 표에서 옵션을 참조하십시오. 파일 루트는 출력 파일을 저장할 위치와 출력 파일 이름을 지정하는 데 사용됩니다. 다음 C 코드 스니펫은 부호 없는 short 형 이미지 배열과 JSON 메타데이터 문자열을 mlfBlemish_shell() 함수에 전달합니다.
unsigned short *rawPixels;
unsigned int pixelCount;
mxArray *outputJSON = NULL, *inputFile = NULL, *rootDir = NULL, *inputKeys = NULL, *opMode = NULL, *varargin = NULL, *imageData = NULL, *jsonData = NULL;
inputFile = mxCreateString("");
rootDir = mxCreateString("C:\ImatestSamples\");
opMode = mxCreateString("-15");
inputKeys = mxCreateString( "JSON");
jsonData = mxCreateString("{ "height": 1296, "width": 808, "ncolors": 1, "extension": "raw", "fileroot": "C:\ImatestSamples\blemish.raw"}}");
/// Load the image data from your source ...
imageData = mxCreateNumericMatrix(1, pixelCount, mxUINT16_CLASS, mxREAL );
mxFree((mxArray*)mxGetData(imageData));
mxSetData(imageData, rawPixels);
varargin = mxCreateCellMatrix(1, 2);
mxSetCell(varargin, 0, imageData);
mxSetCell(varargin, 1, jsonData);
mlfBlemish_shell(1, &outputJSON, inputFile, rootDir, inputKeys, opMode, varargin);opMode를 -15 (기본 INI 파일 사용) 또는 -17 (INI 파일 경로 전달)로 설정하면 호출 프로그램에서 Imatest IT C++ 라이브러리로 이미지(처리된 RGB 또는 RAW 파일)를 직접 전달할 수 있습니다. 이미지를 직접 전달하는 방식은 일반적으로 파일에서 읽는 방식보다 훨씬 빠르므로 속도가 중요한 대용량 테스트에 강력히 권장됩니다.
이미지를 직접 전달하는 경우, varargin 매개변수에는 두 개의 추가 mwArray 가 포함됩니다. 하나는 적절한 유형(부호 있는 또는 부호 없는 8, 16 또는 32비트 정수)의 이미지 데이터를 포함하고, 다른 하나는 이미지를 디코딩(또는 재구성)하는 데 필요한 정보가 포함된 JSON 형식의 문자열 입니다.
rawFile 매개변수는 mwArray 생성자를 사용하여 생성되며, 이미지 배열의 크기, 1 (단일 차원 배열의 경우), 데이터 형식을 나타내는 상수( mxINT8_CLASS , mxUINT8_CLASS , mxINT16_CLASS , mxUINT16_CLASS , mxINT32_CLASS 또는 mxUINT32_CLASS 중 하나), 그리고 상수 mxReal을 전달합니다. 그런 다음 setData() 함수를 사용하여 이미지 배열을 mwArray 매개변수에 복사합니다.
varargin 매개변수는 셀 배열 형식의 mwArray 입니다. Get() 및 Set() 함수를 사용하여 추가 인수를 더할 수 있습니다.
RGB 및 RAW 이미지의 경우 JSON 객체에는 이미지 너비 , 높이 , ncolors (색상 수), 파일 루트 및 확장자 표시기가 포함되어야 합니다. RAW 이미지인 경우, Read Raw 유틸리티를 사용하여 INI 파일에 구성된 확장자를 사용하고, 그렇지 않은 경우 아래 표에서 옵션을 참조하십시오. 파일 루트는 출력 파일을 저장할 위치와 출력 파일 이름을 지정하는 데 사용됩니다. 다음 C++ 코드 스니펫은 부호 없는 short 형 이미지 배열과 JSON 메타데이터 문자열을 blemish_shell() 함수에 전달합니다.
unsigned short *rawPixels;
unsigned int pixelCount;
/// Load the image data from your source here ...
const char *jsonOptionsStr = "{ "jstr": {"width": 1296,"height": 808,"ncolors": 1,"extension": "raw", "fileroot": "C:\ImatestSamples\blemish.raw"}}";
mwArray jsonOutput;
mwArray inputFile = mwArray("");
mwArray rootDir = mwArray("C:\ImatestSamples\");
mwArray inputKeys = mwArray("JSON");
mwArray opMode = mwArray("-15");
mwArray rawFile = mwArray(pixelCount, 1, mxUINT16_CLASS, mxREAL);
rawFile.SetData(rawPixels, pixelCount);
mwArray jsonOptions = mwArray(1,jsonOptionsStr);
mwArray varargin = mwArray(1,2,mxCELL_CLASS);
varargin.Get(1,1).Set(rawFile);
varargin.Get(1,2).Set(jsonOptions);
blemish_shell(1, jsonOutput, inputFile, rootDir, inputKeys, opMode, varargin);op_mode를 ImatestLibrary.DIRECT_READ 로 설정하면 이미지(처리된 RGB 또는 RAW)를 호출 프로그램에서 IT Python으로 직접 전달할 수 있습니다. 이미지를 직접 전달하는 방식은 일반적으로 파일에서 읽는 방식보다 훨씬 빠르므로 속도가 중요한 대용량 테스트에 강력히 권장됩니다.
이미지를 직접 전달하는 경우, raw_data 매개변수에는 이미지(픽셀당 8, 16 또는 32비트의 바이너리 문자열로 전달되거나, 데이터 유형 코드가 'B'(uint8), 'H'(uint16) 또는 'I'(uint32)인 array.array 객체로 전달됨)가 포함되고, json_args 매개변수에는 이미지를 디코딩(또는 재구성)하는 데 필요한 정보가 포함된 JSON 객체가 포함됩니다.
RGB 및 RAW 이미지의 경우, json_args 객체에는 이미지 너비 , 높이 , ncolors (색상 수), 파일 이름 및 확장자 표시기가 포함되어야 합니다. RAW 이미지인 경우, Read Raw 유틸리티를 사용하여 INI 파일에 구성된 확장자를 사용하고, 그렇지 않은 경우 아래 표에서 옵션을 참조하십시오. 파일 이름은 출력 파일을 저장할 위치와 출력 파일 이름을 지정하는 데 사용됩니다. 다음 Python 스크립트는 ImatestLibrary.build_json_args() 함수를 사용하여 json_args 문자열을 생성하고, 이를 raw_data와 함께 blemish_json() 함수에 전달합니다. 이 예제는 다소 인위적인 예시이며, 일반적으로 디스크에서 이미지를 읽어오는 것이 아니라 다른 소스에서 이미 읽어온 raw_data 스트림을 사용합니다.
raw_data = None
/// Load your image data here...
raw_image_path = r'C:ImatestSamplesblemish.raw'
json_args = imatestLib.build_json_args(width=1296,
height=808,
ncolors=1,
extension='raw',
filename=raw_image_path)
result = imatestLib.blemish_json(input_file=None,
root_dir=root_dir,
op_mode=ImatestLibrary.OP_MODE_DIRECT_READ,
ini_file=ini_file,
raw_data=raw_data,
json_args=json_args)Images (processed RGB or RAW) can be passed directly from the calling program to the Imatest IT .NET Library. Passing images directly is generally much faster than reading them from files, and strongly recommended for speed-critical high-volume testing.
For direct image passing, use one of the following module method signatures:
string [module].JSON(string rootDir, byte[] inputBytes, DirectReadOptions directReadOptions)
string [module].JSON(string rootDir, byte[] inputBytes, DirectReadOptions directReadOptions, string iniFilePath)
string [module].JSON(string rootDir, ushort[] inputBytes, DirectReadOptions directReadOptions)
string [module].JSON(string rootDir, ushort[] inputBytes, DirectReadOptions directReadOptions, string iniFilePath)
string [module].JSON(string rootDir, uint[] inputBytes, DirectReadOptions directReadOptions)
string [module].JSON(string rootDir, uint[] inputBytes, DirectReadOptions directReadOptions, string iniFilePath)
[module].JSON(String rootDir, Byte() inputBytes, DirectReadOptions directReadOptions) As String
[module].JSON(String rootDir, Byte() inputBytes, DirectReadOptions directReadOptions, String iniFilePath) As String
[module].JSON(String rootDir, UInt16() inputBytes, DirectReadOptions directReadOptions) As String
[module].JSON(String rootDir, UInt16() inputBytes, DirectReadOptions directReadOptions, String iniFilePath) As String
[module].JSON(String rootDir, UInt32() inputBytes, DirectReadOptions directReadOptions) As String
[module].JSON(String rootDir, UInt32() inputBytes, DirectReadOptions directReadOptions, String iniFilePath) As String
The inputBytes parameter contains the image data of the appropriate type (unsigned 8, 16, or 32 bit integers), and the directReadOptions parameter is an object containing the information needed to decode (or reconstruct) the image.
For RGB and RAW images, the DirectReadOptions object must contain the image Width, Height, NumberOfColors, Filename, and Extension values. If it is a RAW image, then use the extension that has been configured in your INI file using the Read Raw utility, otherwise see the table below for options. The Filename property will be used to direct where to write output files, and what the output filenames will be. The following code snippet passes an image array of type byte and a DirectReadOptions object to the blemish_shell() function.
UInt16[] imageData;
// Load the image data from your source ...
DirectReadOptions directReadOptions = new DirectReadOptions();
directReadOptions.Width = 1296;
directReadOptions.Height = 808;
directReadOptions.Extension = "raw";
directReadOptions.Filename = "C:\ImatestSamples\blemish.raw";
directReadOptions.NumberOfColors = 1;
string rootDir = "C:\ImatestSamples\";
string resultJSON = itLib.Blemish.JSON(rootDir, imageData, directReadOptions);
Dim imageData As UInt16
' Load the image data from your source ...
Dim DirectReadOptions As DirectReadOptions
directReadOptions = New DirectReadOptions()
directReadOptions.Width = 1296
directReadOptions.Height = 808
directReadOptions.Extension = "raw"
directReadOptions.Filename = "C:\ImatestSamples\blemish.raw"
directReadOptions.NumberOfColors = 1
Dim rootDir = "C:\ImatestSamples\"
Dim resultJSON = itLib.Blemish.JSON(rootDir, imageData, directReadOptions)
JSON 요소 이름 | 메모 | |
| 필수의 | 키 | 이미지 배열의 행 수입니다. |
| 너비 | 이미지 배열의 열 개수. | |
| n색상 | 색상 채널 수입니다. Bayer RAW 또는 회색조 이미지를 분석하는 경우 1로 설정하십시오. | |
| 확대 | RAW 이미지 배열의 경우 Imatest Master의 Read Raw 설정 대화 상자 에 정의된 확장 프로그램을 사용하십시오. 그렇지 않으면 다음을 사용하십시오.
참고: 행 우선 형식이 더 일반적이므로 확실하지 않은 경우 먼저 해당 형식을 시도해 보세요. 참고: 단색 행 우선 데이터의 경우 "row_major_planar"를 사용하십시오. | |
| 파일루트 | 결과를 저장할 이미지의 전체 경로명(예: *.csv, *.png)을 입력하세요. | |
| 합격/불합격 여부 출력 (선택 사항) | 부품 번호 | 장치의 부품 번호가 포함된 문자열입니다. 기본값은 "입력되지 않음"입니다. |
| 시리얼 번호 | 기기의 일련번호가 포함된 문자열입니다. 기본값은 "입력되지 않음"입니다. | |
| 역 | 프로덕션 스테이션. 기본값은 빈 문자열입니다. | |
| 연산자 | 역 운영자입니다. 기본값은 빈 문자열입니다. | |
| 이름 | 이 필드는 값이 입력된 경우에만 합격/불합격 결과 출력에 나타납니다. | |
| 작업 | 이 필드는 값이 입력된 경우에만 합격/불합격 결과 출력에 나타납니다. | |
| 상태 | 이 필드는 값이 입력된 경우에만 합격/불합격 결과 출력에 나타납니다. | |
| 선택적 INI 재정의 [SFRplus에만 해당] | 작물 경계 | 제외할 이미지 테두리를 픽셀 단위로 정의하는 정수 배열([왼쪽, 오른쪽, 위쪽, 아래쪽]) |
| 렌즈와 차트 사이의 거리(cm) | 렌즈와 차트 사이의 거리를 센티미터 단위로 나타내는 스칼라 값입니다. | |
| 차트 높이(cm) | 차트의 높이를 센티미터 단위로 나타내는 스칼라 값입니다. | |
| 선택적 INI 재정의 [블레미쉬 전용] | 핫픽셀 유형 | 핫픽셀 임계값 유형을 나타내는 스칼라 정수입니다. 1은 없음, 2는 절대값, 3은 백분율로 설정합니다. |
| 데드픽셀 유형 | 데드픽셀 임계값 유형을 나타내는 스칼라 정수입니다. 1은 없음, 2는 절대값, 3은 백분율로 설정합니다. | |
| 핫픽셀 임계값 | 핫픽셀 임계값을 [절대 임계값, 백분율 임계값] 형식으로 포함하는 2개 요소 배열입니다. | |
| 데드픽셀 임계값 | 데드픽셀 임계값을 [절대 임계값, 백분율 임계값] 형식으로 포함하는 2개 요소 배열입니다. | |
| 흠집 분석 | 잡티 분석 기능을 켜고 끄는 부울 플래그입니다. 1로 설정하면 잡티 분석이 활성화되고, 0으로 설정하면 비활성화됩니다. | |
| 균일성 분석 | 균일성 분석을 켜고 끄는 부울 플래그입니다. 결함 분석을 활성화하려면 1로 설정하고, 비활성화하려면 0으로 설정합니다. | |
| 선택적 진단 필드 | 이미지 표시 | 이 변수는 부울 플래그로, true(또는 1)로 설정하면 필요한 경우 제공된 이미지를 읽어 들여 디코딩한 후 표시합니다. |