CVORun
この関数はオブジェクトが実行されるときにコールされます。
サーチウィンドウの画像情報がCVO_IMGで渡されます。
画像変換を行う場合は、このCVO_IMGの情報を書き替えてください。
CVOAPI int32_t CVORun(CVO_PARAMS* inParams, CVO_PARAMS* outParams, CVO_DETECT_ITEMS* detectItems, CVO_IMG* img, CVO_MODEL* mdl)
{
for (int y = 0; y < img->Height; y++)
{
for (int x = 0; x < img->Width; x++)
{
int idx = img->Stride * y + img->BytesPerPixel * x;
if (img->BytesPerPixel == 3)
{
img->pBuffer[idx + 0] = 255 - img->pBuffer[idx + 0];
img->pBuffer[idx + 1] = 255 - img->pBuffer[idx + 1];
img->pBuffer[idx + 2] = 255 - img->pBuffer[idx + 2];
}
else if (img->BytesPerPixel == 1)
{
img->pBuffer[idx] = 255 - img->pBuffer[idx];
}
}
}
return CVO_NOERROR;
}
検出位置情報を提供する場合は、CVO_DETECT_ITEMSに情報を設定してください。
CVOAPI int32_t CVORun(CVO_PARAMS* inParams, CVO_PARAMS* outParams, CVO_DETECT_ITEMS* detectItems, CVO_IMG* img, CVO_MODEL* mdl)
{
detectItems->Count = 10;
for (auto i = 0; i < detectItems->Count; i++)
{
detectItems->Items[i].PixelX = rand() % img->Width;
detectItems->Items[i].PixelY = rand() % img->Height;
}
return CVO_NOERROR;
}