MultiCam 사용자를위한 EGrabber
- 개념
-
Multicam EGrabber 보드 인터페이스 채널 장치 + 데이터 스트림 서페이스 버퍼 서페이스 클러스터(MC_Cluster) 데이터 스트림에 발표된 버퍼 - 원격 장치 (카메라) MultiCam 매개 변수 GenApi 설정/가져오기 기능 - GenApi 명령 CAM 파일 Euresys GenApi 스크립트 - CallbackOnDemand 콜백 함수 CallbackSingleThread - CallbackMultiThread - 초기화
-
MCSTATUS status = McOpenDriver(NULL); if (status != MC_OK) { ... }Euresys::EGenTL gentl; - 초기화 채널 생성
-
MCSTATUS status; MCHANDLE channel; status = McCreate(MC_CHANNEL, &handle); if (status != MC_OK) { ... } status = McSetParamInt(channel, MC_DriverIndex, CARD_INDEX); if (status != MC_OK) { ... } status = McSetParamInt(channel, MC_Connector, CONNECTOR); if (status != MC_OK) { ... }Euresys::EGrabber<> grabber(gentl, CARD_INDEX, DEVICE_INDEX); - 서페이스 생성 (자동)
-
status = McSetParamInt(channel, MC_SurfaceCount, BUFFER_COUNT); if (status != MC_OK) { ... }grabber.reallocBuffers(BUFFER_COUNT); - 서페이스 생성 (수동)
-
for (size_t i = 0; i < BUFFER_COUNT; ++i) { MCHANDLE surface; MCSTATUS status; void *mem = malloc(BUFFER_SIZE); if (!mem) { ... } status = McCreate(MC_DEFAULT_SURFACE_HANDLE, &surface); if (status != MC_OK) { ... } status = McSetParamInt(surface, MC_SurfaceSize, BUFFER_SIZE); if (status != MC_OK) { ... } status = McSetParamPtr(surface, MC_SurfaceAddr, mem); if (status != MC_OK) { ... } status = McSetParamPtr(surface, MC_SurfaceContext, USER_PTR[i]); if (status != MC_OK) { ... } status = McSetParamInst(channel, MC_Cluster + i, surface); if (status != MC_OK) { ... } }for (size_t i = 0; i < BUFFER_COUNT; ++i) { void *mem = malloc(BUFFER_SIZE); if (!mem) { ... } grabber.announceAndQueue(Euresys::UserMemory(mem, BUFFER_SIZE, USER_PTR[i])); } - 서페이스 클러스터 재설정
-
MCSTATUS status; for (size_t i = 0; i < BUFFER_COUNT; ++i) { MCHANDLE surface; status = McGetParamInst(channel, MC_Cluster + i, &surface); if (status != MC_OK) { ... } status = McSetParamInt(surface, MC_SurfaceState, MC_SurfaceState_FREE); if (status != MC_OK) { ... } } status = McSetParamInt(channel, MC_SurfaceIndex, 0); if (status != MC_OK) { ... }grabber.resetBufferQueue(); - 프레임 그래버 구성
-
Multicam EGrabber McSetParamStr(H, MC_CamFile, filepath) grabber.runScript(filepath) - grabber.runScript(script) McSetParamInt(H, id, value) 또는 McSetParamNmInt(H, name, value) grabber.setInteger<M>(name, value) McSetParamFloat(H, id, value) 또는 McSetParamNmFloat(H, name, value) grabber.setFloat<M>(name, value) McSetParamStr(H, id, value) 또는 McSetParamNmStr(H, name, value) grabber.setString<M>(name, value) 여기서 H는 MC_HANDLE (전역 MC_CONFIGURATION 핸들, 보드 핸들 또는 채널 핸들)이고 M은 대상 모듈 (SystemModule, InterfaceModule, DeviceModule 또는 StreamModule)을 지정합니다.
- 카메라 구성
-
Multicam EGrabber - grabber.runScript(filepath) - grabber.runScript(script) - grabber.setInteger<RemoteModule>(name, value), grabber.setFloat<RemoteModule>(name, value), 또는 grabber.setString<RemoteModule>(name, value) - 스크립트 파일
-
; CAM file ChannelParam1 = Value1; ChannelParam2 = Value2;// Euresys GenApi Script var grabber = grabbers[0]; grabber.DevicePort.set('DeviceFeature1', Value1); grabber.DevicePort.set('DeviceFeature2', Value2); grabber.RemotePort.set('CameraFeatureA', ValueA); - 수집 시작/정지
-
// start "live" McSetParamInt(channel, MC_GrabCount, MC_INFINITE); McSetParamInt(channel, MC_ChannelState, MC_ChannelState_ACTIVE); // stop McSetParamInt(channel, MC_ChannelState, MC_ChannelState_IDLE); // grab 10 images McSetParamInt(channel, MC_GrabCount, 10); McSetParamInt(channel, MC_ChannelState, MC_ChannelState_ACTIVE);// start "live" grabber.start(); // stop grabber.stop(); // grab 10 images grabber.start(10); - 동기식(블로킹) 버퍼 수신
-
MCSTATUS status; MCSIGNALINFO info; // wait for a surface status = McWaitSignal(channel, MC_SIG_SURFACE_PROCESSING, timeout, &info); if (status != MC_OK) { ... } MCHANDLE surface = info.SignalInfo; // process surface ... // make surface available for new images status = McSetParamInt(surface, MC_SurfaceState, MC_SurfaceState_FREE); if (status != MC_OK) { ... }// wait for a buffer Buffer buffer = grabber.pop(timeout); // process buffer ... // make buffer available for new images buffer.push(grabber);{ // wait for a buffer ScopedBuffer buffer(grabber, timeout); // process buffer ... // ScopedBuffer destructor takes care of making buffer available for new images } - 콜백
-
class MyChannel { public: MyChannel() { // create and configure channel ... // enable "SURFACE_PROCESSING" events status = McSetParamInt(channel, MC_SignalEnable + MC_SIG_SURFACE_PROCESSING, MC_SignalEnable_ON); if (status != MC_OK) { ... } // enable "END_EXPOSURE" events status = McSetParamInt(channel, MC_SignalEnable + MC_SIG_END_EXPOSURE, MC_SignalEnable_ON); if (status != MC_OK) { ... } // register "extern C" callback function MCSTATUS status = McRegisterCallback(channel, GlobalCallbackFunction, this); if (status != MC_OK) { ... } } void onEvent(MCSIGNALINFO *info) { switch (info->Signal) { case MC_SIG_SURFACE_PROCESSING: MCHANDLE surface = info.SignalInfo; // process surface ... break; case MC_SIG_END_EXPOSURE: // handle "END_EXPOSURE" event ... break; } } private: MCHANDLE channel; }; void MCAPI GlobalCallbackFunction(MCSIGNALINFO *info) { if (info && info->Context) { MyGrabber *grabber = (MyGrabber *)info->Context; grabber->onEvent(info); } };class MyGrabber : public EGrabber<CallbackSingleThread> { public: MyGrabber(EGenTL &gentl) : EGrabber<CallbackSingleThread>(gentl) { // configure grabber ... // enable "NewBuffer" events enableEvent<NewBufferData>(); // enable "Cic" events enableEvent<CicData>(); } private: virtual void onNewBufferEvent(const NewBufferData& data) { ScopedBuffer buffer(*this, data); // process buffer ... } virtual void onCicEvent(const CicData &data) { // handle "Cic" event ... } }; - 동기식 (블로킹) 이벤트 핸들링
-
class MyChannel { public: MyChannel() { // create and configure channel ... // enable "END_EXPOSURE" events status = McSetParamInt(channel, MC_SignalEnable + MC_SIG_END_EXPOSURE, MC_SignalEnable_ON); if (status != MC_OK) { ... } } void waitForEvent(uint32_t timeout) { // wait for an event MCSTATUS status = McWaitSignal(channel, MC_SIG_END_EXPOSURE, timeout, &info); if (status != MC_OK) { ... } // handle "END_EXPOSURE" event ... } private: ... };class MyGrabber : public EGrabber<CallbackOnDemand> { public: MyGrabber(EGenTL &gentl) : EGrabber<CallbackOnDemand>(gentl) { // configure grabber ... // enable "Cic" events enableEvent<CicData>(); } void waitForEvent(uint64_t timeout) { // wait for an event processEvent<CicData>(timeout); } private: // onCicEvent is called by processEvent when a "Cic" event occurs virtual void onCicEvent(const CicData &data) { // handle "Cic" event ... } };
