Hi All,
Im trying do single dot tracking
When i try to capture the frame using getframe() sometimes it captures the frame and most of time get_count returns zero.
Please help me out in fixing this problem?
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
CComPtr cameraCollection;
CComPtr camera;
CComPtr pframe;
cameraCollection.CoCreateInstance(CLSID_NPCameraCollection);
cameraCollection->Enum();
cameraCollection->Item(0, &camera);
camera->SetOption(NP_OPTION_VIDEO_TYPE , (CComVariant) 1 );
camera->Open();
camera->Start();
printf("camera detected \n");
{
while(!_kbhit())
{
Sleep(5);
MSG msg;
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if(GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
camera->GetFrame(0, &pframe);
if(pframe!=0)
{
LONG lCount = 0;
pframe->get_Count(&lCount);
for (int i = 0; i spObject;
pframe->Item(i, &spObject);
LONG lRank;
spObject->get_Rank(&lRank);
if (lRank == 1)
{
CComVariant varX, varY, varArea;
spObject->get_X(&varX);
spObject->get_Y(&varY);
spObject->get_Area(&varArea);
printf("%.3f\t%0.3f\r",varX.dblVal,varY.dblVal);
}
spObject.Release();
}
if (pframe)
{
pframe->Free(); //free the buffer
pframe = NULL; //release the COM object.
}
}
}
camera->Stop();
camera->Close();
}
camera.Release();
//== Always Clean-up COM Objects ================----
cameraCollection.Release();
//== Uninitialize Microsoft COM Interop =============----
CoUninitialize();
printf("Application Exit.\n");
getchar();
return 0;
}
Regards,
Jagadeeshwari
Problem with frame->get_Count(&lCount1)
-
- Posts: 1
- Joined: Tue Dec 16, 2008 11:29 pm