Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

how can solve this "frame" error?

$
0
0

Fellows, 

I have write this code, but he does not run, and returns me an error saying "error C2065: 'frame' : undeclared identifier"

/**************************INCLUDE*************************/
#include "cv.h"
#include "highgui.h"
//#include "Interface.h"
#include "ml.h"
#include <stdio.h>
#include <math.h>



using namespace cv;
//using namespace std;

void deteccaoMostra(Mat frame);

/*Variaveis globais*/
String face_cascade_nome = "haarcascade_frontalface_alt.xml";
CascadeClassifier face_cascade;
String window_name = "Video Captura- Detecção de Face";

/*Main*/
int main(){
	VideoCapture captura;
	Mat frame;
	/*Carega o algoritmo de cascade*/
	if (!face_cascade.load(face_cascade_nome)){ printf("--(!)Erro "); return -1; };

	/*Ler o stream de video*/
	captura.open(-1);
	if (!captura.isOpened()) { printf("--(!)Erroao abrir a captura de Video\n"); return -1; }

	while (captura.read(frame)){

		if (frame.empty()){
			printf(" --(!) Não existem frames capturadas-- Break!");
			break;
		}

		/*Aplicacao do classificador a frame*/
		deteccaoMostra(frame);

		int c = waitKey(10);
		if ((char)c == 27) { break; } // escape
	}
	return 0;
}
/*Dectçao e amostra de face*/
void deteccaoMostra(){

	std::vector<Rect> faces;
	Mat frame_gray;

	cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
	equalizeHist(frame_gray, frame_gray);
	/*Deteccao de faces*/
	face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));
	for (size_t i = 0; i < faces.size(); i++)
	{
		Point center(faces[i].x + faces[i].width / 2, faces[i].y + faces[i].height / 2);
		ellipse(frame, center, Size(faces[i].width / 2, faces[i].height / 2), 0, 0, 360, Scalar(255, 0, 255), 4, 8, 0);


	}
	//-- Show what you got
	imshow(window_name, frame);
}


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>