|
@ -4,7 +4,6 @@ |
|
|
void ofApp::setup(){ |
|
|
void ofApp::setup(){ |
|
|
/* ofSettings */ |
|
|
/* ofSettings */ |
|
|
ofDisableArbTex(); |
|
|
ofDisableArbTex(); |
|
|
ofSetFrameRate(24); |
|
|
|
|
|
ofSetVerticalSync(true); |
|
|
ofSetVerticalSync(true); |
|
|
window_width = ofGetWindowWidth(); |
|
|
window_width = ofGetWindowWidth(); |
|
|
window_height = ofGetWindowHeight(); |
|
|
window_height = ofGetWindowHeight(); |
|
@ -30,7 +29,7 @@ void ofApp::setup(){ |
|
|
|
|
|
|
|
|
yolo.Setup(modelPath2, false, true); |
|
|
yolo.Setup(modelPath2, false, true); |
|
|
depth.Setup(modelPath, false, true); |
|
|
depth.Setup(modelPath, false, true); |
|
|
depth_small.Setup(modelPath4, true, true); |
|
|
depth_small.Setup(modelPath4, false, true); |
|
|
emotion.Setup(modelPath3, false, true); |
|
|
emotion.Setup(modelPath3, false, true); |
|
|
|
|
|
|
|
|
/* Depth output fbo */ |
|
|
/* Depth output fbo */ |
|
@ -44,7 +43,9 @@ void ofApp::setup(){ |
|
|
|
|
|
|
|
|
screen_fbo.allocate(window_width, window_height, GL_RGB); |
|
|
screen_fbo.allocate(window_width, window_height, GL_RGB); |
|
|
|
|
|
|
|
|
thread1.setup(&map.fboImage, &model_output_fbo, &depth); |
|
|
threadMap.setup(&map.fboImage, &model_output_fbo, &depth); |
|
|
|
|
|
threadVideo.setup(&img, &model_output_fbo_1, &depth_small); |
|
|
|
|
|
threadYolo.setupYolo(&img, &detected_faces, &yolo, &faceDetector); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,10 +54,13 @@ void ofApp::setup(){ |
|
|
void ofApp::update(){ |
|
|
void ofApp::update(){ |
|
|
/* Check to see if the application has moved to the first frame
|
|
|
/* Check to see if the application has moved to the first frame
|
|
|
As the models need to load first, as the first inference is quite slow */ |
|
|
As the models need to load first, as the first inference is quite slow */ |
|
|
if(ofGetFrameNum() > 0 && ofGetFrameNum() < 2) |
|
|
if(ofGetFrameNum() > 0 && ofGetFrameNum() < 2){ |
|
|
firstRun = false; |
|
|
firstRun = false; |
|
|
thread1.start(); |
|
|
threadMap.start(); |
|
|
|
|
|
threadVideo.start(); |
|
|
|
|
|
threadYolo.start(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* Clear detetced face list */ |
|
|
/* Clear detetced face list */ |
|
|
detected_faces.clear(); |
|
|
detected_faces.clear(); |
|
|
|
|
|
|
|
@ -70,35 +74,22 @@ void ofApp::update(){ |
|
|
/* Setup model input using ofImage, allocated fbo */ |
|
|
/* Setup model input using ofImage, allocated fbo */ |
|
|
player.Update(img); |
|
|
player.Update(img); |
|
|
|
|
|
|
|
|
/* Run Models */ |
|
|
/* Run Models, and set pixels */ |
|
|
try{ |
|
|
try{ |
|
|
|
|
|
|
|
|
// // map
|
|
|
threadMap.update(); |
|
|
// inferDepthImage(model_output_fbo, map.fboImage, depth);
|
|
|
depth.SetPixels(model_output_fbo); |
|
|
|
|
|
|
|
|
// // video player
|
|
|
threadVideo.update(); |
|
|
// inferDepthImage(model_output_fbo_1, img, depth_small);
|
|
|
depth_small.SetPixels(model_output_fbo_1); |
|
|
|
|
|
|
|
|
// auto output_tensors_face = yolo.Run(model_input_img);
|
|
|
threadYolo.update(); |
|
|
|
|
|
|
|
|
// auto output_faces = output_tensors_face.front().GetTensorTypeAndShapeInfo().GetShape();
|
|
|
|
|
|
|
|
|
|
|
|
// unsigned int num_anchors = output_faces[1]; // Number of anchors
|
|
|
|
|
|
|
|
|
|
|
|
// float* output_face_ptr = output_tensors_face.front().GetTensorMutableData<float>();
|
|
|
faceDetector.ConvertBoxCoordsToOriginalSize(detected_faces, model_output_fbo_1.getWidth(), model_output_fbo_1.getHeight()); |
|
|
|
|
|
|
|
|
// faceDetector.ParseOutput(output_face_ptr, detected_faces, num_anchors);
|
|
|
|
|
|
|
|
|
|
|
|
// faceDetector.ConvertBoxCoordsToOriginalSize(detected_faces, outFbo.getWidth(), outFbo.getHeight());
|
|
|
|
|
|
|
|
|
|
|
|
/* As no input is generated for the emotion recognition model, run a dummy vector through the model
|
|
|
/* As no input is generated for the emotion recognition model, run a dummy vector through the model
|
|
|
So it can load */ |
|
|
So it can load */ |
|
|
if(firstRun){ |
|
|
if(firstRun){ |
|
|
// map
|
|
|
|
|
|
inferDepthImage(model_output_fbo, map.fboImage, depth); |
|
|
|
|
|
|
|
|
|
|
|
// video player
|
|
|
|
|
|
inferDepthImage(model_output_fbo_1, img, depth_small); |
|
|
|
|
|
/*
|
|
|
/*
|
|
|
Create a dummy initial input of batch_size = 5, as |
|
|
Create a dummy initial input of batch_size = 5, as |
|
|
when initialising the model, it will attempt to create a space in memory for this array. |
|
|
when initialising the model, it will attempt to create a space in memory for this array. |
|
@ -115,9 +106,6 @@ void ofApp::update(){ |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
//inferEmotionalState();
|
|
|
//inferEmotionalState();
|
|
|
thread1.update(); |
|
|
|
|
|
// video player
|
|
|
|
|
|
inferDepthImage(model_output_fbo_1, img, depth_small); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -146,10 +134,10 @@ void ofApp::draw(){ |
|
|
|
|
|
|
|
|
renderDepthMap(); |
|
|
renderDepthMap(); |
|
|
|
|
|
|
|
|
// if(!firstRun && detected_faces.size() != 0){
|
|
|
if(!firstRun && detected_faces.size() != 0){ |
|
|
// faceDetector.DrawBox(detected_faces);
|
|
|
faceDetector.DrawBox(detected_faces); |
|
|
// faceDetector.DrawCenter(detected_faces);
|
|
|
faceDetector.DrawCenter(detected_faces); |
|
|
// }
|
|
|
} |
|
|
|
|
|
|
|
|
ofPushMatrix(); |
|
|
ofPushMatrix(); |
|
|
ofSetColor(255); |
|
|
ofSetColor(255); |
|
|