Пример #1
0
int main(int argc, char *argv[]){

	char key = 'a';				// clef de contrôle du programme
	Flux_cam flux(-1, 40, 1, 3, 0);		// initialisation du flux webcam (/dev/video0)
	Gui gui;				// IHM
	Transfo transfo;
	Reco reco;
	IO_file io;
	Tracking tracking(40);
	int compteur = 0;
	int force_blur = atoi(argv[1]);
	cv::Size kernel_blur(force_blur, force_blur);

	// boucle d'exécution : appuyer sur 'q' pour quitter
	while(key != 'q'){
		key = flux.Get_key();
		// mettre à jour les images du flux
		flux.Update();
		cv::Mat flou;
		if(force_blur > 0){cv::blur(flux.Get_cam(), flou, kernel_blur);}
		else{flux.Get_cam().copyTo(flou);}
		// détecter le quadrillage
		reco.Set_img(flou);
		reco.Detecter_quadrillage();
		if(key == 's'){
			mkdir(("./output/" + to_string(compteur)).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
			vector <cv::Mat> liste_vignettes;
			vector < vector <cv::Point2i> > liste_quadrillage = reco.Get_quadrillage();
			for(int i = 0; i < liste_quadrillage.size(); i++){
				// transformation
				transfo.Set_img(flux.Get_cam());
				transfo.Set_pts_redressement(liste_quadrillage[i]);
				transfo.Appliquer_wrap_from_pts_input(4, cv::Size(200, 200), cv::Size(10, 10));
				cv::Mat img_redressee;
				transfo.Get_img_wrap().copyTo(img_redressee);
				liste_vignettes.push_back(img_redressee);
				imwrite("./output/" + to_string(compteur) + "/img_" + to_string(i) + ".png", liste_vignettes[i]);
			}
			for(int k = 0; k < compteur; k++){
				vector <STRUCT_NOM> liste = io.Lister_fichiers("./output/" + to_string(k), "png");
				for(size_t j = 0; j < liste.size(); j++){
					cout << liste[j].nom_complet << endl;
					cv::Mat old_img = cv::imread(liste[j].nom_complet);
					for(size_t i = 0; i < liste_vignettes.size() ; i++){
						tracking.Set_img_prev(old_img);
						tracking.Set_img_next(liste_vignettes[i]);
						if(tracking.Try_match(10, 5)){cout << "\tok avec " << k+1 << "-" << i << " avec orientation " << 90*tracking.Get_orientation() << "°" << endl;}
					}
				}
			}
			key = 'a';
			compteur++;
		}
		// afficher le résultat
		gui.Afficher_image("Video quadrillage", reco.Get_img_quadrillage());
	}
	return 0;

}
Пример #2
0
int main(){

	char key = 'a';				// clef de contrôle du programme
	Flux_cam flux(-1, 40, 1, 3, 0);		// initialisation du flux webcam (/dev/video0)
	Gui gui;				// IHM
	Instruments instrum(16 * 20, 300);

	// boucle d'exécution : appuyer sur 'q' pour quitter
	while(key != 'q'){
		key = flux.Get_key();
		// mettre à jour les images du flux
		flux.Update();
		// récupérer l'histogramme
		instrum.Set_img(flux.Get_cam());
		instrum.Calculer_hist_H(64);
		// afficher le résultat
		gui.Afficher_image("Video brute", flux.Get_cam());
		gui.Afficher_image("Histogramme H", instrum.Get_hist_H());
	}
	return 0;

}
Пример #3
0
int main(){

	char key = 'a';				// clef de contrôle du programme
	Flux_cam flux(-1, 40, 1, 3, 0);		// initialisation du flux webcam (/dev/video0)
	Gui gui;				// IHM
	gui.Creer_trackbar_transfo("Wrappeur");
	Transfo transfo;

	// boucle d'exécution : appuyer sur 'q' pour quitter
	while(key != 'q'){
		key = flux.Get_key();
		// mettre à jour les images du flux
		flux.Update();
		// afficher le résultat
		gui.Afficher_image("Video brute", flux.Get_cam());
		// transformation
		transfo.Set_img(flux.Get_cam());
		transfo.Definir_parametres_transformation(gui.Get_wrap_bound());
		transfo.Appliquer_wrap_from_structure();
		gui.Afficher_image("Transfo", transfo.Get_img_wrap());
	}
	return 0;

}
int main(){

	char key = 'a';				// clef de contrôle du programme
	Flux_cam flux(-1, 40, 1, 3, 1);		// initialisation du flux webcam (/dev/video0)
	Blobs blobs;				// séparateur de blobs
	Gui gui;				// IHM
	Tracking tracking(500);			// gestion temporelle
	gui.Creer_trackbar_HSV_sep("Separateur");

	// boucle d'exécution : appuyer sur 'q' pour quitter
	while(key != 'q'){
		key = flux.Get_key();
		// mettre à jour les images du flux
		flux.Update();
		// séparer les blobs
		blobs.Set_img(flux.Get_prev());
		blobs.Definir_limites_separation(gui.Get_HSV_bound());
		blobs.Separer();
		blobs.Trouver_blobs();
		// séparer les blobs statiques des blobs en mouvement
		tracking.Set_img_prev(flux.Get_prev());
		tracking.Set_img_next(flux.Get_next());
		tracking.Set_amers(blobs.Get_mc());
		tracking.Tracker();
		std::vector <cv::Point2i> pts_amers, pts_nv, pts_fixe, pts_dyn;
		pts_amers = tracking.Get_amers();
		pts_nv = tracking.Get_nv();
		for(size_t i = 0; i < pts_amers.size(); i++){
			int dist_c = Utils::Distance_carree(pts_amers[i].x, pts_amers[i].y, pts_nv[i].x, pts_nv[i].y);
			if(dist_c < SEUIL_DYNAMIQUE){
				pts_fixe.push_back(pts_amers[i]);
			}
			else{
				pts_dyn.push_back(pts_amers[i]);
			}
		}

		// relier les points
		std::vector <cv::Point2i> pts1, pts2;
		for(size_t i = 0; i < pts_fixe.size(); i++){
			for(size_t j = 0; j < pts_fixe.size(); j++){
				if(i != j){
					pts1.push_back(pts_fixe[i]);
					pts2.push_back(pts_fixe[j]);
				}
			}
		}
		for(size_t i = 0; i < pts_dyn.size(); i++){
			for(size_t j = 0; j < pts_dyn.size(); j++){
				if(i != j){
					pts1.push_back(pts_dyn[i]);
					pts2.push_back(pts_dyn[j]);
				}
			}
		}
		// afficher le résultat
		gui.Afficher_image("Video", flux.Get_prev());
		gui.Ajouter_vecteurs("Video pseudo3D", blobs.Get_img_blobs(), pts1, pts2);
	}


	return 0;

}