Skip to content

Commit

Permalink
adding a half baked image input mode for issue FORTH-ModelBasedTracke…
Browse files Browse the repository at this point in the history
  • Loading branch information
AmmarkoV committed Apr 12, 2022
1 parent 569a586 commit c221793
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/MocapNET2/MocapNET2LiveWebcamDemo/livedemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,30 @@ int main(int argc, char *argv[])
std::cerr<<"Trying to open source ("<<options.webcamSource<<") \n";
VideoCapture cap(options.webcamSource); // open the default camera

int itIsTheFirstFrame=1;
Mat frame;
Mat frameCentered;

if (
(strstr(options.webcamSource,".jpg")!=0) ||
(strstr(options.webcamSource,".png")!=0)
)
{
std::cerr<<"Source seems to be a single image ("<<options.webcamSource<<") \n";
options.frameLimit = 10; //let it warmup for a few frames..
options.inputIsSingleImage = 1;
options.doOutputFiltering = 0; //There is no motion to filter so skip this
frame=imread(options.webcamSource);
} else
if (strstr(options.webcamSource,"/dev/video")!=0)
{
std::cerr<<"Source seems to be a webcam ("<<options.webcamSource<<" @ "<<options.width<<","<<options.height<<") \n";
options.inputIsSingleImage = 0;
cap.set(cv::CAP_PROP_FRAME_WIDTH,options.width);
cap.set(cv::CAP_PROP_FRAME_HEIGHT,options.height);
cap >> frame;
}

Mat frame;
Mat frameCentered;
int itIsTheFirstFrame=1;
cap >> frame;

//We will accept the input resolution and force it
//on visualization..
options.width = frame.size().width;
Expand Down Expand Up @@ -164,8 +176,9 @@ int main(int argc, char *argv[])
{
options.loopStartTime = GetTickCountMicrosecondsMN();

if (itIsTheFirstFrame) { itIsTheFirstFrame=0; } else
{ cap >> frame; }
if (options.inputIsSingleImage) { /*Do nothing*/ } else
if (itIsTheFirstFrame) { itIsTheFirstFrame=0; } else
{ cap >> frame; }

//If we are running in a low-end computer and need to keep in sync with a live video feed we can frame-skip
if (options.frameSkip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct MocapNET2Options
const char * webcamSource;
const char * path;
char * datasetPath;
unsigned int inputIsSingleImage;

unsigned int isJSONFile;
unsigned int isCSVFile;
unsigned int jointEstimatorUsed;
Expand Down

0 comments on commit c221793

Please sign in to comment.