Closed MyVanitar closed 7 years ago
in yolo:
ofVideoPlayer movie;
darknet.yolo(movie.getPixels(), 0.24f);
in others, same basic idea. use movie.getPixels()
as input.
@genekogan
You mean I should modify inside ofApp.cpp
?
Where the path to the single image or recorded video should be defined?
@genekogan
This is all code inside that file:
#include "ofApp.h"
void ofApp::setup()
{
std::string cfgfile = ofToDataPath( "cfg/yolo-obj.cfg" );
std::string weightfile = ofToDataPath( "yolo-obj_2000.weights" );
std::string namesfile = ofToDataPath( "cfg/obj.names" );
darknet.init( cfgfile, weightfile, namesfile );
video.setDeviceID( 0 );
video.setDesiredFrameRate( 30 );
video.initGrabber( 640, 480 );
}
void ofApp::update()
{
video.update();
}
void ofApp::draw()
{
float thresh = ofMap( ofGetMouseX(), 0, ofGetWidth(), 0, 1 );
ofSetColor( 255 );
video.draw( 0, 0 );
if( video.isFrameNew() ) {
std::vector< detected_object > detections = darknet.yolo( video.getPixels(), thresh );
ofNoFill();
for( detected_object d : detections )
{
ofSetColor( d.color );
glLineWidth( ofMap( d.probability, 0, 1, 0, 8 ) );
ofNoFill();
ofDrawRectangle( d.rect );
ofDrawBitmapStringHighlight( d.label + ": " + ofToString(d.probability), d.rect.x, d.rect.y + 20 );
}
}
}
you can swap ofVideoGrabber for ofVideoPlayer into darknet. anything that has pixels can be run through. see ofVideoPlayer documentation on how to use the movie player.
Thank you. so as I understood, a single image will go through this either, yes?
yes.
Fine.
@mrzl @genekogan
Hi,
In the sample code, the default is a connected webcam or camera with device ID=0.
What about if we decided to process an image/recorded video instead of live video?