mirror of
https://github.com/AntoineHX/LivingMachine.git
synced 2025-05-03 13:20:45 +02:00
Debut ajout bouton on/off
This commit is contained in:
parent
8c842d71bd
commit
0079ce6965
4 changed files with 28 additions and 20 deletions
|
@ -49,7 +49,7 @@ int main(int argc, char* argv[])
|
|||
sf::Texture txFlux;
|
||||
sf::Sprite spFlux;
|
||||
sf::Image imFlux;
|
||||
sf::Event event;
|
||||
sf::Event event;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -76,7 +76,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
#ifdef SFML
|
||||
//Création de la fenetre principale
|
||||
sf::RenderWindow window(sf::VideoMode(width, height), "KirbyTrack");
|
||||
sf::RenderWindow window(sf::VideoMode(width+300, height), "KirbyTrack");
|
||||
#endif
|
||||
|
||||
// Initialize different images that are going to be used in the program
|
||||
|
@ -115,7 +115,6 @@ int main(int argc, char* argv[])
|
|||
boucle = 1;
|
||||
#endif
|
||||
|
||||
<<<<<<< HEAD
|
||||
while(boucle)
|
||||
{
|
||||
|
||||
|
@ -152,7 +151,7 @@ int main(int argc, char* argv[])
|
|||
#ifdef SFML
|
||||
//Affichage SFML
|
||||
/* Clear the screen */
|
||||
window.clear(sf::Color::Black);
|
||||
window.clear(sf::Color::White);
|
||||
|
||||
//Conversion de la frame en image smfl
|
||||
/*if(image_CV2SFML(frame, imFlux)){
|
||||
|
@ -161,31 +160,52 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
*/
|
||||
//Enregistrement de la frame openCV
|
||||
cvSaveImage("temp.jpg", frame);
|
||||
cvSaveImage("Stock SFML/temp.jpg", frame);
|
||||
|
||||
//Chargement de la frame en texture SFML
|
||||
if (!txFlux.loadFromFile("temp.jpg")){
|
||||
if (!txFlux.loadFromFile("Stock SFML/temp.jpg")){
|
||||
printf("Erreur chargement image SFML\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
spFlux.setTexture(txFlux);
|
||||
|
||||
window.draw(spFlux);
|
||||
|
||||
window.draw(spFlux);
|
||||
//TEST SFML
|
||||
sf::Texture texture;
|
||||
if (!texture.loadFromFile("Stock SFML/red_button.jpeg")){
|
||||
printf("Erreur chargement image SFML\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
sf::Sprite sprite;
|
||||
sprite.setTexture(texture);
|
||||
|
||||
sprite.setPosition(sf::Vector2f(width, 0));
|
||||
|
||||
window.draw(sprite);
|
||||
|
||||
sf::Vector2i PosMouse = sf::Mouse::getPosition(window);
|
||||
|
||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&(PosMouse.x>640)&&(PosMouse.x<760)&&(PosMouse.y>0)&&(PosMouse.y<120)){
|
||||
printf("\n\n\n OK \n\n\n");
|
||||
}
|
||||
|
||||
printf("Pos Mouse : %d %d \n", PosMouse.x, PosMouse.y);
|
||||
|
||||
/* Update the window */
|
||||
window.display();
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
||||
//Mouvements moteurs
|
||||
printf("-PREMAJ_ANGLE...: %d %d\n",width,height);
|
||||
maj_angle(posX-width/2, posY-height/2, height/6, angle);
|
||||
controle_moteur(angle);
|
||||
cvWaitKey(50);
|
||||
|
||||
*/
|
||||
#ifdef CONFIG
|
||||
affichage_config(frame, hsv_frame, threshold); //Affichage du flux vidéo et de ses traitements
|
||||
|
||||
|
@ -261,18 +281,6 @@ void controle_moteur(int* angle){
|
|||
return;
|
||||
}
|
||||
|
||||
/*Verifie que les valeurs envoyees aux moteurs sont correctes*/
|
||||
int limite_moteur(int val_pwm){
|
||||
int MAX_PWM = 255;
|
||||
if (val_pwm > MAX_PWM || val_pwm < 0){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int image_CV2SFML(IplImage* imcv, sf::Image imFlux){
|
||||
|
||||
int R, G, B;
|
||||
|
|
BIN
Code/Stock SFML/green_button.jpeg
Normal file
BIN
Code/Stock SFML/green_button.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
Code/Stock SFML/red_button.jpeg
Normal file
BIN
Code/Stock SFML/red_button.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
Code/Stock SFML/temp.jpg
Normal file
BIN
Code/Stock SFML/temp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
Loading…
Add table
Add a link
Reference in a new issue