mirror of
https://github.com/AntoineHX/LivingMachine.git
synced 2025-05-04 05:40:46 +02:00
Bug SFML disparu ? Ajour du bouton reset (KirbyTrack) et rangements des fonctions de KirbyTrack
This commit is contained in:
parent
aad2b109a3
commit
c62f7fa243
8 changed files with 290 additions and 14 deletions
|
@ -5,13 +5,15 @@
|
|||
* \brief Figure Imposé : Suivi d'un objet coloré.
|
||||
*
|
||||
* \details Suivie d'un Kirby (Rose) ou d'une étoile (Jaune) par une caméra avec mode interface utilisateur ou configuration
|
||||
* \bug SFML ne supporte qu'un nombre limité de sprite en fonction du PC
|
||||
* \bug (Résolu ?) SFML ne supporte qu'un nombre limité de sprite en fonction du PC
|
||||
* \bug Affichage OpenCV incompatible avec SFML
|
||||
* \todo Optimisation du chargement de la frame en image SFML
|
||||
* \todo Verifier les angles du RESET
|
||||
*/
|
||||
|
||||
|
||||
#include "fonction.h"
|
||||
#include "fonction.c" //Pour le problème de référence indéfinie à la compilation
|
||||
|
||||
|
||||
/**
|
||||
|
@ -163,17 +165,30 @@ int main(int argc, char* argv[])
|
|||
|
||||
sf::Vector2i PosMouse = sf::Mouse::getPosition(window);
|
||||
//Detection du bouton tracking
|
||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&(PosMouse.x>640)&&(PosMouse.x<760)&&(PosMouse.y>0)&&(PosMouse.y<120)){
|
||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&(PosMouse.x>640)&&(PosMouse.x<760)&&(PosMouse.y>0)&&(PosMouse.y<110)){
|
||||
//printf("\n\n\n OK \n\n\n");
|
||||
if (tracking){ tracking = 0;}
|
||||
else tracking = 1;
|
||||
cvWaitKey(100);
|
||||
}
|
||||
|
||||
//Detection du bouton reset
|
||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&(PosMouse.x>640)&&(PosMouse.x<760)&&(PosMouse.y>110)&&(PosMouse.y<160)){
|
||||
//printf("\n\n\n OK \n\n\n");
|
||||
tracking = 0;
|
||||
//Reset Position moteur
|
||||
angle[0]=0; //ANGLES A VERIFIER
|
||||
angle[1]=0;
|
||||
controle_moteur(angle);
|
||||
|
||||
cvWaitKey(100);
|
||||
}
|
||||
//printf("Pos Mouse : %d %d \n", PosMouse.x, PosMouse.y);
|
||||
|
||||
//Dessin du bouton de tracking
|
||||
//Dessin des boutons
|
||||
sf::Texture txBut;
|
||||
sf::Sprite button_tracking;
|
||||
sf::Sprite button_reset;
|
||||
|
||||
if (!txBut.loadFromFile("Stock SFML/button.png")){
|
||||
printf("Erreur chargement image SFML\n" );
|
||||
|
@ -183,11 +198,16 @@ int main(int argc, char* argv[])
|
|||
button_tracking.setTexture(txBut);
|
||||
button_tracking.setScale(0.5,0.5);
|
||||
button_tracking.setPosition(sf::Vector2f(width+20, 20));
|
||||
|
||||
button_reset.setTexture(txBut);
|
||||
button_reset.setScale(0.5,0.5);
|
||||
button_reset.setPosition(sf::Vector2f(width+20, 100));
|
||||
|
||||
if(tracking){ button_tracking.setColor(sf::Color::Green); }
|
||||
else{ button_tracking.setColor(sf::Color::Red); }
|
||||
|
||||
window.draw(button_tracking);
|
||||
window.draw(button_reset);
|
||||
|
||||
//Ajout du texte
|
||||
sf::Font font;
|
||||
|
@ -196,22 +216,29 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
sf::Text text;
|
||||
sf::Text text_track;
|
||||
sf::Text text_reset;
|
||||
// choix de la police à utiliser
|
||||
text.setFont(font); // font est un sf::Font
|
||||
text_track.setFont(font); // font est un sf::Font
|
||||
text_reset.setFont(font);
|
||||
|
||||
// choix de la chaîne de caractères à afficher
|
||||
text.setString("Tracking Moteur");
|
||||
text_track.setString("Tracking Moteurs");
|
||||
text_reset.setString("Reset Moteurs");
|
||||
|
||||
// choix de la taille des caractères
|
||||
text.setCharacterSize(24); // exprimée en pixels, pas en points !
|
||||
text_track.setCharacterSize(24); // exprimée en pixels, pas en points !
|
||||
text_reset.setCharacterSize(24);
|
||||
|
||||
//text.setFillColor(sf::Color::Black);
|
||||
text.setColor(sf::Color::Black);
|
||||
text_track.setColor(sf::Color::Black);
|
||||
text_reset.setColor(sf::Color::Black);
|
||||
|
||||
text.setPosition(sf::Vector2f(width+100, 35));
|
||||
text_track.setPosition(sf::Vector2f(width+100, 35));
|
||||
text_reset.setPosition(sf::Vector2f(width+100, 115));
|
||||
|
||||
window.draw(text);
|
||||
window.draw(text_track);
|
||||
window.draw(text_reset);
|
||||
|
||||
/* Update the window */
|
||||
window.display();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue