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.
68 lines
2.1 KiB
68 lines
2.1 KiB
#include "ofApp.h"
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::setup(){
|
|
ofSetFrameRate(30);
|
|
ofEnableAlphaBlending();
|
|
|
|
videoPlayer.load(videoPath);
|
|
videoPlayer.setLoopState(OF_LOOP_NORMAL);
|
|
//videoPlayer.play();
|
|
|
|
inputImage.allocate(640, 640, OF_IMAGE_COLOR); // Allocate image, so we don't get any issues when processing on the thread
|
|
videoFrame.allocate(1280, 720, OF_IMAGE_COLOR);
|
|
|
|
webcam.setDeviceID(0);
|
|
webcam.setDesiredFrameRate(60);
|
|
webcam.setup(webcamWidth, webcamHeight);
|
|
|
|
ofLog() << "Webcam size: " << webcam.getWidth() << "x" << webcam.getHeight();
|
|
|
|
onnx.setup(&inputImage); // setup onnx -> will need to pass in a pointer to the two fbos?
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::update(){
|
|
//videoPlayer.update();
|
|
webcam.update();
|
|
// if(videoPlayer.isFrameNew()) {
|
|
// ofPixels & p = videoPlayer.getPixels();
|
|
// videoFrame.setFromPixels(p);
|
|
// }
|
|
|
|
if (webcam.isFrameNew() && webcam.isInitialized()) {
|
|
// ofPixels & webcamPixels = webcam.getPixels();
|
|
// // Resize webcamPixels to match videoFrame's size
|
|
// webcamPixels.resizeTo(videoFrame.getPixelsRef());
|
|
// videoFrame.setFromPixels(videoFrame.getPixels());
|
|
videoFrame.setFromPixels(webcam.getPixels());
|
|
}
|
|
onnx.update(videoFrame);
|
|
|
|
// Get the intensity, emotion of highest intensity, and number of people detected
|
|
teleprompter->updateCVData(onnx.detectedFaces.size(), onnx.dominantEmotion, onnx.highestEmotionIntensity);
|
|
|
|
//ofLog() << ofGetFrameRate();
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::draw(){
|
|
onnx.draw();
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::exit(){
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::keyPressed(int key){
|
|
if(key == 'f' || key == 'F'){
|
|
ofToggleFullscreen();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
void ofApp::keyReleased(int key){
|
|
|
|
}
|