Im working with this code which is supposed to detect faces. The code works totally fine, but as soon as I try to insert three lines for writing to csv file, it breaks down with lengthy error of some 100+ lines -ERROR FILE LOG.
This code was taken from :- https://github.com/shunyaos/shunyaface
// Header file for Face-Recognition/Detection
#include "shunyaface.h"
#include "opencv2/opencv.hpp"
#include <bits/stdc++.h>
#include "fstream"
using namespace std;
using namespace cv;
int main(int argc, char** argv){
// Create instance of class FaceRec
std::ofstream filename("test.csv");
filename<< "TESTING CSV WRITE";
FaceRec facerec;
Mat frame;
Mat frame2;
clock_t start, end; //This will hold the start and end-time
int count = 0; //Variable which hold the number of frames elapsed
VideoCapture cap(0);
time(&start);
while(1)
{
// Capture a frame
cap >> frame;
// Pass the frame to the detect function which will return the frame with a bounding-box on the face and points on the lips and eyes
frame2 = facerec.detect(frame);
count++; //Increment count
// Display the frame to the user
imshow("face-detect", frame2);
if(waitKey(1) == 'q')
break;
}
time(&end); // Stop the time
cout<< "Output FPS is:"<<count/(end-start)<<endl; //Display Output-FPS
filename.close();
return 0;
}
So basically as shown above,after inclusion of these lines the code is breaking :-
std::ofstream filename("test.csv");
filename<< "TESTING CSV WRITE";
filename.close()
You forget to end this line cout<< "In while"<<
.
Somewhere in your code is this snippet
out<< "In while"<<
// Capture a frame
~~~~~~~~~~~~~~~~~~
cap >> frame;
You should try to fix error from top to bottom. The first error is regarding cout
, operator<<
and cv::VideoCapture cap
.