You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1002 B
59 lines
1002 B
#include "autoflash.h" |
|
|
|
|
|
|
|
|
|
autoFlash::autoFlash(QObject *parent) |
|
: QObject{parent} |
|
{ |
|
thread = new QThread(); |
|
thread->start(); |
|
this->moveToThread(thread); |
|
|
|
b_sv = false; // |
|
// lastlight; |
|
count = 0; |
|
|
|
// double threshold; |
|
|
|
threshold = 6000; |
|
} |
|
|
|
void autoFlash::slotprocimg(cv::Mat img) |
|
{ |
|
if(count>0){ |
|
b_sv = false; |
|
count -=1; |
|
return; |
|
} |
|
|
|
double avg = 0; |
|
for(int i = 0;i<img.rows;i+=10){ |
|
for(int j = 0;j<img.cols;j+=10){ |
|
avg += img.at<ushort>(i,j); |
|
} |
|
} |
|
avg = avg/int(img.rows/10)/int(img.cols/10)/4; |
|
if(b_sv){ |
|
lastlight = lastlight/20*19 +avg/20; |
|
} |
|
else{ |
|
lastlight = avg; |
|
b_sv = true; |
|
} |
|
if(lastlight-threshold<-1000){ |
|
emit signalSetIT(-1); |
|
count = 5; |
|
} |
|
if(lastlight-threshold>1000){ |
|
emit signalSetIT(1); |
|
count = 5; |
|
} |
|
|
|
|
|
} |
|
|
|
void autoFlash::slotsetshre(double thre) |
|
{ |
|
this->threshold = thre; |
|
}
|
|
|