Repository navigation
Expand file tree
/
Copy pathcomputerDistribute.cpp
More file actions
executable file
·111 lines (102 loc) · 2.7 KB
/
Copy pathcomputerDistribute.cpp
File metadata and controls
executable file
·111 lines (102 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Including Boost
#include <boost/lambda/lambda.hpp>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
#include <boost/interprocess/containers/vector.hpp>
//Including C++ Libs
#include <iostream>
#include <iterator>
#include <queue>
//#include <algorithm>
#include <cstdio>
//Open CV
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "paolMat.h"
#include "buffer.h"
#include "module.h"
#include "computerDistribute.h"
#define _debug_
#define bottomMask 115
#define thresholdDiff .0005
#define repeat 3//number of consecutive stamble images necessary to consider stable
using namespace cv;
ComputerDistribute::ComputerDistribute(Buffer* in, Buffer* compProcIn, Buffer* compMovieIn, Buffer* tempDisplayIn) : Module(in,compProc,150)
{
compProc = compProcIn;
compMovie = compMovieIn;
tempDisplay = tempDisplayIn;
}
void ComputerDistribute::run()
{
int countStable;
double percentDifference;
Ptr<paolMat> current;
Ptr<paolMat> previous;
previous = pop();
if(previous != NULL){
current = pop();
}
countStable=0;
while(current != NULL)
{
if(previous->src.rows==current->src.rows &&
previous->src.cols==current->src.cols)
{
current->difference(previous, 100, 0, bottomMask);
percentDifference=(double)current->difs/(double)(current->src.rows*current->src.cols);
} else
{
percentDifference=1.0;
}
#ifdef _debug_
//percentDifference = 0.5;
std::cout<<"Dif% :"<<percentDifference<<" countStable: "<<countStable<<" current->difs: "<<current->difs<<std::endl;
#endif
if(percentDifference>=thresholdDiff)
{
if(countStable>repeat)//was stable going to unstable
{
#ifdef _debug_
previous->name = "ForCompProc";
std::cout<< "frame "<<previous->count <<" had % "<<percentDifference<<"\n";
#endif
compProc->push(previous);//send to computer process
} else
{//there was a change
#ifdef _debug_
current->name = "ForCompMovie";
#endif
//where one ERROR is since we are seeing black frames
//temporarily commenting out the push to see if if stops it from breaking
//-Paul 11/29/12
//compMovie->push(current);//send to movie creation
}
countStable=0;
} else {
countStable++;
if(countStable==repeat)
{//if it is stable but just started stable
#ifdef _debug_
current->name = "ForTempDisplay";
#endif
tempDisplay->push(current);//send to real time display
}
}
previous->copy(current);
current=pop();
}
//save last image
#ifdef _debug_
previous->name = "ForCompProc";
#endif
compProc->push(previous);
{
boost::mutex::scoped_lock lock(modLock);
keepRunning = false;
}
//stop();
compProc->stop();
compMovie->stop();
tempDisplay->stop();
}