Hi,
I want to measure pulse frequency using opencv and a webcam. I have got one thread for videocapture. In main program I plot pixel value as function of time. Video is nice but plot graph are blinking as you can see in this video. Is it possible to have no blinking for this plot?
Thanks for your help
PS If I use another thread for plot problem is still visible. VS 2013 Windows 10 opencv 3.0-dev
My code to plot a graph is
void TimeSignal()
{
Mat red=Mat::zeros(300,2*MAXTIME,CV_8UC3);
Mat green=Mat::zeros(300,2*MAXTIME,CV_8UC3);
Mat blue=Mat::zeros(300,2*MAXTIME,CV_8UC3);
imshow("Red componnent",red);
imshow("Green componnent",green);
imshow("Blue componnent",blue);
waitKey(10);
double fAcq=20;
std::this_thread::sleep_for (std::chrono::seconds(1));
int indFramePre=-1;
while (true)
{
mtxFrame.lock();
if (mode == 27)
{
mtxFrame.unlock();
return;
}
if (mode == 's')
{
mtxFrame.unlock();
waitKey(30);
}
else
{
if (indFrame != indFramePre)
{
indFramePre = indFrame;
mtxProbe.lock();
map<int, list<Vec4f> >::iterator ite = probeValue.begin();
vector<Scalar> color={Scalar(255,0,0),Scalar(0,255,0),Scalar(0,0,255),Scalar(255,255,0),Scalar(255,255,255)};
for (int c=0; ite != probeValue.end(); ite++,c++)
{
list<Vec4f>::iterator iteList = ite->second.begin();
list<Vec4f>::iterator iteListPre = ite->second.begin();
float tpsIni = (*iteListPre)[0];
int minColor[4]={0,0,0,0};
int maxColor[4]={255,255,255,255};
int offsetRows=20;
for (int i = 0; i < ite->second.size(); i++,iteList++)
{
for (int j = 1; j < 4; j++)
{
if ((*iteListPre)[j]<minColor[j])
minColor[j]=(*iteListPre)[j];
if ((*iteListPre)[j]>maxColor[j])
maxColor[j]=(*iteListPre)[j];
}
}
iteList = ite->second.begin();
iteListPre = ite->second.begin();
iteList++;
for (int i = 1; i < ite->second.size(); i++,iteListPre++,iteList++)
{
line(green,Point(((*iteListPre)[0]-tpsIni)*fAcq, ((*iteListPre)[2]-minColor[2])/(maxColor[2]-minColor[2]+1)*255+offsetRows),Point(((*iteList)[0]-tpsIni)*fAcq, ((*iteList)[2]-minColor[2])/(maxColor[2]-minColor[2]+1)*255+offsetRows),color[c],1);
line(red,Point(((*iteListPre)[0]-tpsIni)*fAcq, ((*iteListPre)[1]-minColor[1])/(maxColor[1]-minColor[1]+1)*255+offsetRows),Point(((*iteList)[0]-tpsIni)*fAcq, ((*iteList)[1]-minColor[1])/(maxColor[1]-minColor[1]+1)*255+offsetRows),color[c],1);
line(blue,Point(((*iteListPre)[0]-tpsIni)*fAcq, ((*iteListPre)[3]-minColor[3])/(maxColor[3]-minColor[3]+1)*255+offsetRows),Point(((*iteList)[0]-tpsIni)*fAcq, ((*iteList)[3]-minColor[3])/(maxColor[3]-minColor[3]+1)*255+offsetRows),color[c],1);
}
}
mtxProbe.unlock();
}
mtxFrame.unlock();
imshow("Red componnent",red);
imshow("Green componnent",green);
imshow("Blue componnent",blue);
waitKey(30);
red=Mat::zeros(300,2*MAXTIME,CV_8UC3);
green=Mat::zeros(300,2*MAXTIME,CV_8UC3);
blue=Mat::zeros(300,2*MAXTIME,CV_8UC3);
}
}
}