Code Example of Callback Mechanism
The following code uses the callback mechanism to process images grabbed during an acquisition sequence. One or several surfaces have to be created and assigned to the cluster owned by the channel. At the end of each acquisition phase, the surface is filled and made available to the callback function. The Status variable can be used for error checking.
[C]
void MyApplication()
{
//Application level initializing code
MCSTATUS Status = McOpenDriver(NULL);
//Application level initializing code
MCHANDLE MyChannel;
Status = McCreateNm("EXPERT_A", &MyChannel);
//Assign grabber and camera to channel
//Configure channel including triggering mode
//Assign to channel a destination cluster of surfaces
//Registering the callback function
Status = McRegisterCallback(MyChannel, MyFunction, NULL);
//Activating acquisition sequence
Status = McSetParamInt(MyChannel, MC_ChannelState, MC_ChannelState_ACTIVE);
//Acquisition sequence is now active
//A callback is automatically generated after each acquisition phase
//Deleting the channels
Status = McDelete(MyChannel);
//Disconnecting from driver
Status = McCloseDriver();
}
void MCAPI MyFunction(PMCSIGNALINFO SignalInfo)
{
//...
//Image processing code
//Image to be processed is available in the destination cluster of surfaces
//...
}