-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecog.cpp
More file actions
38 lines (34 loc) · 1.19 KB
/
Copy pathrecog.cpp
File metadata and controls
38 lines (34 loc) · 1.19 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
#include "recog.hpp"
#include "pmd.hpp"
#include <algorithm>
void Recog::operator()()
{
std::cout << "Started thread for face recognition" << std::endl;
const float * oldmin;
PMD::configuration &conf=PMD::config();
while(!quit_thread){
const float * const start=m_zmap.get();
const float * const end=m_zmap.get()+m_width*m_height;
const float * min=start;
for(const float *z=start+conf.bottomCap*m_width,*q=m_qmap.get()+conf.bottomCap*m_width;
z<end-conf.topCap*m_width;
z++,q++){
if(*q>500 && *z<*min)
min=z;
}
if(start!=min && oldmin!=min){
const size_t idx= std::distance(start, min);
const size_t idx_y=idx/m_width,idx_x=idx%m_width;
if(m_marker){
float posx=(idx_x-m_width/2.)/10,posy=(idx_y-m_height/2.)/10;
m_marker->SetPosAndScale(posx,posy,(*min)*50-8,1);
m_marker->compileNextTime();
}
oldmin=min;
}
}
std::cout << "Ending thread for face recognition" << std::endl;
}
Recog::Recog(unsigned width, unsigned height, std::shared_ptr<float> zmap, std::shared_ptr<float> qmap,SGLshPtr<SGLObjBase> marker)
:m_zmap(zmap),m_qmap(qmap),m_height(height),m_width(width),m_marker(marker)
{}