/*
* imgproc.cpp * * Created on: 20 Nov 2014 * Author: sarahnicholson */
include <stdio.h>
include "opencv2/core/core.hpp"
//#include "core/core.hpp"
include "opencv2/opencv.hpp"
include "opencv2/imgproc/imgproc.hpp"
using namespace cv; using namespace std;
ImgProc::ImgProc(VideoCapture vc) { ImgProc::cap = vc; }
ImgProc::~ImgProc() {
}
//Creates png from video frames. Images then used to crop samples for the classifier. void ImgProc::createPng() { vector<int> compression_params; compression_params.push_back(IMWRITE_PNG_COMPRESSION); compression_params.push_back(3); string fname; Mat frame_in; int num = 0; //int framecount = cap.get(CV_CAP_PROP_FRAME_COUNT); //int counter = round(framecount/20);
for (int i = 1; i<0; i++)
{
cap.read(frame_in);
}
while (1)
{
//skip 19 frames
for (int i = 0; i < 20; i++)
{
cap.read(frame_in);
}
//save the 20th frame as .png
num++;
std::stringstream sstm;
sstm << "class_imgs/" << num << ".png";
fname = sstm.str();
const char * c = fname.c_str();
try {
imwrite(c, frame_in, compression_params);
}
catch (runtime_error& ex) {
cout << "error" << endl;
}
}
}