hey Doug,
Opened a support ticket looking for a way to get the zip to you, - I see I can attach here - but there is a 256Kb maximum and Visual Studio has bloated my project to 33Mb - and that's zipped!
Anyway, I've built a small backbone of a real-time image processing project in openCV that (unfortunately still) has the issues - keen to get it in before the xmas and new year break
Windows8.1, 64bit on a Macbook Pro Retina bootcamp partition
Visual Studio Ultimate 2012 (Version 11.0.61030.00 update 4).
The Code at least:
Code: Select all
#include "cameralibrary.h"
#include "face_supportcode.h"
#include "opencv2/opencv.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
using namespace CameraLibrary;
int main(int argc, char** argv){
//variables involved in obtaining loop timing estimates:
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
WORD currentTime = (sysTime.wSecond * 1000) + sysTime.wMilliseconds;
WORD previousTime;
int period = 0;
int FPS = 0;
CameraManager::X().WaitForInitialization();
Camera *V120Camera = CameraManager::X().GetCamera();
if(!V120Camera)
{
printf("...Error opening the V120\n");
Sleep(3000);
return 0;
}
V120Camera->SetVideoType(Core::GrayscaleMode); // or MJPEGMode...
V120Camera->SetAEC(true);
V120Camera->SetAGC(true);
V120Camera->SetTextOverlay(true);
int camWidth = V120Camera->Width();
int camHeight = V120Camera->Height();
Mat imageCV(cv::Size(camWidth, camHeight), CV_8UC1);
const int BACKBUFFER_BITSPERPIXEL = 8;
namedWindow("V120", WINDOW_AUTOSIZE);
//V120Camera->SetFrameRate(25); //causes crash later
V120Camera->Start();
Sleep(40); //at least 33ms ?
Frame *rawInputV120;
while(1){
//getting an idea of timing...
//might not be accurate (??) but can at least be used to
//reveal relative differences
GetSystemTime(&sysTime);
previousTime = currentTime;
currentTime = (sysTime.wSecond * 1000) + sysTime.wMilliseconds;
period = currentTime - previousTime;
FPS = 1000/period;
printf("%d %d\n", V120Camera->ActualFrameRate(), period);
rawInputV120 = V120Camera->GetLatestFrame(); //if I use GetFrame I get 'frame queue overflow'
if(rawInputV120) //'25' results in no frame here
{
rawInputV120->Rasterize(camWidth, camHeight, imageCV.step, BACKBUFFER_BITSPERPIXEL, imageCV.data);
}
imshow("V120", imageCV);
waitKey(1); //imshow wont work without this... (at least it is set to minimum)
rawInputV120->Release(); //crash from setFrameRate happens here
}
V120Camera->Release();
CameraManager::X().Shutdown();
return 0;
}
A few things to explain:
'face_supportcode.h' is the usual supportcode.h file but with:
bool PopWaitingDialog(); commented out...
Also the function PopWaitingDialog is commented out in face_supportcode.cpp.
Running 64bit gives compile errors if I don't do this - as you can see I don't use PopWaitingDialog anywhere as a result. Is it relevant?
Next, using the quick calculation of loop period, it seems that the while loop is taking almost twice as long as it should to maintain 120fps (15~16ms compared to 8~9ms). Also of note is that the frame buffer fills up using 'getFrame' - although for my project getLatestFrame seems like an ok workaround as low latency is more important than seeing every frame (it's possible that the vision processing algorithms may end up being the bottleneck).
In the code given there has been no image processing yet, I'd expect shorter loop periods huh?
Although I initially mentioned a simple error with setFrameRate in this thread, I'm more keen to learn how to optimize the rate I can get frames from the V120 into something I can work with in openCV. Still though, perhaps the fact I cannot change rates without causing a crash may provide a clue as to the issue/issues?
Do you have an email I can send the project to?
Any help appreciated.