├── Electronic └── readme.txt ├── Firmware ├── Capture.py ├── control_motor.py ├── data │ └── data.rar ├── database.py ├── database │ └── database.rar ├── identColor.py ├── main.py ├── mnist_model_convolutionnel.py ├── processing.py ├── readme.txt ├── solver.py ├── tensor │ ├── checkpoint │ ├── tensor_v1.0.data-00000-of-00001 │ ├── tensor_v1.0.index │ └── tensor_v1.0.meta ├── thresholding.py ├── trackStat.py └── tracking.py ├── GNU GPLv3 ├── Mechanical └── readme.txt ├── README.md └── Ressources ├── Rapport de reformulation ├── box 2.png ├── box 4.png ├── box0.png ├── fonctionnel.docx ├── gantt.png ├── hg1.PNG ├── hg2.PNG ├── hg3.PNG ├── hough.png ├── hough1.png ├── ii.jpg ├── ii2.png ├── lettre_motiv.aux ├── lettre_motiv.log ├── lettre_motiv.out ├── lettre_motiv.pdf ├── lettre_motiv.synctex.gz ├── lettre_motiv.tex ├── lettre_motiv.toc ├── pp.png ├── pre_rapport_robot_sudoku_sicom2A_groupe3(1).pdf ├── pre_rapport_robot_sudoku_sicom2A_groupe3.pdf ├── pxy-img0.png ├── pxy.pgf └── sud1.png ├── Rapport final ├── 4-8c.png ├── 4c.PNG ├── 8c.PNG ├── Rapport_final_Sudoku_sicom.rar ├── b0.PNG ├── b1.PNG ├── b12.PNG ├── b13.PNG ├── b2.PNG ├── b3.PNG ├── b4.PNG ├── b5.PNG ├── b6.PNG ├── b7.PNG ├── b8.PNG ├── b9.PNG ├── e1.jpg ├── e2.png ├── e3.png ├── ecc.PNG ├── final.aux ├── final.log ├── final.out ├── final.synctex.gz ├── final.tex ├── final.toc ├── gantt.png ├── hg1.PNG ├── hough.png ├── k1.PNG ├── k2.png ├── lign_degra.PNG ├── logo_phelma.png ├── pcb.PNG ├── poster_sudoku_sicom2a.png ├── pp.jpg ├── rapport_final_sudoku_sicom2a.pdf ├── rec.PNG ├── reco.PNG ├── test.log ├── test.out ├── test.pdf ├── test.synctex.gz └── test.tex ├── livrable-mi-projet-sudoku-groupe3.rar ├── mi-rapport ├── Readme.txt ├── mi-rapport-sudoku-sicomb.docx └── mi-rapport-sudoku-sicomb.pdf ├── readme.txt └── sud-generation ├── Readme.txt └── generation.tex /Electronic/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Electronic/readme.txt -------------------------------------------------------------------------------- /Firmware/Capture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import picamera 4 | 5 | def capture(): 6 | camera = picamera.PiCamera() 7 | camera.rotation = 180 8 | camera.start_preview() 9 | raw_input("Press enter to continue") 10 | camera.stop_preview() 11 | camera.capture('rawImage.jpg') 12 | 13 | #capture() 14 | -------------------------------------------------------------------------------- /Firmware/control_motor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import RPi.GPIO as GPIO 4 | import time 5 | import numpy as np 6 | from math import * 7 | ## parametrage raspberry pi 8 | GPIO.setmode(GPIO.BOARD) #notation board plutôt que BCM 9 | 10 | 11 | m1_pin_bobine_1_1 = 3 #GPIO moteur haut 12 | m1_pin_bobine_1_2 = 5 #GPIO 13 | m1_pin_bobine_2_1 = 11 #GPIO 14 | m1_pin_bobine_2_2 = 13 #GPIO 15 | 16 | 17 | m2_pin_bobine_1_1 = 8 #GPIO moteur planche 18 | m2_pin_bobine_1_2 = 10 #GPIO 19 | m2_pin_bobine_2_1 = 16 #GPIO 20 | m2_pin_bobine_2_2 = 18 #GPIO 21 | 22 | m_standby= [0 , 7, 22] # standby des moteurs 23 | 24 | servo_moteur = 12 #GPIO servomoteur 25 | 26 | pin_fin_de_course1 = 21; 27 | pin_fin_de_course2 = 19; 28 | pin_demarrage = 15; 29 | pin_reset = 23; 30 | 31 | pin_DEL_red = 24; 32 | pin_DEL_jaune = 26; 33 | pin_DEL_verte = 29; 34 | 35 | # configuration des pins en sortie 36 | GPIO.setup(m1_pin_bobine_1_1, GPIO.OUT) 37 | GPIO.setup(m1_pin_bobine_1_2, GPIO.OUT) 38 | GPIO.setup(m1_pin_bobine_2_1, GPIO.OUT) 39 | GPIO.setup(m1_pin_bobine_2_2, GPIO.OUT) 40 | GPIO.setup(m2_pin_bobine_1_1, GPIO.OUT) 41 | GPIO.setup(m2_pin_bobine_1_2, GPIO.OUT) 42 | GPIO.setup(m2_pin_bobine_2_1, GPIO.OUT) 43 | GPIO.setup(m2_pin_bobine_2_2, GPIO.OUT) 44 | GPIO.setup(m_standby[1], GPIO.OUT) 45 | GPIO.setup(m_standby[2], GPIO.OUT) 46 | GPIO.setup(servo_moteur, GPIO.OUT) 47 | # configuration des pins en entree 48 | GPIO.setup(pin_fin_de_course1, GPIO.IN) 49 | GPIO.setup(pin_fin_de_course2, GPIO.IN) 50 | GPIO.setup(pin_demarrage, GPIO.IN) 51 | GPIO.setup(pin_reset, GPIO.IN) 52 | GPIO.setup(pin_DEL_jaune, GPIO.IN) 53 | GPIO.setup(pin_DEL_red, GPIO.IN) 54 | GPIO.setup(pin_DEL_verte, GPIO.IN) 55 | #constante et etat inital 56 | GPIO.output(m_standby[1], 0) 57 | GPIO.output(m_standby[2], 0) 58 | 59 | pwm = GPIO.PWM(servo_moteur, 50) #servomoteur 60 | pwm.start(7) #servomoteur 61 | 62 | attente= 0.005 #définir et fixer en second, controle la vitesse des moteurs (plus attente grande, plus vitesse faible) 63 | conv = 51 # conversion taille de la case - nombre de pas en pas/cm 64 | 65 | conv_pix = 0.016 #conv de pixel en cm (depend de la hauteur de la camera) 66 | 67 | def fin_de_course(m): #fonction qui ramene les moteurs en fin de course 68 | if m == 1 :#moteur 1 69 | GPIO.output(m_standby[m], 1) 70 | while GPIO.input(pin_fin_de_course1): 71 | 72 | for i in range(0, 4):# envoie des signaux de commandes au moteur 73 | prochainStep(3 - (i % 4),m) 74 | time.sleep(attente) 75 | GPIO.output(m_standby[m], 0) 76 | else:#moteur 2 77 | GPIO.output(m_standby[m], 1) 78 | while GPIO.input(pin_fin_de_course2): 79 | for i in range(0, 4): 80 | prochainStep(3 - (i % 4),m) 81 | time.sleep(attente) 82 | GPIO.output(m_standby[m], 0) 83 | 84 | def calcul_angle(angle, ang ): #bas de la grille par rapport a l'horizontale ang est l'angle par pas de 90° 85 | if (-45 evolution en implementant les threads (à faire) 155 | if (abs(traitm1) < abs(traitm2)):#si traitm1 4 (avec le sens) 162 | 163 | 164 | else: 165 | if (round(traitm2) == 0): 166 | pasm2 = 0 167 | pasm1 = round(traitm1*sens) 168 | else: 169 | pasm1 = round( nb_pas*traitm1*sens/abs(traitm2)) 170 | pasm2 = round( nb_pas*traitm2*sens/abs(traitm2)) 171 | 172 | if(abs(pasm1) > trait):# le nombre de pas à effectuer ne doit pas etre plus grand que la variable trait (cas des petits angles) 173 | pasm1 = round(trait*pasm1/abs(pasm1)) 174 | pasm2 = 0 175 | if(abs(pasm2) > trait): 176 | pasm2 = round(trait*pasm2/abs(pasm2)) 177 | pasm1 = 0 178 | 179 | if abs(pasm1) < abs(pasm2) : #choix de fonctionnement dans la boucle while 180 | 181 | p =1 182 | else : 183 | 184 | p=2 185 | 186 | if pasm1 < 0: #permet de définir le sens des moteurs dans le boucle while car les fonctions marche_avant et marche_arriere ne prend que des entiers positifs 187 | sensm1 =-1 188 | pasm1 = abs(pasm1) 189 | else: 190 | sensm1 = 1 191 | if pasm2 < 0: 192 | sensm2 =-1 193 | pasm2 = abs(pasm2) 194 | else: 195 | sensm2 = 1 196 | 197 | depl = 0 # variable qui compte le nombre de pas effectué 198 | pas_err =0 # permet de compter le nombre de pas non effectué car si un des moteurs fait 4 pas l'autre peut en faire 13 or les moteurs ne font que 199 | #des multiples de 4 pas ainsi le moteur fera 12 pas et il y aura un pas d'erreur 200 | while (depl < trait-3):# test du nombre de pas effectué (-3 permet de s'affranchir à la fin du fait qu'il peut manquer 4 pas sans refaire une itération) 201 | 202 | 203 | if p == 1:# si pasm1 0): #inversion par rapport au moteur 1 car c'est la feuille qui bouge 219 | marche_arriere(attente, pas_dep,2) 220 | else: 221 | marche_avant(attente, pas_dep, 2) 222 | 223 | 224 | 225 | else:# si pasm1>pasm2 alors pasm2 = 4 ou 0 donc pas besoin de tester les erreurs de pas sur pasm2 226 | 227 | if (sensm2 > 0): #inversion par rapport au moteur 1 car c la feuille qui bouge 228 | marche_arriere(attente, pasm2,2) 229 | else: 230 | marche_avant(attente, pasm2, 2) 231 | 232 | 233 | pas_attente = pasm2 234 | 235 | 236 | 237 | pas_dep = pasm1 + pas_err 238 | pas_err = pas_dep%nb_pas 239 | pas_dep = pas_dep - pas_err 240 | if (sensm1 < 0): 241 | marche_arriere(attente, pas_dep,1) 242 | else: 243 | marche_avant(attente, pas_dep, 1) 244 | 245 | 246 | 247 | depl = depl + sqrt(pas_dep*pas_dep+pas_attente*pas_attente) # calcul du nombre de pas effectué (hypotenuse) 248 | if p ==1: 249 | if(abs((trait -depl)*sin(angle)) < pasm2): # permet de determiner s'il reste moins de pasm2 à parcourir et réajuster le pasm2 afin que 250 | #depl ne dépasse pas trait 251 | pasm2 = abs(round(sin(angle)*(trait - depl))) 252 | else: 253 | if(abs((trait -depl)*cos(angle)) < pasm1):#idem dans le cas pasm1>pasm2 pour pasm1 254 | pasm1 = abs(round(cos(angle)*(trait - depl))) 255 | 256 | 257 | 258 | 259 | def trait_hori(taille, angle, sens):#tracer un trait horizontal 260 | rotation_et_deplacement(taille , angle, sens) 261 | 262 | def trait_verti(taille, angle, sens):#tracer un trait vertical 263 | rotation_et_deplacement(taille , angle + 90, sens) 264 | 265 | def write_one(taille,angle):# ecriture du chiffre un avec l'utilisation du stylo, le stylo revient toujours au meme endroit 266 | trait_hori(taille, angle, 1) 267 | position_stylo(1) 268 | trait_verti(2*taille, angle, 1) 269 | position_stylo(0) 270 | trait_verti(2*taille, angle, -1) 271 | trait_hori(taille, angle, -1) 272 | 273 | def write_two(taille,angle): 274 | 275 | trait_hori(taille, angle, 1) 276 | position_stylo(1) 277 | trait_hori(taille, angle, -1) 278 | trait_verti(taille, angle, 1) 279 | trait_hori(taille, angle, 1) 280 | trait_verti(taille, angle, 1) 281 | trait_hori(taille, angle, -1) 282 | position_stylo(0) 283 | trait_verti(2*taille, angle, -1) 284 | 285 | def write_three(taille,angle): 286 | position_stylo(1) 287 | trait_hori(taille, angle, 1) 288 | trait_verti(taille, angle, 1) 289 | trait_hori(taille, angle, -1) 290 | trait_hori(taille, angle, 1) 291 | trait_verti(taille, angle, 1) 292 | trait_hori(taille, angle, -1) 293 | position_stylo(0) 294 | trait_verti(2*taille, angle, -1) 295 | 296 | def write_four(taille,angle): 297 | 298 | trait_hori(taille, angle, 1) 299 | position_stylo(1) 300 | trait_verti(2*taille, angle, 1) 301 | trait_verti(taille, angle, -1) 302 | trait_hori(taille, angle, -1) 303 | trait_verti(taille, angle, 1) 304 | position_stylo(0) 305 | trait_verti(2*taille, angle, -1) 306 | 307 | 308 | def write_five(taille,angle): 309 | position_stylo(1) 310 | trait_hori(taille, angle, 1) 311 | trait_verti(taille, angle, 1) 312 | trait_hori(taille, angle, -1) 313 | trait_verti(taille, angle, 1) 314 | trait_hori(taille, angle, 1) 315 | position_stylo(0) 316 | trait_verti(2*taille, angle, -1) 317 | trait_hori(taille,angle,-1) 318 | 319 | def write_six(taille,angle): 320 | trait_hori(taille, angle, 1) 321 | trait_verti(2*taille, angle, 1) 322 | position_stylo(1) 323 | trait_hori(taille, angle, -1) 324 | trait_verti(2*taille, angle, -1) 325 | trait_hori(taille, angle, 1) 326 | trait_verti(taille, angle, 1) 327 | trait_hori(taille, angle, -1) 328 | position_stylo(0) 329 | trait_verti(taille, angle, -1) 330 | 331 | def write_seven(taille,angle): 332 | trait_hori(taille, angle, 1) 333 | position_stylo(1) 334 | trait_verti(2*taille, angle, 1) 335 | trait_hori(taille, angle, -1) 336 | position_stylo(0) 337 | trait_verti(2*taille, angle, -1) 338 | 339 | def write_heigt(taille,angle): 340 | position_stylo(1) 341 | trait_hori(taille, angle, 1) 342 | trait_verti(taille, angle, 1) 343 | trait_hori(taille, angle, -1) 344 | trait_verti(taille, angle, -1) 345 | trait_verti(2*taille, angle, 1) 346 | trait_hori(taille, angle, 1) 347 | trait_verti(2*taille, angle, -1) 348 | position_stylo(0) 349 | trait_hori(taille,angle,-1) 350 | 351 | def write_nine(taille,angle): 352 | position_stylo(1) 353 | trait_hori(taille, angle, 1) 354 | trait_verti(2*taille, angle, 1) 355 | trait_hori(taille, angle, -1) 356 | trait_verti(taille, angle, -1) 357 | trait_hori(taille, angle, 1) 358 | position_stylo(0) 359 | trait_verti(taille, angle, -1) 360 | trait_hori(taille, angle, -1) 361 | 362 | options = { #bibliotheque des chiffres 363 | 1 : write_one, 364 | 2 : write_two, 365 | 3 : write_three, 366 | 4 : write_four, 367 | 5 : write_five, 368 | 6 : write_six, 369 | 7 : write_seven, 370 | 8 : write_heigt, 371 | 9 : write_nine, 372 | 373 | } 374 | 375 | def number_write(taille, angle, number): #fonction d'écriture des chiffres (la taille est legerement diminuée pour eviter les imperfections d'écriture 376 | taille = taille * 0.8 377 | options[number](taille,angle) 378 | 379 | def deplacement(mat,recogn,taille,coin,angle):#deplacement de case en case avec ecriture des chiffres quand il le faut. (deplacement en serpent) 380 | n = 1;#initialisation du nombre de case parcouru (81 en tout) 381 | if coin == 1: #si le coin ou est positionné le stylo est le coin 1 382 | trait_verti(2.5*taille,angle,-1) #On se positionne à dans la case à un tier du bas de la case et un tier 383 | #du coté gauche de la case (pareil pour toutes les cases) 384 | trait_hori(taille, angle, 1) 385 | raw_input("Verify and press enter to continue") 386 | i = 0 #premiere case en haut a gauche 387 | j = 0 388 | if(recogn[i][j] == 0): # si 0 alors case vide, il faut ecrire un chiffre 389 | number_write(taille, angle, mat[i][j]) 390 | j=1 391 | trait_hori(3*taille, angle, 1)#deplacement à la case suivante 392 | while n < 81: 393 | 394 | 395 | 396 | if(recogn[i][j] == 0): 397 | number_write(taille, angle, mat[i][j]) 398 | 399 | if ((j !=8 and j != 0)):# si on est sur un bord alors il faut passer à la ligne d'en dessous 400 | 401 | if(i%2 == 0):# ligne paire, on se deplace vers la droite 402 | trait_hori(3*taille, angle, 1) 403 | j=j+1 404 | else:#ligne impaire , on se deplace vers la gauche 405 | trait_hori(3*taille, angle, -1) 406 | j=j-1 407 | else:# passage à la ligne en dessous 408 | trait_verti(3*taille,angle,-1)#desente d'une ligne 409 | i = i+1 #incrémentation des lignes 410 | if(i>8): break #si on depasse le nombre de ligne, on sort de la boucle afin d'éviter d'écrire de nouveau chiffre 411 | if(recogn[i][j] == 0): #on reteste la case dans le else sinon à la prochaine iteration on repasse dans le else 412 | number_write(taille, angle, mat[i][j]) 413 | if(i%2 == 0): 414 | trait_hori(3*taille, angle, 1) 415 | j=j+1 416 | else: 417 | trait_hori(3*taille, angle, -1) 418 | j=j-1 419 | n = n+1 420 | 421 | n = n+1 422 | 423 | 424 | if coin == 2: #demarrage au coin 2 en haut a droite 425 | trait_verti(2.5*taille,angle,-1) 426 | trait_hori(2*taille, angle, -1) 427 | raw_input("Press enter to continue") 428 | 429 | i = 0 430 | j = 8 431 | if(recogn[i][j] == 0): 432 | number_write(taille, angle, mat[i][j]) 433 | j=7 434 | trait_hori(3*taille, angle, -1) 435 | while n < 81: 436 | 437 | 438 | 439 | if(recogn[i][j] == 0): 440 | number_write(taille, angle, mat[i][j]) 441 | 442 | if (j !=8 and j != 0): 443 | 444 | if(i%2 == 0): 445 | trait_hori(3*taille, angle, -1) 446 | j=j-1 447 | else: 448 | trait_hori(3*taille, angle, 1) 449 | j=j+1 450 | else: 451 | trait_verti(3*taille,angle,-1) 452 | i = i+1 453 | if(i>8): break 454 | if(recogn[i][j] == 0): 455 | number_write(taille, angle, mat[i][j]) 456 | if(i%2 == 0): 457 | trait_hori(3*taille, angle, -1) 458 | j=j-1 459 | else: 460 | trait_hori(3*taille, angle, 1) 461 | j=j+1 462 | n = n+1 463 | n = n+1 464 | 465 | if coin == 3: 466 | trait_verti(0.5*taille,angle,1) 467 | trait_hori(taille, angle, 1) 468 | raw_input("Press enter to continue") 469 | 470 | i = 8 471 | j = 0 472 | if(recogn[i][j] == 0): 473 | number_write(taille, angle, mat[i][j]) 474 | j=1 475 | trait_hori(3*taille, angle, 1) 476 | while n < 81: 477 | 478 | #print(i,j,n) 479 | 480 | if(recogn[i][j] == 0): 481 | number_write(taille, angle, mat[i][j]) 482 | 483 | if (j !=8 and j != 0): 484 | 485 | if(i%2 == 0): 486 | trait_hori(3*taille, angle, 1) 487 | j=j+1 488 | else: 489 | trait_hori(3*taille, angle, -1) 490 | j=j-1 491 | else: 492 | trait_verti(3*taille,angle,1) 493 | i = i-1 494 | if(i<0): break 495 | if(recogn[i][j] == 0): 496 | number_write(taille, angle, mat[i][j]) 497 | if(i%2 == 0): 498 | trait_hori(3*taille, angle, 1) 499 | j=j+1 500 | else: 501 | trait_hori(3*taille, angle, -1) 502 | j=j-1 503 | n = n+1 504 | n = n+1 505 | 506 | 507 | 508 | if coin == 4: 509 | trait_verti(0.5*taille,angle,1) 510 | trait_hori(2*taille, angle, -1) 511 | raw_input("Press enter to continue") 512 | 513 | i = 8 514 | j = 8 515 | if(recogn[i][j] == 0): 516 | number_write(taille, angle, mat[i][j]) 517 | j=7 518 | trait_hori(3*taille, angle, -1) 519 | while n < 81: 520 | 521 | 522 | 523 | if(recogn[i][j] == 0): 524 | number_write(taille, angle, mat[i][j]) 525 | 526 | if (j !=8 and j != 0): 527 | 528 | if(i%2 == 0): 529 | trait_hori(3*taille, angle, -1) 530 | j=j-1 531 | else: 532 | trait_hori(3*taille, angle, 1) 533 | j=j+1 534 | else: 535 | trait_verti(3*taille,angle,1) 536 | i = i-1 537 | if(i<0): break 538 | if(recogn[i][j] == 0): 539 | number_write(taille, angle, mat[i][j]) 540 | if(i%2 == 0): 541 | trait_hori(3*taille, angle, -1) 542 | j=j-1 543 | else: 544 | trait_hori(3*taille, angle, 1) 545 | j=j+1 546 | n = n+1 547 | n = n+1 548 | 549 | 550 | def calc_coin(angle): # renvoi le coin sur lequel le stylo doit etre positionné (stylo initalement tout a gauche, le coin et aussi toujours celui le plus a gauche) 551 | #coin 1 en haut a gauche de la grille 552 | #coin 2 en haut a droite 553 | #coin 3 en bas à gauche 554 | #coin 4 en bas à droite 555 | angle = angle%360 556 | if (angle <=90 and angle >0): 557 | coin = 1 558 | elif (angle <=180 and angle >90): 559 | coin = 2 560 | elif (angle <=270 and angle >180): 561 | coin = 4 562 | else: 563 | coin = 3 564 | return coin 565 | 566 | 567 | 568 | 569 | def track():#fonction de controle des moteurs avec tracking grace à la camera (a faire) 570 | a,b = trackStat((155, 120, 90), (180, 155, 190), (60, 50, 40),(120, 85, 100)) 571 | #a point rouge, b point vert 572 | # ([894, 366], [793, 884]) 573 | 574 | #intialisation des moteurs en position de démarrage 575 | position_stylo(0) 576 | fin_de_course(1) 577 | fin_de_course(2) 578 | 579 | 580 | 581 | #### a decommenter pour test #### 582 | ##pwm.stop() 583 | ##GPIO.cleanup() 584 | -------------------------------------------------------------------------------- /Firmware/data/data.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/data/data.rar -------------------------------------------------------------------------------- /Firmware/database.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | #import numpy as np 5 | import cv2 6 | import os 7 | from processing import * 8 | import random as rd 9 | path = '/media/pi/PKBACK# 001/Images sudoku/Sudoku-robot/Ressources/database/' 10 | class base(object): 11 | def __init__(self,train,test,validation = 0): 12 | self.train = train 13 | self.test = test 14 | self.validation = validation 15 | 16 | 17 | class DataSet(object): 18 | 19 | def __init__(self, 20 | images, 21 | labels): 22 | """Construct a DataSet. 23 | one_hot arg is used only if fake_data is true. `dtype` can be either 24 | `uint8` to leave the input as `[0, 255]`, or `float32` to rescale into 25 | `[0, 1]`. 26 | """ 27 | assert len(labels) == len(images) 28 | self._num_examples = len(images) 29 | self._images = images 30 | self._labels = labels 31 | self._epochs_completed = 0 32 | self._index_in_epoch = 0 33 | 34 | @property 35 | def images(self): 36 | return self._images 37 | 38 | @property 39 | def labels(self): 40 | return self._labels 41 | 42 | @property 43 | def num_examples(self): 44 | return self._num_examples 45 | 46 | @property 47 | def epochs_completed(self): 48 | return self._epochs_completed 49 | 50 | def next_batch(self, batch_size): 51 | """Return the next `batch_size` examples from this data set.""" 52 | start = self._index_in_epoch 53 | self._index_in_epoch += batch_size 54 | if self._index_in_epoch > self._num_examples: 55 | # Finished epoch 56 | self._epochs_completed += 1 57 | # Shuffle the data 58 | perm = np.arange(self._num_examples) 59 | np.random.shuffle(perm) 60 | self._images = self._images[perm] 61 | self._labels = self._labels[perm] 62 | # Start next epoch 63 | start = 0 64 | self._index_in_epoch = batch_size 65 | assert batch_size <= self._num_examples 66 | end = self._index_in_epoch 67 | return self._images[start:end], self._labels[start:end] 68 | 69 | def to_one_hot(labels, num_classes): 70 | """Convert class labels from scalars to one-hot vectors.""" 71 | num_labels = labels.shape[0] 72 | index_offset = np.arange(num_labels) * num_classes 73 | labels_one_hot = np.zeros((num_labels, num_classes)) 74 | labels_one_hot.flat[index_offset + labels.ravel()] = 1 75 | return labels_one_hot 76 | 77 | 78 | images = [] 79 | labels = [] 80 | ##eps = 0.1*255 81 | ##for file in os.listdir(path): 82 | ## label = [int(s) for s in list(file) if s.isdigit()][0] 83 | ## labels.append(label) 84 | ## image = 255 - cv2.cvtColor(cv2.imread(path+file),cv2.COLOR_BGR2GRAY) #inverser l'image 85 | ## ret,image = binarize(image,cv2.THRESH_OTSU) 86 | ## images.append(np.reshape(image/255,image.shape[0]*image.shape[1])) #puis convertir [0,255] ->[0,1] 87 | ## 88 | ##num_classes = 10 #chiffres de 0 à 9 89 | ##labels = to_one_hot(np.array(labels),num_classes) 90 | labels = np.array(labels) 91 | images = np.array(images) 92 | test = DataSet(images,labels) 93 | 94 | ##path = '/media/pi/PKBACK# 001/Images sudoku/Sudoku-robot/Ressources/data/' 95 | ##images = [] 96 | ##labels = [] 97 | ##image_label = [] 98 | ##tab = np.zeros(10) 99 | ##for file in os.listdir(path): 100 | ## label = [int(s) for s in list(file) if s.isdigit()][0] 101 | ## tab[label] +=1 102 | ## #labels.append(label) 103 | ## image = 255 - cv2.cvtColor(cv2.imread(path+file),cv2.COLOR_BGR2GRAY) #inverser l'image 104 | ## ret,image = binarize(image,cv2.THRESH_OTSU) 105 | ## #images.append(np.reshape(image/255,image.shape[0]*image.shape[1])) #puis convertir [0,255] ->[0,1] 106 | ## image_label.append((image,label)) 107 | ## 108 | ##num_classes = 10 #chiffres de 0 à 9 109 | ##rd.shuffle(image_label) 110 | ##for i in range(len(image_label)): 111 | ## images.append(np.reshape(image_label[i][0]/255,image_label[i][0].shape[0]*image_label[i][0].shape[1])) 112 | ## labels.append(image_label[i][1]) 113 | ##labels = to_one_hot(np.array(labels),num_classes) 114 | images = np.array(images) 115 | 116 | train = DataSet(images,labels) 117 | data = base(train,test) 118 | -------------------------------------------------------------------------------- /Firmware/database/database.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/database/database.rar -------------------------------------------------------------------------------- /Firmware/identColor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import picamera 4 | import cv2 5 | 6 | def identColor(): 7 | camera = picamera.PiCamera() 8 | camera.resolution = (1080,1080) 9 | camera.start_preview() 10 | raw_input("Press enter to continue") 11 | camera.stop_preview() 12 | camera.capture('ident.jpg') 13 | im = cv2.imread('ident.jpg') 14 | hsv = cv2.cvtColor(im,cv2.COLOR_BGR2HSV) 15 | print(hsv[540][540]) 16 | 17 | identColor() 18 | 19 | -------------------------------------------------------------------------------- /Firmware/main.py: -------------------------------------------------------------------------------- 1 | from thresholding import * 2 | from solver import * 3 | from control_motor import * 4 | t1=time.clock() 5 | pwm.start(7) 6 | capture() 7 | t2=time.clock() 8 | im = cv2.imread('rawImage.jpg',0) 9 | 10 | rect, grille = threshHold(im) 11 | 12 | cv2.imwrite('Grille.png',grille) 13 | try: 14 | from mnist_model_convolutionnel import * 15 | except: 16 | print("unable to recognize number make sure that the image is readable\n") 17 | 18 | 19 | 20 | taille = conv_cote(rect[1][0],rect[1][1]) 21 | angle = calcul_angle(rect[2],ang) 22 | 23 | 24 | try: 25 | mat = np.array(resolver(np.int_(recogn2).tolist())) 26 | except: 27 | try: 28 | mat = np.array(resolver(np.int_(recogn1).tolist())) 29 | except: 30 | try: 31 | mat = np.array(resolver(np.int_(recogn3).tolist())) 32 | except: 33 | mat = np.array(resolver(np.int_(recogn).tolist())) 34 | 35 | coin =calc_coin(angle) 36 | print("Placer le stylo sur le coin " + str(coin)) 37 | raw_input("Press enter to continue") 38 | t3 = time.clock() 39 | print(t3-t1,t3-t2) 40 | deplacement(mat,recogn,taille,coin,angle) 41 | 42 | 43 | 44 | 45 | pwm.stop() 46 | GPIO.cleanup() 47 | t4 = time.clock() 48 | print(t4-t1) 49 | -------------------------------------------------------------------------------- /Firmware/mnist_model_convolutionnel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import cv2 4 | from tensorflow.examples.tutorials.mnist import input_data 5 | import tensorflow as tf 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | import time 9 | from datetime import timedelta 10 | import math 11 | from processing import * 12 | from database import * 13 | 14 | def CreateNewWeights(shape): 15 | """ 16 | permet de créer rapidement une matrice de poids selon le shape spécifié. La matrice(ou vecteur) de retour 17 | est de taille shape et contient des valeurs qui suivent la loi normale tronquée (truncated_normal) 18 | stddev = écart type 19 | """ 20 | return tf.Variable(tf.truncated_normal(shape,stddev=0.05)) 21 | 22 | 23 | 24 | def CreateNewBiases(length): 25 | """ 26 | permet de créer rapidement un vecteur de biais de taille length suivant la loi 27 | uniforme 28 | """ 29 | 30 | return tf.Variable(tf.constant(0.05,shape=[length])) 31 | 32 | 33 | 34 | def CreateNewConvolutionalLayer(inputs, numOfInputChannel, filterSize, numOfFilters, usePooling=True): 35 | """ 36 | This function allow to create a new convolutional layer. 37 | Parameters: 38 | ----------- 39 | inputs: the input image. it is a 4-dimension tensor(you know that image is a 3-dim matrix if you consider channels 40 | so just imagine a list of image: t's 4-dim): 41 | 1 - the image number 42 | 2 - Y-axis of each image 43 | 3 - X-axis of each image 44 | 4 - channels of each image 45 | numOfInputChannel: the number of input channels 46 | filterSize: the filter size 47 | numOfFilters: number of filter 48 | usePooling: if true, use 2x2 max-pooling 49 | 50 | Return: 51 | ------- 52 | layer : the output layer (4-dim) 53 | weights: the tensor of weights that has been used 54 | """ 55 | 56 | shape = [filterSize, filterSize,numOfInputChannel, numOfFilters] 57 | weights = CreateNewWeights(shape = shape) 58 | biases = CreateNewBiases(length = numOfFilters) 59 | 60 | layer = tf.nn.conv2d(input = inputs, 61 | filter = weights, 62 | strides = [1,1,1,1], 63 | padding ='SAME') 64 | layer += biases 65 | if(usePooling): 66 | layer = tf.nn.max_pool(value = layer, 67 | ksize = [1,2,2,1], 68 | strides = [1,2,2,1], 69 | padding = 'SAME') 70 | 71 | layer = tf.nn.relu(layer) 72 | return layer,weights 73 | 74 | 75 | 76 | def FlattenLayer(layer): 77 | """ 78 | Allow you to quick flatten a layer as the layer is a 4-dim tensor, we need to 79 | reduce the 4-dim to 2-dim which will be use as the input of the function 80 | FullyConnectLayer(...) 81 | Parameters: 82 | ----------- 83 | layer: the 4-dim tensor 84 | Return: 85 | ------- 86 | flattenedLayer: 2-dim tensor 87 | numFeatures: the number of features = img_height * img_width * num_channels 88 | """ 89 | 90 | layerShape = layer.get_shape() 91 | numFeatures = layerShape[1:4].num_elements() 92 | flattenedLayer = tf.reshape(layer,[-1,numFeatures]) 93 | return flattenedLayer,numFeatures 94 | 95 | 96 | 97 | 98 | def FullyConnectLayer(inputs,numOfinput,numOfOutput,useRelu=True): 99 | """ 100 | Return layer = inputs*weights + biases where weights is a matrix of dim [numOfinput,numOfOutput] 101 | and biases of dim numOfOutput 102 | """ 103 | weights = CreateNewWeights(shape = [numOfinput,numOfOutput]) 104 | biases = CreateNewBiases(length = numOfOutput) 105 | 106 | layer = tf.matmul(inputs,weights)+biases 107 | if(useRelu): 108 | layer = tf.nn.relu(layer) 109 | return layer 110 | 111 | 112 | 113 | # Counter for total number of iterations performed so far. 114 | total_iterations = 0 115 | 116 | 117 | 118 | def optimize(num_iterations): 119 | """ 120 | Run optimization on trainning database. 121 | Parameters: 122 | ----------- 123 | num_iterations : the number of iteration to converge the model 124 | Returns: 125 | -------- 126 | Accuracy each iteration 127 | """ 128 | # Ensure we update the global variable rather than a local copy. 129 | global total_iterations 130 | 131 | # Start-time used for printing time-usage below. 132 | start_time = time.time() 133 | 134 | for i in range(total_iterations, 135 | total_iterations + num_iterations): 136 | 137 | # Get a batch of training examples. 138 | # x_batch now holds a batch of images and 139 | # y_true_batch are the true labels for those images. 140 | x_batch, y_true_batch = data.train.next_batch(train_batch_size) 141 | 142 | # Put the batch into a dict with the proper names 143 | # for placeholder variables in the TensorFlow graph. 144 | feed_dict_train = {x: x_batch, 145 | y_true: y_true_batch} 146 | 147 | # Run the optimizer using this batch of training data. 148 | # TensorFlow assigns the variables in feed_dict_train 149 | # to the placeholder variables and then runs the optimizer. 150 | session.run(optimizer, feed_dict=feed_dict_train) 151 | 152 | # Print status every 100 iterations. 153 | if i % 100 == 0: 154 | # Calculate the accuracy on the training-set. 155 | acc = session.run(accuracy, feed_dict=feed_dict_train) 156 | 157 | # Message for printing. 158 | msg = "Optimization Iteration: {0:>6}, Training Accuracy: {1:>6.1%}" 159 | 160 | # Print it. 161 | print(msg.format(i + 1, acc)) 162 | 163 | # Update the total number of iterations performed. 164 | total_iterations += num_iterations 165 | 166 | # Ending time. 167 | end_time = time.time() 168 | 169 | # Difference between start and end-times. 170 | time_dif = end_time - start_time 171 | 172 | # Print the time-usage. 173 | print("Time usage: " + str(timedelta(seconds=int(round(time_dif))))) 174 | 175 | 176 | 177 | # Split the test-set into smaller batches of this size. 178 | test_batch_size = 22 #256 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | def print_test_accuracy(): 188 | """ 189 | Allow you to print the accuracy of the model in test database after optimisation 190 | """ 191 | # Number of images in the test-set. 192 | num_test = len(data.test.images) 193 | 194 | # Allocate an array for the predicted classes which 195 | # will be calculated in batches and filled into this array. 196 | cls_pred = np.zeros(shape=num_test, dtype=np.int) 197 | 198 | # Now calculate the predicted classes for the batches. 199 | # We will just iterate through all the batches. 200 | # There might be a more clever and Pythonic way of doing this. 201 | 202 | # The starting index for the next batch is denoted i. 203 | i = 0 204 | 205 | while i < num_test: 206 | # The ending index for the next batch is denoted j. 207 | j = min(i + test_batch_size, num_test) 208 | 209 | # Get the images from the test-set between index i and j. 210 | images = data.test.images[i:j, :] 211 | 212 | # Get the associated labels. 213 | labels = data.test.labels[i:j, :] 214 | 215 | # Create a feed-dict with these images and labels. 216 | feed_dict = {x: images, 217 | y_true: labels} 218 | 219 | # Calculate the predicted class using TensorFlow. 220 | cls_pred[i:j] = session.run(y_pred_cls, feed_dict=feed_dict) 221 | 222 | # Set the start-index for the next batch to the 223 | # end-index of the current batch. 224 | i = j 225 | 226 | # Convenience variable for the true class-numbers of the test-set. 227 | cls_true = data.test.cls 228 | 229 | # Create a boolean array whether each image is correctly classified. 230 | correct = (cls_true == cls_pred) 231 | 232 | # Calculate the number of correctly classified images. 233 | # When summing a boolean array, False means 0 and True means 1. 234 | correct_sum = correct.sum() 235 | 236 | # Classification accuracy is the number of correctly classified 237 | # images divided by the total number of images in the test-set. 238 | acc = float(correct_sum) / num_test 239 | 240 | # Print the accuracy. 241 | msg = "Accuracy on Test-Set: {0:.1%} ({1} / {2})" 242 | print(msg.format(acc, correct_sum, num_test)) 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | #definition de quelques paramètres importants 251 | learning_rate = 0.3 252 | training_iteration = 10 253 | batch_size = 100 254 | display_step = 2 255 | img_size = 28 #la taille des images dans MNIST est de 28 pixels 256 | img_size_flat = img_size*img_size #28x28 pixels, la matrice 2D l'image est transformée en un vecteur 257 | img_shape = (img_size,img_size) #qui sera réutilisé plus tard pour convertir le vecteur en image 258 | num_classes = 10 #10 classes possibles 0-9 259 | num_channels = 1 260 | filter1_size = 5 261 | filter2_size = 5 262 | num_filter1 = 16 263 | num_filter2 = 36 264 | train_batch_size = 42 #256#22 265 | 266 | 267 | #***************************************************************************# 268 | # DEFINITION DU MODEL: ICI RESEAUX DE NEURONES COVOLUTIFS # 269 | # DEFINITION OF MODEL: HERE IS CONVOLUTIVE NETWORK # 270 | #***************************************************************************# 271 | 272 | 273 | 274 | 275 | 276 | 277 | #data = input_data.read_data_sets("/home/pi/Documents/Sudoku/tensor/",one_hot=True) 278 | data.test.cls = np.array([label.argmax() for label in data.test.labels]) 279 | x = tf.placeholder("float",[None, img_size_flat],name='x') 280 | x_reshape = tf.reshape(x,shape = [-1,img_size,img_size,num_channels], name='x_reshape') 281 | 282 | y_true = tf.placeholder(dtype=tf.float32, shape=[None,10], name='y_true') 283 | y_true_cls = tf.argmax(y_true,dimension=1) 284 | 285 | 286 | #First convolutional layer 287 | 288 | layerConv1,weightsConv1 = CreateNewConvolutionalLayer(inputs = x_reshape, 289 | numOfInputChannel = num_channels, 290 | filterSize = filter1_size, 291 | numOfFilters = num_filter1, 292 | usePooling = True) 293 | #Second convolutional layer 294 | 295 | layerConv2,weightsConv2 = CreateNewConvolutionalLayer(inputs = layerConv1, 296 | numOfInputChannel = num_filter1, 297 | filterSize = filter2_size, 298 | numOfFilters = num_filter2, 299 | usePooling = True) 300 | 301 | #Flatten Layer 302 | 303 | flattenedLayer,numFeatures = FlattenLayer(layerConv2) 304 | 305 | #Fully-Connected Layer 1 306 | 307 | firstConnectedLayerSize = 128 308 | connectedLayer1 = FullyConnectLayer(inputs = flattenedLayer, 309 | numOfinput = numFeatures, 310 | numOfOutput = firstConnectedLayerSize, 311 | useRelu = True) 312 | 313 | 314 | #Fully-Connected Layer 2 315 | 316 | secondConnectedLayerSize = 10 #==> num_classes 317 | connectedLayer2 = FullyConnectLayer(inputs = connectedLayer1, 318 | numOfinput = firstConnectedLayerSize, 319 | numOfOutput = secondConnectedLayerSize, 320 | useRelu = True) 321 | 322 | 323 | #So here we have the output of our graph and we are going to determine thre predicted classe 324 | 325 | y_pred = tf.nn.softmax(connectedLayer2) 326 | y_pred_cls = tf.argmax(y_pred, dimension = 1) 327 | 328 | #Now were are going to define the cost function to be optimize 329 | 330 | cost_function = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=connectedLayer2, labels=y_true)) 331 | #or you can use the EQM = sum((y_pred-y_true)^2)/N where N is the number of input images 332 | #cost_function = tf.reduce_mean(tf.square(y_pred-y_true)) #EQM 333 | 334 | #Definition of optimization method. Here we use AdamOptimizer but you can use GradientDescendOptimizer is you use 335 | #for exemple the EQM 336 | 337 | #optimizer = tf.train.AdamOptimizer(learning_rate = 1e-4).minimize(cost_function) 338 | optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost_function) 339 | 340 | 341 | #Performance Measures 342 | 343 | predictions = tf.equal(y_pred_cls,y_true_cls) #vector of boolean that show the matched and unmatched prediction 344 | 345 | accuracy = tf.reduce_mean(tf.cast(predictions,tf.float32)) 346 | 347 | 348 | 349 | 350 | 351 | 352 | #***************************************************************************# 353 | # NOW WE ARE GOING TO START TRAINING OUR MODEL # 354 | #***************************************************************************# 355 | 356 | 357 | 358 | 359 | init = tf.global_variables_initializer() 360 | saver = tf.train.Saver() 361 | session = tf.Session() 362 | session.run(init) 363 | #optimize(4000) #if you want to train the model so uncomment this 364 | #saver.save(session,"./tensor/tensor_v1.0") and this to save it in the specifief directory 365 | 366 | #I had already train a model so I have just restore it here 367 | 368 | saver.restore(session,"./tensor/tensor_v1.0") #Allow you to restore previous trained session 369 | feed_dict = {x:(255-imBox)/255} #charge imBox which contains the cases of sudoku image with interpolation bicubic 370 | feed_dict1 = {x:(255-imBox1)/255} # inter_area 371 | feed_dict2 = {x:(255-imBox2)/255} # linear 372 | feed_dict3 = {x:(255-imBox3)/255} #lanczos4 373 | recogn = session.run(y_pred_cls,feed_dict).reshape((9,9)) 374 | re = session.run(connectedLayer2,feed_dict) 375 | rem = np.zeros(re.shape[0]) 376 | decision = 0 377 | for i in range(re.shape[0]): 378 | rem[i] = re[i][re[i].argmax()] 379 | s = sum(rem) 380 | for k in range(1,4): 381 | 382 | imBox = ExtractBoxImage(ExtractBoxes(np.rot90(imB*I,k)),np.rot90(imB,k),(28,28),cv2.INTER_CUBIC) 383 | feed_dict = {x:(255-imBox)/255} 384 | re = session.run(connectedLayer2,feed_dict) 385 | for i in range(re.shape[0]): 386 | rem[i] = re[i][re[i].argmax()] 387 | if(sum(rem)>s): 388 | s = sum(rem) 389 | decision = k 390 | if(decision >= 0): 391 | 392 | #I try different interpolations to see the result (bicubic, bilinear,lanczos4,area) see opencv doc for more info 393 | imBox = ExtractBoxImage(ExtractBoxes(np.rot90(imB*I,decision)),np.rot90(imB,decision),(28,28),cv2.INTER_CUBIC) 394 | imBox1 = ExtractBoxImage(ExtractBoxes(np.rot90(imB*I,decision)),np.rot90(imB,decision),(28,28),cv2.INTER_AREA) 395 | imBox2 = ExtractBoxImage(ExtractBoxes(np.rot90(imB*I,decision)),np.rot90(imB,decision),(28,28),cv2.INTER_LINEAR) 396 | imBox3 = ExtractBoxImage(ExtractBoxes(np.rot90(imB*I,decision)),np.rot90(imB,decision),(28,28),cv2.INTER_LANCZOS4) 397 | feed_dict = {x:(255-imBox)/255} 398 | feed_dict1 = {x:(255-imBox1)/255} 399 | feed_dict2 = {x:(255-imBox2)/255} 400 | feed_dict3 = {x:(255-imBox3)/255} 401 | recogn = session.run(y_pred_cls,feed_dict).reshape((9,9)) 402 | recogn1 = session.run(y_pred_cls,feed_dict1).reshape((9,9)) 403 | recogn2 = session.run(y_pred_cls,feed_dict2).reshape((9,9)) 404 | recogn3 = session.run(y_pred_cls,feed_dict3).reshape((9,9)) 405 | ang = 90*decision 406 | 407 | 408 | #This is for just in case you want to add imBox to database so you can improve (feed) your database 409 | 410 | ###np.int_(recogn).tolist() 411 | ##print(recogn) 412 | ##print(recogn1) 413 | ##print(recogn2) 414 | ##print(recogn3) 415 | ##res = input("Do you want to save in the database?[Y/N]\n") 416 | ##if(res == "Y"): 417 | ## res = input("What recogn do you want to save?[1,2,3,4]") 418 | ## if(res == "1"): 419 | ## for i in range(len(imBox)): 420 | ## cv2.imwrite("./database/"+str(recogn[i/9][i%9])+"aa"+str(i)+".png",imBox[i].reshape((28,28))) 421 | ## res = input("What recogn do you want to save?[1,2,3,4]") 422 | ## if(res == "2"): 423 | ## for i in range(len(imBox)): 424 | ## cv2.imwrite("./database/"+str(recogn1[i/9][i%9])+"bb"+str(i)+".png",imBox1[i].reshape((28,28))) 425 | ## res = input("What recogn do you want to save?[1,2,3,4]") 426 | ## if(res == "3"): 427 | ## for i in range(len(imBox)): 428 | ## cv2.imwrite("./database/"+str(recogn2[i/9][i%9])+"cc"+str(i)+".png",imBox2[i].reshape((28,28))) 429 | ## res = input("What recogn do you want to save?[1,2,3,4]") 430 | ## if(res == "4"): 431 | ## for i in range(len(imBox)): 432 | ## cv2.imwrite("./database/"+str(recogn3[i/9][i%9])+"dd"+str(i)+".png",imBox3[i].reshape((28,28))) 433 | ##else: 434 | ## pass 435 | 436 | 437 | -------------------------------------------------------------------------------- /Firmware/processing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | import cv2 4 | import numpy as np 5 | from matplotlib import pyplot as plt 6 | from random import * 7 | from solver import * 8 | 9 | def xyproject(img,axis): 10 | """Take an image and a axis( 0 or 1) and return the normalized projection of the image on the specified axe 11 | Paramters: 12 | ---------- 13 | img : input image 14 | axis : 0 for x projection and 1 for y projection 15 | returns 16 | ------- 17 | Array of projection 18 | """ 19 | if(img.shape[axis] == 0): 20 | return None 21 | return np.sum(img,axis)/img.shape[axis] 22 | 23 | 24 | 25 | 26 | 27 | def binarize(img,flag): 28 | """ Take an image and a flag and return the binarized image according to the flag specified 29 | Parameters: 30 | ----------- 31 | img: input image 32 | flag: if cv2.THRESH_OTSU then the binarisation is done with OTSU method 33 | if either cv2.ADAPTIVE_THRESH_MEAN_C or cv2.ADAPTIVE_THRESH_GAUSSIAN_C then an adaptive method 34 | is used. 35 | Returns: 36 | -------- 37 | retval: the value of the threshold( default value = 0) 38 | imB: binarized image (default value = None) 39 | PLEASE REFER TO THE OPENCV DOC FOR MORE INFORMATIONS 40 | """ 41 | retval = 0 42 | imB = None 43 | if(flag == cv2.THRESH_BINARY): 44 | retval,imB = cv2.threshold(img,0,255,cv2.THRESH_BINARY) 45 | if(flag == cv2.THRESH_OTSU): 46 | retval,imB = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) 47 | if(flag == cv2.ADAPTIVE_THRESH_GAUSSIAN_C): 48 | imB = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,7,2) 49 | if(flag == cv2.ADAPTIVE_THRESH_MEAN_C): 50 | imB = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,7,2) 51 | return retval,imB 52 | 53 | 54 | 55 | 56 | 57 | def HoughSort(lines,eps_rho,eps_theta): 58 | """ Take the vector return by HoughLine() and sort it. 59 | To best understand use it to see its effect 60 | """ 61 | lines = lines[0][lines[0][:][:,0].argsort()] 62 | for i in range(lines.shape[0]): 63 | j=i-1 64 | while(j>=0): 65 | if(abs(lines[j][0]-lines[j+1][0])eps_theta): 66 | #then, in this case sort by following theta 67 | if(lines[j][1]>lines[j+1][1]): 68 | lines[j][0],lines[j+1][0] = lines[j+1][0],lines[j][0] 69 | lines[j][1],lines[j+1][1] = lines[j+1][1],lines[j][1] 70 | j -= 1 71 | return lines 72 | 73 | 74 | 75 | 76 | def StatSort(stats): 77 | """ 78 | Once you get the coordinate of each case, you have to order it because to do not lose the position 79 | of each case on the sudoku image 80 | """ 81 | stats = stats[stats[:,1].argsort()] #on trie par rapport a la 2e colonne 82 | for j in range(9):#puis par rapport a la 1ere par bloc de 9(pour comprendre essayer d'afficher stats sans tri) 83 | t = stats[9*j:j*9+9,:] 84 | t = t[t[:,0].argsort()] 85 | stats[9*j:j*9+9,:] = t 86 | return stats 87 | 88 | 89 | 90 | 91 | def ExtractBoxes(imBinarized,connexity=None,thresh=None): 92 | """ Take a binarized image thresholded and search the eventual boxes inside using thresh 93 | Parameters: 94 | ----------- 95 | imBinarized: input image 96 | connexity : 4 or 8 (refer to cv2.connectedComponentsWithStats(...) doc) 97 | thresh : array of 1x2= (thresh_min_x,thresh_min_y,thresh_max_x,thresh_max_y) which means that the 98 | researched boxes should be at least thresh_min_x large and thresh_min_y height and at most 99 | thresh_max large and thresh_max_y height 100 | 101 | 102 | the parmeters connexity and thresh will be used if specified otherwise findContours(...) method will be used! 103 | Returns: 104 | -------- 105 | stat: an array of Nx5 where N means the number of boxes found and 5, 5 rows according to 106 | cv2.connectedComponentsWithStats(...) or findContours(...) doc. 107 | 108 | PLEASE REFER TO THE OPENCV DOC FOR MORE INFORMATIONS 109 | """ 110 | try: 111 | output = cv2.connectedComponentsWithStats(imBinarized,connexity) 112 | stat = output[2] #contains the boxes found 113 | #now we are going to delete the boxes which do not respect the thresh 114 | k = 0 115 | l = 0 116 | while( k < stat.shape[0]): 117 | if( stat[k][2] < thresh[0] or stat[k][3] < thresh[1] or stat[k][2] > thresh[2] or stat[k][3] > thresh[3]): 118 | #then delete it 119 | stat = np.delete(stat,k,axis=0) 120 | else: 121 | #ignore 122 | k += 1 123 | return StatSort(stat) 124 | except: 125 | """ If opencv function connectedComponentsWithStats() not found or if only one argument 126 | is given, then findContours() method will be used! 127 | for example, opencv2 don't embed the previous method cv2.connectedComponentsWithStats(...) 128 | """ 129 | (cnts,_) = cv2.findContours(imBinarized.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 130 | cnts = sorted(cnts, key = cv2.contourArea, reverse = True)[:81] #permet de trier par ordre décroissant de l'aire des cases détectées 131 | #l = cv2.drawContours(im, [cnts[1]], -1, (255, 0, 0), 3) 132 | stats = np.zeros((81,5),int) 133 | T = [] 134 | for i in range(len(cnts)): 135 | cnts[i] = cv2.approxPolyDP(cnts[i],eps_rho,True) 136 | cnts[i] = cnts[i][cnts[i][:,0][:,0][:].argsort()] #pour trier selon la colonne des y (afficher stat pour comprendre) 137 | if(len(cnts[i]) != 4): 138 | continue 139 | x,y,h,w = cv2.boundingRect(cnts[i]) 140 | T.append(x+1)#l'abscisse de la case 141 | T.append(y+1)#son ordonnee 142 | T.append(min(h,w)-2)#sa hauteur les -2 c'est uniquement pour eviter de prendre les pixels noirs du contour 143 | T.append(min(h,w)-2)#sa largeur 144 | T.append(T[2]*T[3])#l'aire totale du contour 145 | stats[i] = T 146 | T = [] #T.clear() 147 | return StatSort(stats) 148 | 149 | 150 | 151 | 152 | 153 | def ExtractBoxImage(boxes,img,imgFlat,method): 154 | """ Take the input image and extract image from boxes returned by function ExtractBoxes(...) 155 | Parameters: 156 | ----------- 157 | img: input image 158 | boxes: ExtractBoxes(...) 159 | imgFlat: tuple of size =2 . For each image will be flattened into a 1D array of imgFlat[0]*imgFlat[1] 160 | Returns: 161 | -------- 162 | imBox: an array of Nx28x28 where N means the number of boxes found and 28x28 the size of the box image 163 | resized 164 | PLEASE REFER TO THE ExtractBoxes(...) FUNCTION FOR MORE INFORMATIONS 165 | """ 166 | imBox = np.zeros((boxes.shape[0],imgFlat[0]*imgFlat[1]),dtype = img.dtype) 167 | for i in range(imBox.shape[0]): 168 | if(stat[i][3] (3.0/4)*imgFlat[0] or w > (3.0/4)*imgFlat[1]):#souvent les chiffres sont de grandes tailles ce qui fausse la detection 179 | 180 | ret,tmp = binarize(cv2.resize(imR[y:y+w,x:x+h],None,fx=0.6,fy=0.6,interpolation=method),cv2.THRESH_BINARY) 181 | #l'idee est donc de redimensioner la taille du chiffre: on extrait le chiffre, on le resize et on le reinjecte dans une image noire (imRR) 182 | w,h = tmp.shape 183 | imRR[imgFlat[1]/2 - w/2:imgFlat[1]/2 - w/2 + w,imgFlat[0]/2 - h/2:imgFlat[0]/2 - h/2 + h] = tmp #NB -w/2 + w != w/2 ==> arrondi (calcul scientifique) 184 | imR = imRR 185 | #print 'dbg' 186 | 187 | elif(abs(x+h/2 - imgFlat[0]/2) > pix or abs(y+w/2 - imgFlat[1]/2) > pix):#souvent les chiffres sont pas centres dans la case 188 | #l'idee est d'extraire le chiffre de calculer le shift et le recentrer :) ah Mohamed tu cherches loin 189 | tmp = imR[y:y+w,x:x+h] 190 | w,h = tmp.shape 191 | imRR[imgFlat[1]/2 - w/2:imgFlat[1]/2 - w/2 + w,imgFlat[0]/2 - h/2:imgFlat[0]/2 - h/2 + h] = tmp #NB -w/2 + w != w/2 ==> arrondi (calcul scientifique) 192 | imR = imRR 193 | #print 'dbg' 194 | imBox[i] = np.reshape(imR,imgFlat[0]*imgFlat[1]) 195 | return imBox 196 | 197 | 198 | def HoughGrid(lines,eps_rho,eps_theta): 199 | """ 200 | take return by HoughLine() and sort it in order to let only the lines of the grid 201 | Remind that Hough method return all 3-points alignment on image so some of lines won't be a part of the desired 202 | line 203 | """ 204 | lines = HoughSort(lines,eps_rho,eps_theta) 205 | grid = np.zeros((20,2)) #sudoku's grid have 20 lines. 2 =>(rho,theta) 206 | j = 0 207 | eps = 1e-2 208 | for i in range(lines.shape[0]): 209 | if(lines[i][0] <= 0 or lines[i][1] < 0): 210 | continue 211 | elif(abs(lines[i][0] - grid[j-1][0]) > eps_rho or (abs(lines[i][1] - grid[j-1][1]) > eps_theta and lines[i][1] > eps)): 212 | if abs(lines[i][1] < eps): lines[i][1] = 0 213 | elif (abs(lines[i][1]-np.pi/2) < eps): lines[i][1] = np.pi/2 214 | elif (abs(lines[i][1]-np.pi) < eps): lines[i][1] = np.pi 215 | else: continue 216 | grid[j] = lines[i] 217 | j +=1 218 | #if j == 20: break 219 | elif(abs(lines[i][0] - grid[j-1][0]) < eps_rho and abs(lines[i][1] - grid[j-1][1]) < eps_theta ): 220 | if abs(lines[i][1] < eps): lines[i][1] = 0 221 | elif (abs(lines[i][1]-np.pi/2) < eps): lines[i][1] = np.pi/2 222 | elif (abs(lines[i][1]-np.pi) < eps): lines[i][1] = np.pi 223 | else: continue 224 | grid[j-1] = (grid[j-1] + lines[i])/2 225 | else: 226 | continue 227 | 228 | return grid,lines 229 | 230 | def EstimatedGrid(grid): 231 | """ 232 | return the estimated grid (and save it as hough.png) 233 | """ 234 | imC = (im>=0)*255 235 | for i in range(grid.shape[0]): 236 | rho = grid[i][0] 237 | theta = grid[i][1] 238 | a = np.cos(theta) 239 | b = np.sin(theta) 240 | x0 = a*rho 241 | y0 = b*rho 242 | x1 = int(x0 + 1000*(-b)) 243 | y1 = int(y0 + 1000*(a)) 244 | x2 = int(x0 - 1000*(-b)) 245 | y2 = int(y0 - 1000*(a)) 246 | cv2.line(imC,(x1,y1),(x2,y2),(0,0,0),2) 247 | #cv2.imwrite('hough.png',imC) 248 | I = cv2.cvtColor(np.array(imC,'uint8'),cv2.COLOR_BGR2GRAY)/255 249 | return I 250 | 251 | 252 | 253 | 254 | im = cv2.imread('./Grille.png')#,cv2.IMREAD_GRAYSCALE) 255 | 256 | #Grille.png is the image return by "pretraitement(thresholding)" 257 | img = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) 258 | lx,ly = img.shape #image width and heigth 259 | ret,imB = binarize(img,cv2.THRESH_OTSU) 260 | 261 | 262 | edges = cv2.Canny(img,50,150,apertureSize = 3) 263 | lines = cv2.HoughLines(edges,1,np.pi/180,110) 264 | eps_rho = int(min(lx/9,ly/9)/2) 265 | eps_theta = np.pi/8 266 | grid,lines = HoughGrid(lines,eps_rho,eps_theta) 267 | I = EstimatedGrid(grid) 268 | 269 | #I*imB juste pour rehausser les lignes qui peuvent ne pas être en noir et corriger les artefacts (voir rapport) 270 | stat = ExtractBoxes(imB*I)#,connexity = 8,thresh=(lx/18,ly/18,lx/3,ly/3)) if you use connectedComponent 271 | 272 | imBox = ExtractBoxImage(stat,imB,(28,28),cv2.INTER_CUBIC) 273 | imBox1 = ExtractBoxImage(stat,imB,(28,28),cv2.INTER_AREA) 274 | imBox2 = ExtractBoxImage(stat,imB,(28,28),cv2.INTER_LINEAR) 275 | imBox3 = ExtractBoxImage(stat,imB,(28,28),cv2.INTER_LANCZOS4) 276 | 277 | ##Remind that INTER_CUBIC,INTER_AREA,INTER_LINEAR, INTER_LANCZOS4 that is the 278 | ##type of interpolation used to resize image to 28x28 pixels 279 | 280 | 281 | 282 | -------------------------------------------------------------------------------- /Firmware/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/readme.txt -------------------------------------------------------------------------------- /Firmware/solver.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from copy import deepcopy 4 | # update of one column 5 | 6 | def search_column(mat, num_column): 7 | """ Fill a vector with the numbers already found of the column num_column 8 | Parameters: 9 | ----------- 10 | mat: the matrix unsolved 11 | num_column: the number of the treated column 12 | Return: 13 | ------- 14 | vect: the vector with the numbers already found 15 | """ 16 | vect = [] 17 | for i in range( len(mat) ): 18 | if (len( mat[i][num_column] ) == 1): 19 | vect = vect + [mat[i][num_column]] 20 | return vect 21 | 22 | def update_column(mat, num_column, vect,c): 23 | """ Verefy in the vector of possibilities if there are the numbers on the vector which returned by search_column 24 | and if it's the case remove the numbers 25 | Parameters: 26 | ----------- 27 | mat: the matrix unsolved 28 | num_column: the number of the treated column 29 | vect: the vector with the numbers already found 30 | c: indicator to know if all the vector of possibilities are reduced to maximum 31 | Return: 32 | ------- 33 | c: if c=1 the function modified mat and it has to continu, if not the function is not anymore used 34 | """ 35 | for k in range( len( vect) ): 36 | for i in range( len( mat ) ): 37 | if (len( mat[i][num_column] ) != 1): 38 | for j in range( len( mat[i][num_column] ) ): 39 | if (mat[i][num_column][j] == vect[k][0]): 40 | del( mat[i][num_column][j] ) 41 | c = 1 42 | break # quit the loop to avoid error seqfull 43 | return c 44 | 45 | # update of one line 46 | 47 | def search_line(mat, num_line): 48 | """ same than search_column but with a line""" 49 | vect = [] 50 | for i in range( len( mat[0] ) ): 51 | if (len( mat[num_line][i] ) == 1): 52 | vect = vect + [mat[num_line][i]] 53 | return vect 54 | 55 | def update_line(mat, num_line, vect,c): 56 | """ same than update_column but with a line""" 57 | for k in range( len( vect) ): 58 | for i in range( len( mat[0] ) ): 59 | if (len( mat[num_line][i] ) != 1): 60 | for j in range( len( mat[num_line][i] ) ): 61 | if (mat[num_line][i][j] == vect[k][0]): 62 | del( mat[num_line][i][j] ) 63 | 64 | c = 1 65 | break 66 | return c 67 | 68 | 69 | # update of one bloc 70 | 71 | def identify_bloc(num): 72 | """ Delimitate the blocs 73 | Parameter: 74 | ---------- 75 | num: the identifier of a bloc 76 | Return: 77 | ------- 78 | a vector with the coordonate of bloc 79 | """ 80 | if (num == 1): 81 | return [ [0,1,2], [0,1,2] ] # bloc at the top on the left 82 | elif (num == 2): 83 | return [ [0,1,2], [3,4,5] ] # bloc at the top in the midle 84 | elif (num == 3): 85 | return [ [0,1,2], [6,7,8] ] # bloc at the top on the right 86 | elif (num == 4): 87 | return [ [3,4,5], [0,1,2] ] 88 | elif (num == 5): 89 | return [ [3,4,5], [3,4,5] ] 90 | elif (num == 6): 91 | return [ [3,4,5], [6,7,8] ] 92 | elif (num == 7): 93 | return [ [6,7,8], [0,1,2] ] 94 | elif (num == 8): 95 | return [ [6,7,8], [3,4,5] ] 96 | else: 97 | return [ [6,7,8], [6,7,8] ] # bloc at the bottom on the right 98 | 99 | def search_bloc(mat, bloc): 100 | """ same than serach_column with a bloc 101 | Parameter: bloc (coordonate od bloc) replace num_column 102 | """ 103 | vect = [] 104 | for i in bloc[0]: 105 | for j in bloc[1]: 106 | if (len( mat[i][j] ) == 1): 107 | vect = vect + [mat[i][j]] 108 | return vect 109 | 110 | def update_bloc(mat, bloc, vect,c): 111 | """ same than update_column with a bloc 112 | Parameter: bloc (coordonate od bloc) replace num_column 113 | """ 114 | for k in range( len( vect) ): 115 | for i in bloc[0]: 116 | for j in bloc[1]: 117 | if (len( mat[i][j] ) != 1): 118 | for l in range( len( mat[i][j] ) ): 119 | if (mat[i][j][l] == vect[k][0]): 120 | del( mat[i][j][l] ) 121 | c = 1 122 | break 123 | return c 124 | 125 | # resume 126 | 127 | def resume_line(mat, c): 128 | """ Update the matrix for all the lines 129 | Parameters: 130 | ----------- 131 | mat: the matrix unsolved 132 | c: indicator to know if all the vector of possibilities are reduced to maximum 133 | Return: 134 | ------- 135 | if c=1 the function modified mat and it has to continu, if not the function is not anymore used 136 | until the second upadte (cf update_column2); but it's true if only the three functions return c=0 137 | """ 138 | for i in range(len(mat)): 139 | vect = [] 140 | vect = search_line(mat, i) 141 | c = update_line(mat, i, vect, c) 142 | return c 143 | 144 | def resume_column(mat, c): 145 | """ same than resume_line with a column""" 146 | for i in range(len(mat[0])): 147 | vect = [] 148 | vect = search_column(mat, i) 149 | c = update_column(mat, i, vect, c) 150 | return c 151 | 152 | def resume_bloc(mat, c): 153 | """ same than resume_line with a bloc""" 154 | for i in range(1,10): 155 | bloc = [] 156 | bloc = identify_bloc(i) 157 | vect = [] 158 | vect = search_bloc(mat, bloc) 159 | c = update_bloc(mat, bloc, vect, c) 160 | return c 161 | 162 | # second way to update 163 | 164 | def update_line2(mat, num_line): 165 | """ we search if there is un vector which has a unique number in a line. If it's the case, 166 | we replace the vector by this unique number 167 | Parameters: 168 | ----------- 169 | mat: the matrix unsolved 170 | num_column: the number of the treated column 171 | Return: 172 | ------- 173 | nothing 174 | """ 175 | for i in range(1,10): 176 | k = -1 # variable used like a memory 177 | for j in range( len( mat[0] ) ): 178 | if ( len( mat[num_line][j] ) != 1 ): # it's the vector is egal to [number] so the vextor is already optimal 179 | for n in range(len( mat[num_line][j] )): 180 | if ( mat[num_line][j][n] == i): 181 | if ( k == -1): 182 | k = j # if k is egal to -1, so it's the first time that we found the number i, 183 | # then we memorize the number of the line which has i 184 | else: # if k is different to -1, then there are two vector which have the number i => we quit this iteration 185 | k = -2 186 | break 187 | elif (mat[num_line][j] == [i]): # if mat[num_line][j] = [i], then we quit the iteration 188 | k = -2 189 | break 190 | if ( k != -1 and k != -2 ): 191 | mat[num_line][k] = [i] 192 | 193 | 194 | 195 | 196 | def update_column2(mat, num_column): 197 | """ same than update_lines with a column""" 198 | for i in range(1,10): 199 | k = -1 200 | for j in range( len( mat ) ): 201 | if ( len( mat[j][num_column] ) != 1 ): 202 | for n in range(len( mat[j][num_column] )): 203 | if ( mat[j][num_column][n] == i): 204 | if ( k == -1): 205 | k = j 206 | else: 207 | k = -2 208 | break 209 | elif (mat[j][num_column] == [i]): 210 | k = -2 211 | break 212 | if ( k != -1 and k != -2 ): 213 | mat[k][num_column] = [i] 214 | 215 | def update_bloc2(mat, bloc): 216 | """ same than update_lines with a bloc""" 217 | for k in range(1,10): 218 | l = -1 219 | m = 0 #second memory needed bcause it has to coordinate 220 | for i in bloc[0]: 221 | for j in bloc[1]: 222 | if ( len( mat[i][j] ) != 1 ): 223 | for n in range(len( mat[i][j] )): 224 | if ( mat[i][j][n] == k): 225 | if ( l == -1): 226 | l = i 227 | m = j 228 | else: 229 | l = -2 230 | break 231 | elif (mat[i][j] == [k]): 232 | l = -2 233 | break 234 | if ( l != -1 and l != -2 ): 235 | mat[l][m] = [k] 236 | # security 237 | 238 | def security_line( mat, num_line): 239 | """ Verify if there is a number twice and if there is a number which is not correct in one line 240 | Parameters: 241 | ----------- 242 | mat: the matrix unsolved 243 | num_line: the number of the treated line 244 | Return: 245 | ------- 246 | boolean 247 | """ 248 | vect = [0] 249 | for i in range( len( mat[0] ) ): 250 | if (len(mat[num_line][i]) == 1): 251 | num = mat[num_line][i][0] 252 | if (num<0 or num>9): 253 | print("bad number at", num_line, i) 254 | return False 255 | elif ( num!=0): 256 | for j in range(len(vect)): 257 | if (num == vect[j]): 258 | #print("there is a number twice in the line ",num_line) 259 | return False 260 | vect = vect + [num] 261 | return True 262 | 263 | 264 | def security_column( mat, num_column): 265 | """ same than update_lines with a column""" 266 | vect = [0] 267 | for i in range(len( mat ) ): 268 | if (len(mat[i][num_column]) == 1): 269 | num = mat[i][num_column][0] 270 | if ( num!=0): 271 | for j in range(len(vect)): 272 | if (num == vect[j]): 273 | #print("there is a number twice in the column",num_column) 274 | return False 275 | vect = vect + [num] 276 | return True 277 | 278 | def security_bloc( mat, n): 279 | """ same than update_lines with a bloc""" 280 | vect = [0] 281 | bloc = identify_bloc(n) 282 | for i in bloc[0]: 283 | for j in bloc[1]: 284 | if (len(mat[i][j]) == 1): 285 | num = mat[i][j][0] 286 | if ( num!=0 ): 287 | for j in range(len(vect)): 288 | if (num == vect[j]): 289 | #print("there is a number twice in the bloc", n) 290 | return False 291 | vect = vect + [num] 292 | return True 293 | 294 | def security(mat): 295 | """ verify if there are faults in the matrix 296 | Parameter: 297 | ---------- 298 | mat: the matrix unsolved 299 | Return: 300 | ------- 301 | nothing 302 | """ 303 | for i in range(9): 304 | if (not security_line(mat,i)): 305 | return False 306 | if (not security_column(mat,i)): 307 | return False 308 | if (not security_bloc(mat,i+1)): 309 | return False 310 | return True 311 | 312 | # resolver 313 | 314 | def init( mat): 315 | """ transforme the matrix to be used in the algo: change the numbers different to 0 in vector 316 | of this number and replaced 0 by the vector [1,2,3,4,5,6,7,8,9] 317 | Parameter: 318 | ---------- 319 | mat: matrix with numbers as parameters 320 | Return: 321 | ------- 322 | mat: matrix used in the algo with vectors as parameters 323 | """ 324 | for i in range(len(mat)): 325 | for j in range(len(mat[0])): 326 | if (mat[i][j] == 0): 327 | mat[i][j] = [1,2,3,4,5,6,7,8,9] # replace the zero by a vector with all the posibilities 328 | else: 329 | mat[i][j] =[ mat[i][j] ] # transform a whole number in a vector 330 | return mat 331 | 332 | def test_end(mat): 333 | """ verify if the sudoku is solved 334 | Parameter: 335 | ---------- 336 | mat: sudoku which is bieng solved 337 | Returns: 338 | -------- 339 | 1 if it solved 340 | 0 if not 341 | """ 342 | for i in range( len(mat) ): 343 | for j in range( len( mat[0]) ): 344 | if (len(mat[i][j]) != 1): 345 | return 1 346 | return 0 347 | 348 | def transform(mat): 349 | """ replace the vector of one number by this number 350 | Parameter: 351 | ---------- 352 | mat: completed matrix with vectors as parameters 353 | Return: 354 | ------- 355 | mat: same matrix with numbers as parameters 356 | """ 357 | for i in range( len(mat) ): 358 | for j in range( len( mat[0]) ): 359 | mat[i][j] = mat[i][j][0] 360 | return mat 361 | 362 | def choice(mat,mem_choice): 363 | if ( [mem_choice[2]] == len( mat[mem_choice[0]][mem_choice[1]]) ): 364 | print("it is not solvable") 365 | exit() 366 | k = 2 367 | while (mem_choice[0] == 0 or mem_choice[1] == 0): 368 | for i in range( len(mat) ): 369 | if (mem_choice[0] == 0 or mem_choice[1] == 0): 370 | for j in range( len( mat[0]) ): 371 | if( len(mat[i][j]) == k): 372 | mem_choice[0] = i 373 | mem_choice[1] = j 374 | k=k+1 375 | mem_choice[2]=mem_choice[2]+1 376 | mat[mem_choice[0]][mem_choice[1]] = [ mat[mem_choice[0]][mem_choice[1]][mem_choice[2]] ] 377 | return mat 378 | 379 | def resolver(mat): 380 | """ Take the uncompleted sudoku and return it completed 381 | Parameter: 382 | ---------- 383 | mat: a matrix 9 by 9 with zeros instead the white cases 384 | Return: 385 | ------- 386 | mat: the same matrix with the zeros which are replaced by the correct numbers 387 | """ 388 | init( mat) 389 | if (not security(mat)): 390 | exit() 391 | secur = 0 392 | mem_choice_init =[0,0,-1] 393 | mat_mem = [deepcopy(mat)] 394 | mem_choice = [mem_choice_init] 395 | mem_identity = 0 396 | while((test_end(mat) or not security(mat) )and secur != 1000 ): 397 | mat2 = deepcopy(mat) 398 | secur = secur +1 399 | c = 1 400 | ## print(mat) 401 | ## print("\n\nline") 402 | while( c==1): 403 | c = 0 404 | c = resume_line(mat, c) 405 | ## print(mat) 406 | ## print("\n\ncol") 407 | c = resume_column(mat, c) 408 | ## print(mat) 409 | ## print("bloc") 410 | c = resume_bloc(mat, c) 411 | ## print(mat) 412 | ## print("\n\nline") 413 | ## print(secur) 414 | for i in range(len(mat)): 415 | update_line2(mat, i) 416 | 417 | ## print("\n\nline2") 418 | ## print(mat) 419 | while( c==1): 420 | c = 0 421 | c = resume_line(mat, c) 422 | c = resume_column(mat, c) 423 | c = resume_bloc(mat, c) 424 | c = 1 425 | ## print("\n\n*********************\n\n") 426 | ## print(mat) 427 | for i in range(len(mat[0])): 428 | k = 0 429 | update_column2(mat, i) 430 | 431 | ## print("col2") 432 | ## print(mat) 433 | while( c==1): 434 | c = 0 435 | c = resume_line(mat, c) 436 | c = resume_column(mat, c) 437 | c = resume_bloc(mat, c) 438 | c = 1 439 | ## print("\n\n*********************\n\n") 440 | ## print(mat) 441 | for i in range(1,10): 442 | bloc = [] 443 | bloc = identify_bloc(i) 444 | update_bloc2(mat, bloc) 445 | 446 | ## print("bloc2") 447 | ## print( mat) 448 | ## print("\n\n***********************************************\n\n") 449 | #if (np.array_equal( np.array(transform(deepcopy(mat))), np.array(transform(deepcopy(mat2))) ) and mem_choice[2] == -1): 450 | if (np.array_equal( np.array(transform(deepcopy(mat))), np.array(transform(deepcopy(mat2))) ) and security(mat) and test_end(mat)==1): 451 | mat_mem = mat_mem +[deepcopy(mat)] 452 | mem_choice = mem_choice + [deepcopy(mem_choice_init)] 453 | mem_identity = mem_identity + 1 454 | ## print("\n ***********11111111111************* \n", mem_choice) 455 | ## print(mat) 456 | mat = choice(mat,mem_choice[mem_identity]) 457 | ## print(mem_choice) 458 | ## print(mat[mem_choice[mem_identity][0]][mem_choice[mem_identity][1]]) 459 | ## print("\n ***********22222222222222************* \n") 460 | ## print(mat) 461 | #if (secur == 100 and (mem_choice[0] != 0 or mem_choice[1] != 0) and !security(mat)): 462 | if (np.array_equal( np.array(transform(deepcopy(mat))), np.array(transform(deepcopy(mat2))) ) and (not security(mat))): 463 | ## print("\n ***********333333333333************* \n") 464 | ## print(mat) 465 | ## print(mem_choice) 466 | mat = deepcopy(mat_mem[mem_identity]) 467 | while( mem_choice[mem_identity][2] == len(mat[mem_choice[mem_identity][0]][mem_choice[mem_identity][1]]) - 1 ): 468 | mat_mem.remove(mat_mem[mem_identity]) 469 | mem_choice.remove(mem_choice[mem_identity]) 470 | mem_identity = mem_identity - 1 471 | mat = deepcopy(mat_mem[mem_identity]) 472 | ## print("\n ***********444444444444************* \n") 473 | ## print(mat) 474 | ## print(mem_choice) 475 | mat = choice(mat,mem_choice[mem_identity]) 476 | 477 | ## print("\n*********************55555555555555**************************\n") 478 | if (secur == 1000 or not security(mat)): 479 | print("it is not solvable!!!!!!!!!!!!!!!!!!!!!!!!! trop de boucle") 480 | exit() 481 | mat = transform(mat) 482 | return mat 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | -------------------------------------------------------------------------------- /Firmware/tensor/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "/home/pi/Documents/Sudoku/tensor/tensor_v1.1" 2 | all_model_checkpoint_paths: "/home/pi/Documents/Sudoku/tensor/tensor_v1.1" 3 | -------------------------------------------------------------------------------- /Firmware/tensor/tensor_v1.0.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/tensor/tensor_v1.0.data-00000-of-00001 -------------------------------------------------------------------------------- /Firmware/tensor/tensor_v1.0.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/tensor/tensor_v1.0.index -------------------------------------------------------------------------------- /Firmware/tensor/tensor_v1.0.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Firmware/tensor/tensor_v1.0.meta -------------------------------------------------------------------------------- /Firmware/thresholding.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | from Capture import * 4 | import numpy as np 5 | import math 6 | import cv2 7 | import os 8 | 9 | def adaptativeThresholding(image): 10 | """Applique un filtre médian et effectue un seuillage binaire adaptatif sur l'image 11 | __________ 12 | Parameters : 13 | image : image en niveau de gris 14 | __________ 15 | Return : 16 | tresh : image binarisée 17 | """ 18 | img = cv2.medianBlur(image,5) 19 | thresh = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,21,2) 20 | return thresh 21 | 22 | def normalThresholding(image): 23 | """Applique un filtre gaussien et effectue un seuillage binaire suivant la méthode de Otsu sur l'image 24 | __________ 25 | Parameters : 26 | image : image en niveau de gris 27 | __________ 28 | Return : 29 | thresh : image binarisée 30 | """ 31 | ret,thresh = cv2.threshold(image,120,255,cv2.THRESH_TRUNC) 32 | th3,threshNormal = cv2.threshold(thresh,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU) 33 | return threshNormal 34 | 35 | def negative(image): 36 | """Retourne le negatif de l'image prise en paramètre 37 | """ 38 | return 255 - image 39 | 40 | def order_points(pts): 41 | """Réarrange les coins d'un quadrilatère dont les coordonnées sont contenues dans une matrice (4,2) de cette façon : [[bas-gauche],[haut-gauche],[haut-droit],[bas-droit]] 42 | __________ 43 | Parameters : 44 | pts: matrice (4,2) contenant les coordonnées des coins 45 | __________ 46 | Return : 47 | rect : matrice (4,2) contenant les coordonnées des coins ordonnées 48 | """ 49 | rect = np.zeros((4, 2)) 50 | 51 | s = pts.sum(axis = 1) 52 | rect[1] = pts[np.argmin(s)] # le coin supérieur gauche a la plus faible somme sur ses cooordonnées 53 | rect[3] = pts[np.argmax(s)] # le coin inférieur droit a la plus grande somme sur ses cooordonnées 54 | 55 | diff = np.diff(pts, axis = 1) 56 | rect[2] = pts[np.argmin(diff)] # le coin supérieur droit a la plus petite différence sur ses cooordonnées 57 | rect[0] = pts[np.argmax(diff)] # le coin inférieur gauche a la plus grande différence sur ses cooordonnées 58 | 59 | return rect 60 | 61 | 62 | def grille_detection(img): 63 | """Detecte la grille de sudoku sur une image où la grille est blanche sur un fond noir 64 | __________ 65 | Parameters : 66 | img : image binaire 67 | __________ 68 | Return : 69 | rect : tuple ((x, y), (l, h), alpha) où (x, y) sont les coordonnées du centre du rectangle d'approximation de la grille, (l, h) la largeur et la hauteur du rectangle et alpha son angle 70 | grille : une matrice contenant les coordonnées des coins de la grille de sudoku [[bas-gauche],[haut-gauche],[haut-droit],[bas-droit]] 71 | """ 72 | # Recherche des contours 73 | (contours,_) = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) 74 | # Sélection du plus grand contour en terme d'aire 75 | max_area = 0 76 | for cnt in contours: 77 | area = cv2.contourArea(cnt) 78 | if area > max_area: 79 | max_area = area 80 | best_cnt = cnt 81 | # Approximation du contour par un polynôme selon l'algorithme de Douglas–Peucker 82 | epsilon = 0.1 * cv2.arcLength(best_cnt, True) 83 | approx = cv2.approxPolyDP(best_cnt, epsilon, True) 84 | app=[] 85 | for i in range(0,len(approx)): 86 | app.append(approx[i][0]) 87 | grid = np.array(app) 88 | grille = order_points(grid) 89 | # Recherche du rectangle orienté qui s'adapte le mieux au contour en terme d'aire 90 | rect = cv2.minAreaRect(best_cnt) 91 | return rect, grille 92 | 93 | def processNormal(img): 94 | """Applique le traitement normal (image de bonne qualité) sur l'image et effectue le redressement de perspective 95 | __________ 96 | Parameters : 97 | img : image en niveau de gris 98 | __________ 99 | Return : 100 | rect : tuple ((x, y), (l, h), alpha) où (x, y) sont les coordonnées du centre du rectangle d'approximation de la grille, (l, h) la largeur et la hauteur du rectangle et alpha son angle 101 | dst : la grille de sudoku 102 | """ 103 | # On applique le seuillage normal 104 | threshNormal = normalThresholding(img) 105 | thresh_neg = negative(threshNormal) 106 | # On détecte la grille 107 | rect, grid = grille_detection(thresh_neg) 108 | rect = list(rect) 109 | ##box = grid_model(rect) 110 | # pts1 contient les coordonnées des coins du polynôme d'approximation de la grille au nombre de 4 111 | pts1 = np.float32(grid) 112 | pts2 = np.float32([[0,512],[0,0],[512,0],[512,512]]) 113 | # Redressage de la grille 114 | M = cv2.getPerspectiveTransform(pts1,pts2) 115 | dst = cv2.warpPerspective(threshNormal,M,(512,512)) 116 | return rect, dst 117 | 118 | def processAdaptative(img): 119 | """Applique le traitement adaptatif (image de mauvaise qualité) sur l'image et effectue le redressement de perspective 120 | __________ 121 | Parameters : 122 | img : image en niveau de gris 123 | __________ 124 | Return : 125 | rect : tuple ((x, y), (l, h), alpha) où (x, y) sont les coordonnées du centre du rectangle d'approximation de la grille, (l, h) la largeur et la hauteur du rectangle et alpha son angle 126 | median : la grille de sudoku 127 | """ 128 | # On applique un premier seuillage qui passe en blanc tout les pixels de niveau de gris supérieur à 120, les autres sont conservés 129 | ret,threshAdapt = cv2.threshold(img,120,255,cv2.THRESH_TRUNC) 130 | # On applique le seuillage adaptatif 131 | threshAdapt = adaptativeThresholding(threshAdapt) 132 | # On applique un filtre médian afin de supprimer les petits artefacts du seuillage adaptatif 133 | threshMedian = cv2.medianBlur(threshAdapt,7) 134 | thresh_neg = negative(threshMedian) 135 | thresh_neg = negative(threshMedian) 136 | # On détecte la grille 137 | rect, grid = grille_detection(thresh_neg) 138 | rect = list(rect) 139 | ##box = grid_model(rect) #box contient les coordonnées des 4 coins du rectancle d'approximation de la grille qui minimise l'aire 140 | # pts1 contient les coordonnées des coins du polynôme d'approximation de la grille au nombre de 4 141 | pts1 = np.float32(grid) 142 | pts2 = np.float32([[0,512],[0,0],[512,0],[512,512]]) 143 | # Redressage de la grille 144 | M = cv2.getPerspectiveTransform(pts1,pts2) 145 | dst = cv2.warpPerspective(threshAdapt,M,(512,512)) 146 | # On applique un filtre médian afin de supprimer les petits artefacts du seuillage adaptatif 147 | median = cv2.medianBlur(dst,3) 148 | th,median = cv2.threshold(median,254,255,cv2.THRESH_BINARY) 149 | return rect, median 150 | 151 | def grid_model(rect): 152 | """ 153 | Cette fcn permet, à partir du tuple de la fonction grille_detection(), de retourner les coordonnées des 4 coins du rectangle 154 | """ 155 | box = cv2.boxPoints(rect) 156 | box = np.int0(box) 157 | return box 158 | 159 | def draw_model(image,box): 160 | """ 161 | Cette fonction permet de tracer le rectangle qui approxime la grille sur l'image à partir des coordonnées des 4 coins 162 | """ 163 | return cv2.drawContours(image,[box],0,(255,255,255),2) 164 | 165 | def isGridOK(im): 166 | """Juge si la grille de sudoku semble être bonne en vérifiant la proportion de pixels noir dans l'image 167 | __________ 168 | Parameters : 169 | img : grille sudoku (image binaire) 170 | __________ 171 | Return : 172 | booleen : True si la grille est OK False sinon 173 | """ 174 | ret, imageBinaire = cv2.threshold(im,254,255,cv2.THRESH_BINARY) 175 | s = 0 176 | for i in range (0,len(imageBinaire)): 177 | for j in range (0,len(imageBinaire[0])): 178 | if(imageBinaire[i,j] == 0): 179 | s += 1 180 | pourcentageNoir = (s/(len(imageBinaire)*len(imageBinaire[0])))*100 181 | print(pourcentageNoir) 182 | if(pourcentageNoir>5 and pourcentageNoir <25): 183 | return True 184 | else : 185 | return False 186 | 187 | def threshHold(image): 188 | # Remarque : 189 | # En l'état cette fonction n'est plus utile car seul le processNormal est utilisé. Elle est donc equivalente à la fonction processNormal() 190 | # Cependant dans des conditions d'éclairage mauvaise il peut être utile d'appliquer le processAdaptative et de comparer les resultats pour ne conserver que le meilleur 191 | 192 | """Applique tout les traitement sur l'image et retourne la grille avec ses infos 193 | __________ 194 | Parameters : 195 | img : image à traiter 196 | __________ 197 | Return : 198 | rectNorm: tuple ((x, y), (l, h), alpha) où (x, y) sont les coordonnées du centre du rectangle d'approximation de la grille, (l, h) la largeur et la hauteur du rectangle et alpha son angle 199 | norm : la grille de sudoku redressée 200 | """ 201 | #rectAdapt, adapt = processAdaptative(image) 202 | rectNorm, norm = processNormal(image) 203 | return rectNorm, norm 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /Firmware/trackStat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | from Capture import * 4 | from picamera.array import PiRGBArray 5 | import picamera 6 | import time 7 | import cv2 8 | import numpy as np 9 | from thresholding import * 10 | 11 | def trackStat(downColor, upColor, downColor2, upColor2): 12 | """Prend une photo et retourne les coordonnées des centres de gravité des deux plus gros objets dont la couleur 13 | codée en HSV se situe dans l'espace definit par les coordonnées downColor et upColor pour le premier objet 14 | et downColor2 et upColor2 pour le deuxième 15 | __________ 16 | Parameters : 17 | downColor : 3-uplet de les coordonnées représentent la couleur basse pour le premier objet 18 | upColor : 3-uplet de les coordonnées représentent la couleur haute pour le premier objet 19 | downColor2 : 3-uplet de les coordonnées représentent la couleur basse pour le deuxième objet 20 | upColor2 : 3-uplet de les coordonnées représentent la couleur haute pour le deuxième objet 21 | __________ 22 | Return : 23 | a : 2-uplet ie les coordonnées du centre de gravité du premier objet 24 | a : 2-uplet ie les coordonnées du centre de gravité du deuxième objet 25 | """ 26 | l = 1280 27 | L = 1024 28 | 29 | # initialisation de la camera 30 | camera = picamera.PiCamera() 31 | camera.resolution = (l, L) 32 | rawCapture = PiRGBArray(camera, size=(l, L)) 33 | time.sleep(0.1) 34 | # Prise de la photo 35 | camera.capture(rawCapture, format="bgr") 36 | image = rawCapture.array 37 | # Conversion de l'image en HSV 38 | hsv = cv2.cvtColor(image,cv2.COLOR_BGR2HSV) 39 | # Conservation des pixels de la bonne couleur 40 | thresh = cv2.inRange(hsv,np.array(downColor), np.array(upColor)) 41 | thresh2 = cv2.inRange(hsv,np.array(downColor2), np.array(upColor2)) 42 | # Recherche des contours 43 | (contours,_) = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) 44 | (contours2,_) = cv2.findContours(thresh2,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) 45 | # Conservation du contour ayant la plus grande aire pour la première couleur 46 | max_area = 1 47 | best_cnt = 1 48 | for cnt in contours: 49 | area = cv2.contourArea(cnt) 50 | if area > max_area: 51 | max_area = area 52 | best_cnt = cnt 53 | # Conservation du contour ayant la plus grande aire pour la deuxième couleur 54 | max_area2 = 0 55 | best_cnt2 = 1 56 | for cnt in contours2: 57 | area = cv2.contourArea(cnt) 58 | if area > max_area2: 59 | max_area2 = area 60 | best_cnt2 = cnt 61 | # Calcul des coordonnées du centre de gravité du contours le plus grand (best_cnt) 62 | M = cv2.moments(best_cnt) 63 | cx,cy = int(M['m10']/M['m00']), int(M['m01']/M['m00']) 64 | # Calcul des coordonnées du centre de gravité du contours le plus grand (best_cnt2) 65 | M2 = cv2.moments(best_cnt2) 66 | cx2,cy2= int(M2['m10']/M2['m00']), int(M2['m01']/M2['m00']) 67 | # Ajout de deux cercles sur l'image centrés sur les centres de gravités 68 | cv2.circle(image,(cx,cy),10,(0,0,255),2) 69 | cv2.circle(image,(cx2,cy2),10,(0,255,0),2) 70 | a = [cx,cy] 71 | b = [cx2,cy2] 72 | cv2.imwrite('test.png',image) 73 | return a, b 74 | 75 | 76 | print(trackStat((155, 120, 90), (180, 155, 190), (60, 50, 40),(120, 85, 100))) 77 | 78 | -------------------------------------------------------------------------------- /Firmware/tracking.py: -------------------------------------------------------------------------------- 1 | from picamera.array import PiRGBArray 2 | import picamera 3 | import time 4 | import cv2 5 | import numpy as np 6 | 7 | l = 480 8 | L = 480 9 | 10 | 11 | # initialisation de la camra 12 | camera = picamera.PiCamera() 13 | camera.resolution = (l, L) 14 | camera.framerate = 30 15 | camera.hflip = True 16 | rawCapture = PiRGBArray(camera, size=(l, L)) 17 | time.sleep(0.1) 18 | 19 | for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True): 20 | # Recuperation de la matrice décrivant l'image dans la frame 21 | image = frame.array 22 | 23 | # Conversion de l'image en hsv 24 | hsv = cv2.cvtColor(image,cv2.COLOR_BGR2HSV) 25 | # Conservation des pixels d'interêt ie dans lal bonne plage de couleur 26 | thresh = cv2.inRange(hsv,np.array((60, 50, 40)), np.array((120, 85, 100))) 27 | # Recherche des contours 28 | (contours,_) = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) 29 | # Sélection du contour ayant la plus grande aire 30 | max_area = 1 31 | best_cnt = 1 32 | for cnt in contours: 33 | area = cv2.contourArea(cnt) 34 | if area > max_area: 35 | max_area = area 36 | best_cnt = cnt 37 | # Calcul des coordonnées du centre de gravité du contours le plus grand 38 | M = cv2.moments(best_cnt) 39 | cx,cy = int(M['m10']/M['m00']), int(M['m01']/M['m00']) 40 | # Ajout d'un cercle sur l'image centré sur le centre de gravité 41 | cv2.circle(image,(cx,cy),10,(0,0,255),2) 42 | # Ajout d'un cercle au centre de l'image qui permet de bien situé le centre de l'image 43 | cv2.circle(image,(l/2,L/2),10,(0,0,255),2) 44 | # Affichage de la valeur en HSV de la couleur du pixel au centre de l'image. 45 | print(hsv[l/2][L/2]) 46 | # Affichage de l'image 47 | cv2.imshow("Frame", image) 48 | key = cv2.waitKey(1) & 0xFF 49 | rawCapture.truncate(0) 50 | 51 | # Si l'utilisateur presse la touche q on sort de la boucle 52 | if key == ord("q"): 53 | break 54 | 55 | 56 | -------------------------------------------------------------------------------- /GNU GPLv3: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | 676 | -------------------------------------------------------------------------------- /Mechanical/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Mechanical/readme.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A robot that solves and fills alone a sudoku puzzles ! 2 |

3 | 4 |

5 | 6 | Sudoku are digital puzzles that computers can solve automatically because they obey some simple mathematical rules. 7 |

8 | 9 | 10 |

11 | The main objective of this project was to build a rudimentary and autonomous robot like 3D-printer, which will be able to: 12 | 13 | 1. analyze the grid of sudoku to be filled 14 | 2. solve the Sudoku puzzle 15 | 3. fill the grid 16 | 17 | That means the robot must be able to process the grid to be solved in order to detect the boxes already filled,their values and then proceed to filling. 18 | 19 | # How it works? 20 | 21 | The hardware of the robot consist at using a Raspberry pi 3 with a camera. A photo of the grid is taken at the beginning of the process. 22 |

23 | 24 | 25 | 26 |

27 | 28 | The photo is then pre-processed using image processing methods to suppress artefacts, detect rotation and angle therefore (the puzzle can be solved whatever his position on the table). After that the image is redressed to obtain a picture focused only on the grid. 29 | 30 | Once the sudoku grid obtained, we segment the picture to extract each box and proceed to image recognition using [a neural network](https://en.wikipedia.org/wiki/Artificial_neural_network). For that we used Tensorflow framework developed by Google for machine learning. At the end of this process we have a numerical representation of our grid which can then be solved. 31 | 32 | Once solved, the raspberry pi is again used to control the motors of the robot in order to fill the grid. 33 | 34 | To sum up, 35 |

36 | 37 |

38 | 39 | **The result** 40 |

41 | 42 |

43 | 44 | link to youtube video (https://www.youtube.com/watch?v=cQKQf74-gNk) 45 | 46 | **Required skills** 47 | 48 | - computer vision 49 | - Images processing 50 | - Programming skills 51 | - Electronic 52 | - Mechanical 53 | 54 | **useful tools and API** 55 | 56 | - python 57 | - [tensorflow](tensorflow.org) for neural network 58 | - [opencv](http://opencv.org/) for image processing 59 | 60 | # References 61 | 62 | https://en.wikipedia.org/wiki/Sudoku 63 | 64 | A detailled report of this project can be found in ressources directory. 65 | 66 | for more information about the project don't hesitate to contact us 67 | -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/box 2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/box 2.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/box 4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/box 4.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/box0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/box0.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/fonctionnel.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/fonctionnel.docx -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/gantt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/gantt.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/hg1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/hg1.PNG -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/hg2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/hg2.PNG -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/hg3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/hg3.PNG -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/hough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/hough.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/hough1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/hough1.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/ii.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/ii.jpg -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/ii2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/ii2.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 4 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 5 | \global\let\oldcontentsline\contentsline 6 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 7 | \global\let\oldnewlabel\newlabel 8 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 9 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 10 | \AtEndDocument{\ifx\hyper@anchor\@undefined 11 | \let\contentsline\oldcontentsline 12 | \let\newlabel\oldnewlabel 13 | \fi} 14 | \fi} 15 | \global\let\hyper@last\relax 16 | \gdef\HyperFirstAtBeginDocument#1{#1} 17 | \providecommand\HyField@AuxAddToFields[1]{} 18 | \providecommand\HyField@AuxAddToCoFields[2]{} 19 | \catcode `:\active 20 | \catcode `;\active 21 | \catcode `!\active 22 | \catcode `?\active 23 | \select@language{french} 24 | \@writefile{toc}{\select@language{french}} 25 | \@writefile{lof}{\select@language{french}} 26 | \@writefile{lot}{\select@language{french}} 27 | \@writefile{toc}{\contentsline {section}{\numberline {1}Cahier des Charges}{2}{section.1}} 28 | \@writefile{toc}{\contentsline {part}{I\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ouverte}{2}{part.1}} 29 | \@writefile{toc}{\contentsline {section}{\numberline {2}Acquisition et pr\IeC {\'e}-traitement d'images}{2}{section.2}} 30 | \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces wrapping de l'image}}{3}{figure.1}} 31 | \newlabel{ii}{{1}{3}{wrapping de l'image}{figure.1}{}} 32 | \@writefile{toc}{\contentsline {section}{\numberline {3}D\IeC {\'e}tection de la grille et reconnaissance des chiffres}{3}{section.3}} 33 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}D\IeC {\'e}tection de la grille}{3}{subsection.3.1}} 34 | \@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces illustration projection de la grille sur les axes x et y}}{3}{figure.2}} 35 | \newlabel{pp}{{2}{3}{illustration projection de la grille sur les axes x et y}{figure.2}{}} 36 | \@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces illustration transform\IeC {\'e}e de Hough }}{4}{figure.3}} 37 | \newlabel{hg}{{3}{4}{illustration transformée de Hough}{figure.3}{}} 38 | \@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces illustration hough transform sur la grille avec opencv}}{4}{figure.4}} 39 | \newlabel{hg1}{{4}{4}{illustration hough transform sur la grille avec opencv}{figure.4}{}} 40 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}D\IeC {\'e}tection des cases vides}{5}{subsection.3.2}} 41 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}Reconnaissance des chiffres des cases non vides}{5}{subsection.3.3}} 42 | \@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces illustration r\IeC {\'e}seaux de neurones }}{5}{figure.5}} 43 | \newlabel{rn}{{5}{5}{illustration réseaux de neurones}{figure.5}{}} 44 | \@writefile{toc}{\contentsline {section}{\numberline {4}R\IeC {\'e}solution de la grille de Sudoku}{5}{section.4}} 45 | \@writefile{toc}{\contentsline {section}{\numberline {5}\'{E}lectronique et contr\IeC {\^o}le du d\IeC {\'e}placement des moteurs}{5}{section.5}} 46 | \@writefile{toc}{\contentsline {part}{II\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ferm\IeC {\'e}e}{6}{part.2}} 47 | \@writefile{lof}{\contentsline {figure}{\numberline {6}{\ignorespaces diagramme de Gantt }}{7}{figure.6}} 48 | \newlabel{gantt}{{6}{7}{diagramme de Gantt}{figure.6}{}} 49 | -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.out: -------------------------------------------------------------------------------- 1 | \BOOKMARK [1][-]{section.1}{Cahier des Charges}{}% 1 2 | \BOOKMARK [0][-]{part.1}{I R\351solution de la grille: Boucle ouverte}{}% 2 3 | \BOOKMARK [1][-]{section.2}{Acquisition et pr\351-traitement d'images}{part.1}% 3 4 | \BOOKMARK [1][-]{section.3}{D\351tection de la grille et reconnaissance des chiffres}{part.1}% 4 5 | \BOOKMARK [2][-]{subsection.3.1}{D\351tection de la grille}{section.3}% 5 6 | \BOOKMARK [2][-]{subsection.3.2}{D\351tection des cases vides}{section.3}% 6 7 | \BOOKMARK [2][-]{subsection.3.3}{Reconnaissance des chiffres des cases non vides}{section.3}% 7 8 | \BOOKMARK [1][-]{section.4}{R\351solution de la grille de Sudoku}{part.1}% 8 9 | \BOOKMARK [1][-]{section.5}{\311lectronique et contr\364le du d\351placement des moteurs}{part.1}% 9 10 | \BOOKMARK [0][-]{part.2}{II R\351solution de la grille: Boucle ferm\351e}{}% 10 11 | -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/lettre_motiv.pdf -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/lettre_motiv.synctex.gz -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{makeidx} 3 | \usepackage{multirow} 4 | \usepackage{multicol} 5 | \usepackage[dvipsnames,svgnames,table]{xcolor} 6 | \usepackage{graphicx} 7 | \usepackage{epstopdf} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage{ulem} 10 | \usepackage{import} 11 | \usepackage{hyperref} 12 | \usepackage{amsmath} 13 | \usepackage{amssymb} 14 | \usepackage{tikz} 15 | \usepackage[francais]{babel} 16 | \usetikzlibrary{matrix,shapes,arrows,positioning,chains} 17 | \author{Mohamed SANA} 18 | \title{} 19 | \usepackage[paperwidth=595pt,paperheight=841pt,top=49pt,right=70pt,bottom=35pt,left=70pt]{geometry} 20 | \makeatletter 21 | \newenvironment{indentation}[3] 22 | {\par\setlength{\parindent}{#3} 23 | \setlength{\leftmargin}{#1} \setlength{\rightmargin}{#2} 24 | \advance\linewidth -\leftmargin \advance\linewidth -\rightmargin 25 | \advance\@totalleftmargin\leftmargin \@setpar{{\@@par}} 26 | \parshape 1\@totalleftmargin \linewidth\ignorespaces}{\par} 27 | \makeatother 28 | 29 | \begin{document} 30 | \begin{flushright} 31 | Mardi le 31/01/2017\\ 32 | \end{flushright}\\ 33 | \newline 34 | \newline 35 | \newline 36 | % La table des matières 37 | \part*{\center{ROBOT SUDOKU (SICOM 2A)}} 38 | \textbf{\begin{center} 39 | Par:\\ 40 | BOUDIER Baptiste\\ 41 | SANA Mohamed\\ 42 | GENTIL Kévin\\ 43 | BERTRAND Emile\\ 44 | *------------------------------------------------*\\ 45 | Tuteur: BERTRAND Rivet\\ 46 | \end{center}} 47 | *---------------------------------------------------------------------------------------------------------------------*\\ 48 | 49 | \newline 50 | \newline 51 | \newline 52 | \tableofcontents 53 | \newpage 54 | \part*{INTRODUCTION} 55 | 56 | Ce projet a pour but la réalisation d'un robot autonome capable d'analyser et de résoudre des grilles de Sudoku. Ce robot, basique, de type table traçante devra être en mesure d'acquérir une image de la grille de Sudoku à résoudre, puis procéder à l'analyse de cette image pour y détecter la grille et procéder à sa résolution mathématique. Une fois résolue, le robot devra alors compléter la grille de Sudoku et tout ceci de façon autonome. 57 | 58 | \section{Cahier des Charges} 59 | \textbf{Cadre du projet :}\\ 60 | Notre projet est de construire un robot pouvant résoudre, puis compléter une grille de Sudoku de façon autonome. \\ 61 | Pour l'instant, nous avons déjà le corps du robot et il nous reste toute la partie programmation et quelques améliorations de la mécanique et de l'électronique.\\ 62 | 63 | \textbf{Attentes des utilisateurs :}\\ 64 | Le robot doit pouvoir résoudre et remplir la grille quelque soit l'orientation et la taille de celle-ci. Il devra donc pouvoir adapter sa façon d'écrire au cas par cas.\\ 65 | 66 | \textbf{Définition des objectifs :}\\ 67 | Premièrement, il faut que le robot puisse fonctionner avec une grille de taille fixe,que nous définirons, et avec une orientation sur le plateau connue.\\ 68 | Deuxièmement, il faut qu'il puisse s'adapter selon une orientation inconnue (taille standard), puis avec une taille non définie (orientation connue). Enfin, il faut qu'il réussisse avec les deux paramètres inconnus.\\ 69 | Le robot ne pourra par contre fonctionner que si la grille de Sudoku ne quitte pas un périmètre de 165x165 mm délimité par un carré bleu sur le plateau. Ce périmètre est imposé par la limitation du champ de vision de la caméra.\\ 70 | 71 | \textbf{Tests :}\\ 72 | La validation du système passe par l'implémentation de plusieurs tests. Ces tests doivent prendre en compte plusieurs grilles de tailles différentes avec des orientations différentes.\\ 73 | Toutes ces étapes doivent être faites selon le diagramme de Gantt de la figure ~\ref{gantt} 74 | 75 | \part{Résolution de la grille: Boucle ouverte} 76 | Dans cette première partie, aucun asservissement n'est réalisé par rapport aux déplacements des moteurs. 77 | \section{Acquisition et pré-traitement d'images} 78 | 79 | Dans cette partie l'objectif est de faire l'acquisition d'une image : la grille de Sudoku placée sur le plateau, et d'y appliquer les premiers traitements. Ces traitements consistent en la détermination le l'emplacement de la grille sur le plateau, son orientation ainsi que l'isolement de la grille afin qu'elle puisse être analysée dans la partie suivante. L'image retournée à l'issue de cette étape est une image binarisée (noir et blanc) où la grille est les chiffres ressortent le mieux possible, le plus proche possible de la grille de Sudoku numérique qui a été imprimée (voir figure ~\ref{ii}). Pour effectuer cette étape on se servira d'un raspberry pi ''2011.12'', de la camera ''Rasperry PI camera Rev 1.3'', du langage python ainsi que que de la librairie Opencv.\\ 80 | \begin{figure}[!h] 81 | \centering 82 | \includegraphics[scale = 0.07]{ii.jpg} 83 | \includegraphics[scale = 0.086]{ii2.png} 84 | \caption{\label{ii}wrapping de l'image} 85 | \end{figure} 86 | 87 | \section{Détection de la grille et reconnaissance des chiffres} 88 | 89 | L'objectif de cette partie, c'est de pouvoir aux moyens de techniques de segmentation d'images, reconnaitre la grille du Sudoku pour en extraire chaque case. Chaque image de case extraite va ensuite subir un certain nombre de traitements, le but étant de pouvoir reconnaitre si celle-ci est vide ou sinon quel chiffre s'y affiche. La valeur de retour de cette étape du traitement est une matrice 9x9 représentant la grille de Sudoku en vu de sa résolution dans l'étape suivante. 90 | \subsection{Détection de la grille} 91 | Il existe plusieurs techniques permettant de reconnaitre des lignes dans une image. En effectuant ''l'état de l'art'' de ces techniques, 3 méthodes sortent du lots par leur efficacité: 92 | \begin{enumerate} 93 | \item \textbf{Les projections orthogonales de la grille suivant l'axe x et y:}\\ 94 | L'image de la grille de Sudoku, étant constituée de ligne, les projections de la grille suivant les axes x et y peuvent conduire à des résultats exploitables.\\ 95 | \begin{figure}[!h] 96 | \centering 97 | \includegraphics[scale = 0.5]{pp.png} 98 | \caption{\label{pp} illustration projection de la grille sur les axes x et y} 99 | \end{figure} 100 | On peut ainsi voir sur ces projections ~\ref{pp} , 10 pics reflétant les positions des lignes sur la grille de Sudoku. La mesure de la distance entre-pics pourrait donc permettre de segmenter l'image de Sudoku. 101 | \item \textbf{La transformée de Hough:}\\ 102 | Cette méthode se base sur le fait que pour un point de coordonnées (x,y) il existe une infinité de droites passant par ce point mais pour 2 points distincts donnés, il existe une une droite passant par ces 2 points. Pour un point $(x_0,y_0)$ de l'image l'ensemble des droites passants par ce point est donné par l'équation:\\ 103 | $r_\theta = x_0*\cos \theta + y_0*\sin \theta$ (1) \\ 104 | où chaque couple $(r_\theta,\theta)$ représente l'équation d'une droite passant par le point $(x_0,y_0)$.\\ 105 | Ainsi pour $(x_0,y_0)$ donné, on peut représenter le lieu de ces droites (illustration sur la figure ~\ref{hg} en haut à droite). Ce que fait cette méthode c'est représenter pour tous points (x,y) de l'image ce lieu des droites et si par exemple 3 lieux de 3 points donnés se coupent cela implique que ces 3 points sont alignés dans l'image ( illustration faite sur la figure 2 en bas à droite ~\ref{hg}). Par exemple sur notre figure la droite passant par ces trois points est donnée par ses coordonnées polaires (0.96,9.56).\\ 106 | \begin{figure}[!h] 107 | \centering 108 | \includegraphics[scale = 0.8]{hg1.png} 109 | \caption{\label{hg} illustration transformée de Hough } 110 | \end{figure} 111 | 112 | On voit bien qu'avec cette méthode on pourrait bien détecter la grille de Sudoku, formée d'ailleurs de ligne. Cependant l'inconvénient de ma méthode c'est que tout ce qui est ligne de pixel sera détecté : il va falloir donc définir ce que nous considérons comme faisant parti de la grille et donc filtrer certaines données!\\ 113 | Exemple d'implémentation de cette méthode que nous avons fait avec la libraire opencv (figure ~\ref{hg1}). 114 | \begin{figure}[!h] 115 | \centering 116 | \includegraphics[scale = 0.7]{hough1.png}} 117 | \caption{\label{hg1} illustration hough transform sur la grille avec opencv} 118 | \end{figure} 119 | \item \textbf{La méthode de la détection des composantes connexes:}\\ 120 | Cette méthode quant à elle permet de détecter les connexités dans l'image. Un pixel est connecté à son voisin si celui-ci est dans le même état que le pixel considéré. Il existe principalement 2 ordres de connexité : 4-connexités (le voisinage du pixel est constitué des 4 plus proches voisin) et 8-connexités( le voisinage du pixel est constitué des 8 plus proches voisin). Cette méthode est très efficace puisque les pixels des lignes de la grille du Sudoku sont aussi connectés.\\ 121 | \end{enumerate} 122 | Nous parcourirons toutes ces solutions pour voir les avantages et les inconvénients de chacune d'elle et choisir la meilleure pour segmenter l'image du Sudoku. 123 | \subsection{Détection des cases vides} 124 | Une fois l'image segmentée en 9x9 images il va falloir détecter les cases vides du Sudoku. Une case vide est principalement constituée de pixels blancs. Dans la segmentation de l'image, des pixels noirs de la grille peuvent s'y retrouver. Cela veut dire qu'en calculant l'écart type type de chaque image de case, on pourrait trouver un seuil acceptable tel que pour un écart type au dessus de ce seuil, une case sera considérée comme vide. 125 | 126 | \subsection{Reconnaissance des chiffres des cases non vides} 127 | Plusieurs techniques de reconnaissance d'images (de chiffres en particulier) existent. Pour notre application, nous avons réffléchi à l'utilisation d'une méthode de reconnaissance par classification et apprentissage de réseaux de neurones ~\ref{rn} . Pour cela la libraire \textbf{tensorflow} de google que nous utiliserons offre un certain nombre de fonctions pour prendre en main ces techniques de classification. 128 | 129 | 130 | %\includegraphics[scale = 0.45]{sud1.png} 131 | \begin{figure}[!h] 132 | \centering 133 | \pagestyle{empty} 134 | \def\layersep{2.5cm} 135 | \begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] 136 | \tikzstyle{every pin edge}=[<-,shorten <=1pt] 137 | \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt] 138 | \tikzstyle{input neuron}=[neuron, fill=green!50]; 139 | \tikzstyle{output neuron}=[neuron, fill=red!50]; 140 | \tikzstyle{hidden neuron}=[neuron, fill=blue!50]; 141 | \tikzstyle{annot} = [text width=4em, text centered] 142 | 143 | 144 | % Draw the input layer nodes 145 | \foreach \name / \y in {1,...,4} 146 | % This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4} 147 | \node[input neuron, pin=left:Input(pixels des cases) \#\y] (I-\name) at (0,-\y) {}; 148 | 149 | % Draw the hidden layer nodes 150 | \foreach \name / \y in {1,...,5} 151 | \path[yshift=0.5cm] 152 | node[hidden neuron] (H-\name) at (\layersep,-\y cm) {}; 153 | 154 | % Draw the output layer node 155 | \node[output neuron,pin={[pin edge={->}]right:Output[matrice du Sudoku]}, right of=H-3] (O) {}; 156 | 157 | % Connect every node in the input layer with every node in the 158 | % hidden layer. 159 | \foreach \source in {1,...,4} 160 | \foreach \dest in {1,...,5} 161 | \path (I-\source) edge (H-\dest); 162 | 163 | % Connect every node in the hidden layer with the output layer 164 | \foreach \source in {1,...,5} 165 | \path (H-\source) edge (O); 166 | 167 | % Annotate the layers 168 | \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; 169 | \node[annot,left of=hl] {Input layer}; 170 | \node[annot,right of=hl] {Output layer}; 171 | \end{tikzpicture} 172 | \caption{\label{rn} illustration réseaux de neurones } 173 | \end{figure} 174 | 175 | \section{Résolution de la grille de Sudoku} 176 | On utilise la méthode par listes chaînées, mais simplifiée car python permet une implémentation plus simple de cette méthode. le principe est simple, on remplace les cases vides par une liste possédant l'ensemble des possibilités, puis on réduit ces listes au fur et à mesure jusqu'à n'obtenir plus qu'une seule possibilité. 177 | 178 | %% Define block styles 179 | %\tikzset{ 180 | %desicion/.style={ 181 | % diamond, 182 | % draw, 183 | % text width=4em, 184 | % text badly centered, 185 | % inner sep=0pt 186 | %}, 187 | %block/.style={ 188 | % rectangle, 189 | % draw, 190 | % text width=10em, 191 | % text centered, 192 | % rounded corners 193 | %}, 194 | %cloud/.style={ 195 | % draw, 196 | % ellipse, 197 | % minimum height=2em 198 | %}, 199 | %descr/.style={ 200 | % fill=white, 201 | % inner sep=2.5pt 202 | %}, 203 | %connector/.style={ 204 | % -latex, 205 | % font=\scriptsize 206 | %}, 207 | %rectangle connector/.style={ 208 | % connector, 209 | % to path={(\tikztostart) -- ++(#1,0pt) \tikztonodes |- (\tikztotarget) }, 210 | % pos=0.5 211 | %}, 212 | %rectangle connector/.default=-2cm, 213 | %straight connector/.style={ 214 | % connector, 215 | % to path=--(\tikztotarget) \tikztonodes 216 | %} 217 | %} 218 | % 219 | %\begin{tikzpicture} 220 | %\matrix (m)[matrix of nodes, column sep=2cm,row sep=8mm, align=center, nodes={rectangle,draw, anchor=center} ]{ 221 | % |[block]| {Start}; & \\ 222 | % |[block]| {Assume that $a=c$ the optimilalty cretierin given by } & \\ 223 | % |[desicion]| {Locally optimal} & \\ 224 | % |[block]| {Assume that $a=d$ the optimilalty cretierin given by} & \\ 225 | % |[desicion]| {Locally optimal} & \\ 226 | % |[block]| {Assume that $a=e$ the optimilalty cretierin given by} & \\ 227 | % |[desicion]| {Locally optimal} & \\ 228 | % |[block]| {Assume that $a=f$ the optimilalty cretierin given by} & \\ 229 | % |[desicion]| {Locally optimal} & \\ 230 | % |[block]| {Assume that $a=k$ the optimilalty cretierin given by} & \\ 231 | % |[desicion]| {Locally optimal} & \\ 232 | % |[block]| {Stop}; & \\ 233 | %}; 234 | %\path [>=latex,->] (m-1-1) edge (m-2-1); 235 | %\path [>=latex,->] (m-2-1) edge (m-3-1); 236 | %\path [>=latex,->] (m-3-1) edge (m-4-1); 237 | %\path [>=latex,->] (m-4-1) edge (m-5-1); 238 | %\path [>=latex,->] (m-5-1) edge (m-6-1); 239 | %\path [>=latex,->] (m-6-1) edge (m-7-1); 240 | %\path [>=latex,->] (m-7-1) edge (m-8-1); 241 | %\path [>=latex,->] (m-8-1) edge (m-9-1); 242 | %\path [>=latex,->] (m-9-1) edge (m-10-1); 243 | %\path [>=latex,->] (m-10-1) edge (m-11-1); 244 | %\path [>=latex,->] (m-11-1) edge (m-12-1); 245 | % 246 | %\end{tikzpicture} 247 | 248 | 249 | \section{\'{E}lectronique et contrôle du déplacement des moteurs} 250 | Le contrôle des moteurs se fera avec la carte Raspberry Pi et non plus avec l'Arduino pour une facilité de la gestion du programme. 251 | Même si la Raspberry Pi n'a pas de protection sur ses entrées/sorties, nous avons pas besoin d’optocoupleur car les seules entrées sont des capteurs de fin de course (il ne faut pas oublier les résistances de protection). Les sorties sont reliées au drivers des moteurs et au servomoteur. 252 | Il y a besoin d'une alimentation de 2.8V (tension nominale) pour les moteurs (utilisation d'un régulateur de tension à partir du 5V de la Raspberry Pi). 253 | Cependant les moteurs peuvent demander jusqu'à 1.68A et les drivers n'en fournissent que 1.2A mais peuvent supporter jusqu'à 2A pendant 20 ms or nous avons remarqué à l'oscilloscope que l'on avait des pics de 2A inférieur à 20 ms.\\ 254 | 255 | Mise en place de deux ou trois leds pour renseigner l'état de la résolution et de l'écriture du Sudoku.\\ 256 | 257 | Il faut créer des fonctions en python pour contrôler les moteurs, le servomoteur,et les leds à définir suivant les étapes de réalisation dans le software. La mise en place de l'automatisation de l'écriture des chiffres avec la camera qui asservit la position du stylo sera effectuée si tout le reste du projet fonctionne. En attendant, le déplacement de la grille et du stylo sera réalisé en comptant le nombre pas du moteur (fonction du déplacement de la table ou du stylo). Il faut positionner le stylo dans le coin inférieur gauche (ou un autre) d'une case puis appeler une fonction d'écriture d'un chiffre. La création des fonctions en python de l'écriture des chiffres aura en entrée l'angle de la feuille, la dimension d'un côté d'une case ( pour la taille du chiffre). En sortie ces fonctions appelleront directement les fonctions de déplacement des moteurs et du servomoteur. 258 | 259 | \part{Résolution de la grille: Boucle fermée} 260 | 261 | Dans une deuxième partie, l'objectif du projet sera de réaliser tout le traitement en boucle fermée. En effet dans la première partie le Robot complète la grille ''à l'aveugle'' moyennant les estimations de la position et de chaque case de la grille faite dans la partie pré-traitement. Seulement ces estimations ne sont pas toujours bonnes: on peut écrire de travers. L'idée est de pouvoir, grâce à la caméra, asservir le déplacement des moteurs pour compléter la grille afin d'avoir une meilleur précision d'écriture.\\ 262 | 263 | \item 264 | \textbf{ORGANISATION DE L'ÉQUIPE}\\ 265 | \\ 266 | Acquisition et pré-traitement : BOUDIER Baptiste\\ 267 | Détection de la grille et reconnaissance des chiffres : SANA Mohamed\\ 268 | Résolution du Sudoku + mécanique : GENTIL Kévin\\ 269 | Électronique et Contrôle des moteurs : BERTRAND Emile\\ 270 | Le diagramme de Gantt de la figure ~\ref{gantt} montre le déroulement du projet.\\ 271 | 272 | \item 273 | \textbf{Composants, matériels et logiciels utilisés}\\ 274 | Toute la programmation se fera avec le langage \textbf{Python} et les libraires suivantes: 275 | \begin{itemize} 276 | \item{Opencv} pour le traitement d'image 277 | \item{Numpy} pour les calculs matriciels 278 | \item{Matplolib} pour l'affichage des courbes et graphes 279 | \item{Tensorflow} pour la classification et la reconnaissance des chiffres 280 | \item{Pycam} pour la gestion de la camera de la Raspbery py 281 | \end{itemize} 282 | \item 283 | Supports matériels: 284 | \begin{itemize} 285 | \item{Raspberry Py} 286 | \item{Arduino} 287 | \item{Moteurs pas à pas et leurs drivers + servomoteurs} 288 | \item{Capteurs de fin de course + régulateurs de tension} 289 | \end{itemize} 290 | \newline 291 | \item 292 | \textbf{Commandes projets}\\ 293 | Convertisseur HDMI male VGA femelle (réf: 778-1882) prix: 22.47 euros, chez RS PRO\\ 294 | \newpage 295 | \item 296 | \textbf{BIBLIOGRAPHIE}\\ 297 | \item 298 | Résolution Sudoku : \url{http://www-ljk.imag.fr/membres/Jerome.Lelong/fichiers/Ensta/sudoku.pdf}\\ 299 | Reconnaissance et capture d'images de documents : \url{https://tel.archives-ouvertes.fr/tel-00821889/document}\\ 300 | \url{https://web.stanford.edu/class/ee368/Project_Spring_1415/Reports/Wang.pdf}\\ 301 | \url{http://docs.opencv.org/3.0-beta/modules/imgproc/doc/feature_detection.html?highlight=houghline#cv2.HoughLines}\\ 302 | 303 | \begin{figure}[!h] 304 | \centering 305 | \includegraphics[scale = 0.38]{gantt.png} 306 | \caption{\label{gantt} diagramme de Gantt } 307 | \end{figure} 308 | 309 | 310 | \end{document} 311 | -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/lettre_motiv.toc: -------------------------------------------------------------------------------- 1 | \select@language {french} 2 | \contentsline {section}{\numberline {1}Cahier des Charges}{2}{section.1} 3 | \contentsline {part}{I\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ouverte}{2}{part.1} 4 | \contentsline {section}{\numberline {2}Acquisition et pr\IeC {\'e}-traitement d'images}{2}{section.2} 5 | \contentsline {section}{\numberline {3}D\IeC {\'e}tection de la grille et reconnaissance des chiffres}{3}{section.3} 6 | \contentsline {subsection}{\numberline {3.1}D\IeC {\'e}tection de la grille}{3}{subsection.3.1} 7 | \contentsline {subsection}{\numberline {3.2}D\IeC {\'e}tection des cases vides}{5}{subsection.3.2} 8 | \contentsline {subsection}{\numberline {3.3}Reconnaissance des chiffres des cases non vides}{5}{subsection.3.3} 9 | \contentsline {section}{\numberline {4}R\IeC {\'e}solution de la grille de Sudoku}{5}{section.4} 10 | \contentsline {section}{\numberline {5}\'{E}lectronique et contr\IeC {\^o}le du d\IeC {\'e}placement des moteurs}{5}{section.5} 11 | \contentsline {part}{II\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ferm\IeC {\'e}e}{6}{part.2} 12 | -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/pp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/pp.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/pre_rapport_robot_sudoku_sicom2A_groupe3(1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/pre_rapport_robot_sudoku_sicom2A_groupe3(1).pdf -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/pre_rapport_robot_sudoku_sicom2A_groupe3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/pre_rapport_robot_sudoku_sicom2A_groupe3.pdf -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/pxy-img0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/pxy-img0.png -------------------------------------------------------------------------------- /Ressources/Rapport de reformulation/sud1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport de reformulation/sud1.png -------------------------------------------------------------------------------- /Ressources/Rapport final/4-8c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/4-8c.png -------------------------------------------------------------------------------- /Ressources/Rapport final/4c.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/4c.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/8c.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/8c.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/Rapport_final_Sudoku_sicom.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/Rapport_final_Sudoku_sicom.rar -------------------------------------------------------------------------------- /Ressources/Rapport final/b0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b0.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b1.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b12.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b12.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b13.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b13.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b2.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b3.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b4.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b5.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b6.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b7.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b8.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/b9.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/b9.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/e1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/e1.jpg -------------------------------------------------------------------------------- /Ressources/Rapport final/e2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/e2.png -------------------------------------------------------------------------------- /Ressources/Rapport final/e3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/e3.png -------------------------------------------------------------------------------- /Ressources/Rapport final/ecc.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/ecc.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/final.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 4 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 5 | \global\let\oldcontentsline\contentsline 6 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 7 | \global\let\oldnewlabel\newlabel 8 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 9 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 10 | \AtEndDocument{\ifx\hyper@anchor\@undefined 11 | \let\contentsline\oldcontentsline 12 | \let\newlabel\oldnewlabel 13 | \fi} 14 | \fi} 15 | \global\let\hyper@last\relax 16 | \gdef\HyperFirstAtBeginDocument#1{#1} 17 | \providecommand\HyField@AuxAddToFields[1]{} 18 | \providecommand\HyField@AuxAddToCoFields[2]{} 19 | \catcode `:\active 20 | \catcode `;\active 21 | \catcode `!\active 22 | \catcode `?\active 23 | \select@language{french} 24 | \@writefile{toc}{\select@language{french}} 25 | \@writefile{lof}{\select@language{french}} 26 | \@writefile{lot}{\select@language{french}} 27 | \@writefile{toc}{\contentsline {part}{I\hspace {1em}Introduction et cahier des charges}{2}{part.1}} 28 | \@writefile{toc}{\contentsline {section}{\numberline {1}Introduction}{2}{section.1}} 29 | \@writefile{toc}{\contentsline {section}{\numberline {2}Cahier des Charges}{2}{section.2}} 30 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Cadre du projet}{2}{subsection.2.1}} 31 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Attentes des utilisateurs :}{2}{subsection.2.2}} 32 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.3}D\IeC {\'e}finition des objectifs}{2}{subsection.2.3}} 33 | \@writefile{toc}{\contentsline {subsection}{\numberline {2.4}Tests}{2}{subsection.2.4}} 34 | \@writefile{toc}{\contentsline {part}{II\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ouverte}{2}{part.2}} 35 | \@writefile{toc}{\contentsline {section}{\numberline {3}Acquisition et pr\IeC {\'e}-traitement d'images}{3}{section.3}} 36 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Capture et traitement d'image}{3}{subsection.3.1}} 37 | \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Image Grille de Sudoku originale}}{3}{figure.1}} 38 | \newlabel{b0}{{1}{3}{Image Grille de Sudoku originale}{figure.1}{}} 39 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.1.1}Capture}{3}{subsubsection.3.1.1}} 40 | \@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Image brute 1}}{3}{figure.2}} 41 | \newlabel{b1}{{2}{3}{Image brute 1}{figure.2}{}} 42 | \@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces Image brute 2}}{3}{figure.3}} 43 | \newlabel{b2}{{3}{3}{Image brute 2}{figure.3}{}} 44 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.1.2} Traitement}{4}{subsubsection.3.1.2}} 45 | \@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces Image }}{4}{figure.4}} 46 | \newlabel{b3}{{4}{4}{Image}{figure.4}{}} 47 | \@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces Image}}{4}{figure.5}} 48 | \newlabel{b4}{{5}{4}{Image}{figure.5}{}} 49 | \@writefile{lof}{\contentsline {figure}{\numberline {6}{\ignorespaces Image binaris\IeC {\'e}e}}{4}{figure.6}} 50 | \newlabel{b5}{{6}{4}{Image binarisée}{figure.6}{}} 51 | \@writefile{lof}{\contentsline {figure}{\numberline {7}{\ignorespaces Image binaris\IeC {\'e}e}}{4}{figure.7}} 52 | \newlabel{b6}{{7}{4}{Image binarisée}{figure.7}{}} 53 | \@writefile{lof}{\contentsline {figure}{\numberline {8}{\ignorespaces Grille1 }}{6}{figure.8}} 54 | \newlabel{b7}{{8}{6}{Grille1}{figure.8}{}} 55 | \@writefile{lof}{\contentsline {figure}{\numberline {9}{\ignorespaces Grille 2}}{6}{figure.9}} 56 | \newlabel{b8}{{9}{6}{Grille 2}{figure.9}{}} 57 | \@writefile{toc}{\contentsline {section}{\numberline {4}D\IeC {\'e}tection de la grille et reconnaissance des chiffres}{6}{section.4}} 58 | \@writefile{lof}{\contentsline {figure}{\numberline {10}{\ignorespaces \IeC {\'E}tapes importantes du traitement}}{6}{figure.10}} 59 | \newlabel{etape}{{10}{6}{Étapes importantes du traitement}{figure.10}{}} 60 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.1}D\IeC {\'e}tection de la grille}{7}{subsection.4.1}} 61 | \@writefile{lof}{\contentsline {figure}{\numberline {11}{\ignorespaces Lignes d\IeC {\'e}grad\IeC {\'e}es}}{7}{figure.11}} 62 | \newlabel{lign_degra}{{11}{7}{Lignes dégradées}{figure.11}{}} 63 | \@writefile{lof}{\contentsline {figure}{\numberline {12}{\ignorespaces illustration transform\IeC {\'e}e de Hough }}{8}{figure.12}} 64 | \newlabel{hg}{{12}{8}{illustration transformée de Hough}{figure.12}{}} 65 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.2}Extraction des cases}{8}{subsection.4.2}} 66 | \@writefile{lof}{\contentsline {figure}{\numberline {13}{\ignorespaces Connexit\IeC {\'e} }}{8}{figure.13}} 67 | \newlabel{cc}{{13}{8}{Connexité}{figure.13}{}} 68 | \@writefile{lof}{\contentsline {figure}{\numberline {14}{\ignorespaces illustration Composantes Connexes }}{9}{figure.14}} 69 | \newlabel{ecc}{{14}{9}{illustration Composantes Connexes}{figure.14}{}} 70 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.3}Reconnaissance des chiffres sur les cases}{9}{subsection.4.3}} 71 | \@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces Matrice de confusion}}{10}{table.1}} 72 | \newlabel{tab3}{{1}{10}{Matrice de confusion}{table.1}{}} 73 | \@writefile{toc}{\contentsline {section}{\numberline {5}R\IeC {\'e}solution de la grille de Sudoku}{10}{section.5}} 74 | \@writefile{lof}{\contentsline {figure}{\numberline {15}{\ignorespaces Organigramme }}{11}{figure.15}} 75 | \newlabel{ho}{{15}{11}{Organigramme}{figure.15}{}} 76 | \@writefile{toc}{\contentsline {section}{\numberline {6}\'{E}lectronique et contr\IeC {\^o}le du d\IeC {\'e}placement des moteurs}{12}{section.6}} 77 | \@writefile{toc}{\contentsline {subsection}{\numberline {6.1}Choix de conception}{12}{subsection.6.1}} 78 | \@writefile{lof}{\contentsline {figure}{\numberline {16}{\ignorespaces Maquette }}{12}{figure.16}} 79 | \newlabel{mq}{{16}{12}{Maquette}{figure.16}{}} 80 | \@writefile{toc}{\contentsline {subsection}{\numberline {6.2}Choix des composants}{13}{subsection.6.2}} 81 | \@writefile{toc}{\contentsline {subsection}{\numberline {6.3}Contr\IeC {\^o}le des moteurs}{13}{subsection.6.3}} 82 | \@writefile{lof}{\contentsline {figure}{\numberline {17}{\ignorespaces Image 1}}{13}{figure.17}} 83 | \newlabel{e2}{{17}{13}{Image 1}{figure.17}{}} 84 | \@writefile{lof}{\contentsline {figure}{\numberline {18}{\ignorespaces Image 2}}{13}{figure.18}} 85 | \newlabel{e3}{{18}{13}{Image 2}{figure.18}{}} 86 | \@writefile{toc}{\contentsline {subsection}{\numberline {6.4}Carte PCB}{14}{subsection.6.4}} 87 | \@writefile{lof}{\contentsline {figure}{\numberline {19}{\ignorespaces Routage}}{14}{figure.19}} 88 | \newlabel{e4}{{19}{14}{Routage}{figure.19}{}} 89 | \@writefile{lof}{\contentsline {figure}{\numberline {20}{\ignorespaces visualisation}}{14}{figure.20}} 90 | \newlabel{e5}{{20}{14}{visualisation}{figure.20}{}} 91 | \@writefile{toc}{\contentsline {part}{III\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ferm\IeC {\'e}e}{14}{part.3}} 92 | \@writefile{toc}{\contentsline {section}{\numberline {7}Tracking}{15}{section.7}} 93 | \@writefile{lof}{\contentsline {figure}{\numberline {21}{\ignorespaces Le tracking en action}}{15}{figure.21}} 94 | \newlabel{b9}{{21}{15}{Le tracking en action}{figure.21}{}} 95 | \@writefile{toc}{\contentsline {section}{\numberline {8}Boucler la boucle}{16}{section.8}} 96 | \@writefile{lof}{\contentsline {figure}{\numberline {22}{\ignorespaces diagramme de Gantt }}{17}{figure.22}} 97 | \newlabel{gantt}{{22}{17}{diagramme de Gantt}{figure.22}{}} 98 | -------------------------------------------------------------------------------- /Ressources/Rapport final/final.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/final.log -------------------------------------------------------------------------------- /Ressources/Rapport final/final.out: -------------------------------------------------------------------------------- 1 | \BOOKMARK [0][-]{part.1}{I Introduction et cahier des charges}{}% 1 2 | \BOOKMARK [1][-]{section.1}{Introduction}{part.1}% 2 3 | \BOOKMARK [1][-]{section.2}{Cahier des Charges}{part.1}% 3 4 | \BOOKMARK [2][-]{subsection.2.1}{Cadre du projet}{section.2}% 4 5 | \BOOKMARK [2][-]{subsection.2.2}{Attentes des utilisateurs :}{section.2}% 5 6 | \BOOKMARK [2][-]{subsection.2.3}{D\351finition des objectifs}{section.2}% 6 7 | \BOOKMARK [2][-]{subsection.2.4}{Tests}{section.2}% 7 8 | \BOOKMARK [0][-]{part.2}{II R\351solution de la grille: Boucle ouverte}{}% 8 9 | \BOOKMARK [1][-]{section.3}{Acquisition et pr\351-traitement d'images}{part.2}% 9 10 | \BOOKMARK [2][-]{subsection.3.1}{Capture et traitement d'image}{section.3}% 10 11 | \BOOKMARK [3][-]{subsubsection.3.1.1}{Capture}{subsection.3.1}% 11 12 | \BOOKMARK [3][-]{subsubsection.3.1.2}{ Traitement}{subsection.3.1}% 12 13 | \BOOKMARK [1][-]{section.4}{D\351tection de la grille et reconnaissance des chiffres}{part.2}% 13 14 | \BOOKMARK [2][-]{subsection.4.1}{D\351tection de la grille}{section.4}% 14 15 | \BOOKMARK [2][-]{subsection.4.2}{Extraction des cases}{section.4}% 15 16 | \BOOKMARK [2][-]{subsection.4.3}{Reconnaissance des chiffres sur les cases}{section.4}% 16 17 | \BOOKMARK [1][-]{section.5}{R\351solution de la grille de Sudoku}{part.2}% 17 18 | \BOOKMARK [1][-]{section.6}{\311lectronique et contr\364le du d\351placement des moteurs}{part.2}% 18 19 | \BOOKMARK [2][-]{subsection.6.1}{Choix de conception}{section.6}% 19 20 | \BOOKMARK [2][-]{subsection.6.2}{Choix des composants}{section.6}% 20 21 | \BOOKMARK [2][-]{subsection.6.3}{Contr\364le des moteurs}{section.6}% 21 22 | \BOOKMARK [2][-]{subsection.6.4}{Carte PCB}{section.6}% 22 23 | \BOOKMARK [0][-]{part.3}{III R\351solution de la grille: Boucle ferm\351e}{}% 23 24 | \BOOKMARK [1][-]{section.7}{Tracking}{part.3}% 24 25 | \BOOKMARK [1][-]{section.8}{Boucler la boucle}{part.3}% 25 26 | -------------------------------------------------------------------------------- /Ressources/Rapport final/final.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/final.synctex.gz -------------------------------------------------------------------------------- /Ressources/Rapport final/final.toc: -------------------------------------------------------------------------------- 1 | \select@language {french} 2 | \contentsline {part}{I\hspace {1em}Introduction et cahier des charges}{2}{part.1} 3 | \contentsline {section}{\numberline {1}Introduction}{2}{section.1} 4 | \contentsline {section}{\numberline {2}Cahier des Charges}{2}{section.2} 5 | \contentsline {subsection}{\numberline {2.1}Cadre du projet}{2}{subsection.2.1} 6 | \contentsline {subsection}{\numberline {2.2}Attentes des utilisateurs :}{2}{subsection.2.2} 7 | \contentsline {subsection}{\numberline {2.3}D\IeC {\'e}finition des objectifs}{2}{subsection.2.3} 8 | \contentsline {subsection}{\numberline {2.4}Tests}{2}{subsection.2.4} 9 | \contentsline {part}{II\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ouverte}{2}{part.2} 10 | \contentsline {section}{\numberline {3}Acquisition et pr\IeC {\'e}-traitement d'images}{3}{section.3} 11 | \contentsline {subsection}{\numberline {3.1}Capture et traitement d'image}{3}{subsection.3.1} 12 | \contentsline {subsubsection}{\numberline {3.1.1}Capture}{3}{subsubsection.3.1.1} 13 | \contentsline {subsubsection}{\numberline {3.1.2} Traitement}{4}{subsubsection.3.1.2} 14 | \contentsline {section}{\numberline {4}D\IeC {\'e}tection de la grille et reconnaissance des chiffres}{6}{section.4} 15 | \contentsline {subsection}{\numberline {4.1}D\IeC {\'e}tection de la grille}{7}{subsection.4.1} 16 | \contentsline {subsection}{\numberline {4.2}Extraction des cases}{8}{subsection.4.2} 17 | \contentsline {subsection}{\numberline {4.3}Reconnaissance des chiffres sur les cases}{9}{subsection.4.3} 18 | \contentsline {section}{\numberline {5}R\IeC {\'e}solution de la grille de Sudoku}{10}{section.5} 19 | \contentsline {section}{\numberline {6}\'{E}lectronique et contr\IeC {\^o}le du d\IeC {\'e}placement des moteurs}{12}{section.6} 20 | \contentsline {subsection}{\numberline {6.1}Choix de conception}{12}{subsection.6.1} 21 | \contentsline {subsection}{\numberline {6.2}Choix des composants}{13}{subsection.6.2} 22 | \contentsline {subsection}{\numberline {6.3}Contr\IeC {\^o}le des moteurs}{13}{subsection.6.3} 23 | \contentsline {subsection}{\numberline {6.4}Carte PCB}{14}{subsection.6.4} 24 | \contentsline {part}{III\hspace {1em}R\IeC {\'e}solution de la grille: Boucle ferm\IeC {\'e}e}{14}{part.3} 25 | \contentsline {section}{\numberline {7}Tracking}{15}{section.7} 26 | \contentsline {section}{\numberline {8}Boucler la boucle}{16}{section.8} 27 | -------------------------------------------------------------------------------- /Ressources/Rapport final/gantt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/gantt.png -------------------------------------------------------------------------------- /Ressources/Rapport final/hg1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/hg1.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/hough.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/hough.png -------------------------------------------------------------------------------- /Ressources/Rapport final/k1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/k1.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/k2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/k2.png -------------------------------------------------------------------------------- /Ressources/Rapport final/lign_degra.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/lign_degra.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/logo_phelma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/logo_phelma.png -------------------------------------------------------------------------------- /Ressources/Rapport final/pcb.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/pcb.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/poster_sudoku_sicom2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/poster_sudoku_sicom2a.png -------------------------------------------------------------------------------- /Ressources/Rapport final/pp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/pp.jpg -------------------------------------------------------------------------------- /Ressources/Rapport final/rapport_final_sudoku_sicom2a.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/rapport_final_sudoku_sicom2a.pdf -------------------------------------------------------------------------------- /Ressources/Rapport final/rec.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/rec.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/reco.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/reco.PNG -------------------------------------------------------------------------------- /Ressources/Rapport final/test.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/test.out -------------------------------------------------------------------------------- /Ressources/Rapport final/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/test.pdf -------------------------------------------------------------------------------- /Ressources/Rapport final/test.synctex.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/Rapport final/test.synctex.gz -------------------------------------------------------------------------------- /Ressources/Rapport final/test.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt]{article} 2 | \usepackage{makeidx} 3 | \usepackage{multirow} 4 | \usepackage{multicol} 5 | \usepackage[dvipsnames,svgnames,table]{xcolor} 6 | \usepackage{graphicx} 7 | \usepackage{epstopdf} 8 | \usepackage[utf8]{inputenc} 9 | \usepackage{ulem} 10 | \usepackage{import} 11 | \usepackage{hyperref} 12 | \usepackage{amsmath} 13 | \usepackage{amssymb} 14 | \usepackage{tikz} 15 | \usepackage{pgfplots} 16 | \usepackage[francais]{babel} 17 | \usepackage{pgf} 18 | \usetikzlibrary{plotmarks} 19 | \usetikzlibrary{matrix,shapes,arrows,positioning,chains,automata} 20 | \author{Mohamed SANA} 21 | \title{} 22 | \usepackage[paperwidth=595pt,paperheight=841pt,top=49pt,right=70pt,bottom=35pt,left=70pt]{geometry} 23 | \makeatletter 24 | \newenvironment{indentation}[3] 25 | {\par\setlength{\parindent}{#3} 26 | \setlength{\leftmargin}{#1} \setlength{\rightmargin}{#2} 27 | \advance\linewidth -\leftmargin \advance\linewidth -\rightmargin 28 | \advance\@totalleftmargin\leftmargin \@setpar{{\@@par}} 29 | \parshape 1\@totalleftmargin \linewidth\ignorespaces}{\par} 30 | \makeatother 31 | \begin{document} 32 | \fbox{ 33 | \pagestyle{empty} 34 | \def\layersep{2.5cm} 35 | \begin{tikzpicture}[shorten >=1pt,->,draw=black!50, node distance=\layersep] 36 | \tikzstyle{every pin edge}=[<-,shorten <=1pt] 37 | \tikzstyle{neuron}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt] 38 | \tikzstyle{input neuron}=[neuron, fill=green!50]; 39 | \tikzstyle{output neuron}=[neuron, fill=red!50]; 40 | \tikzstyle{hidden neuron}=[neuron, fill=blue!50]; 41 | \tikzstyle{annot} = [text width=4em, text centered] 42 | 43 | 44 | % Draw the input layer nodes 45 | \foreach \name / \y in {1,...,4} 46 | % This is the same as writing \foreach \name / \y in {1/1,2/2,3/3,4/4} 47 | \node[input neuron, pin=left:Input \#\y] (I-\name) at (0,-\y) {}; 48 | 49 | % Draw the hidden layer nodes 50 | \foreach \name / \y in {1,...,5} 51 | \path[yshift=0.5cm] 52 | node[hidden neuron] (H-\name) at (\layersep,-\y cm) {}; 53 | 54 | % Draw the output layer node 55 | \node[output neuron,pin={[pin edge={->}]right:Output}, right of=H-3] (O) {}; 56 | 57 | % Connect every node in the input layer with every node in the 58 | % hidden layer. 59 | \foreach \source in {1,...,4} 60 | \foreach \dest in {1,...,5} 61 | \path (I-\source) edge (H-\dest); 62 | 63 | % Connect every node in the hidden layer with the output layer 64 | \foreach \source in {1,...,5} 65 | \path (H-\source) edge (O); 66 | 67 | % Annotate the layers 68 | \node[annot,above of=H-1, node distance=1cm] (hl) {Hidden layer}; 69 | \node[annot,left of=hl] {Input layer}; 70 | \node[annot,right of=hl] {Output layer}; 71 | \end{tikzpicture} 72 | } 73 | \end{document} -------------------------------------------------------------------------------- /Ressources/livrable-mi-projet-sudoku-groupe3.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/livrable-mi-projet-sudoku-groupe3.rar -------------------------------------------------------------------------------- /Ressources/mi-rapport/Readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/mi-rapport/Readme.txt -------------------------------------------------------------------------------- /Ressources/mi-rapport/mi-rapport-sudoku-sicomb.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/mi-rapport/mi-rapport-sudoku-sicomb.docx -------------------------------------------------------------------------------- /Ressources/mi-rapport/mi-rapport-sudoku-sicomb.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/mi-rapport/mi-rapport-sudoku-sicomb.pdf -------------------------------------------------------------------------------- /Ressources/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/readme.txt -------------------------------------------------------------------------------- /Ressources/sud-generation/Readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sanahm/Sudoku-robot/7f802baffdd9cf6b3589443d1c3ebfa1f7a46d0d/Ressources/sud-generation/Readme.txt -------------------------------------------------------------------------------- /Ressources/sud-generation/generation.tex: -------------------------------------------------------------------------------- 1 | % Sudoku 2 | % Author: Roberto Bonvallet 3 | \documentclass[convert={density=300,size=28x28,outext=.png}]{standalone} 4 | \usepackage[pdftex,active,tightpage]{preview} 5 | \usepackage{tikz} 6 | \usepackage{mathpazo} 7 | \PreviewEnvironment{tikzpicture} 8 | \newcounter{row} 9 | \newcounter{col} 10 | 11 | \newcommand\setrow[9]{ 12 | \setcounter{col}{1} 13 | \foreach \n in {#1, #2, #3, #4, #5, #6, #7, #8, #9} { 14 | \edef\x{\value{col} - 0.5} 15 | \edef\y{9.5 - \value{row}} 16 | \node[anchor=center] at (\x, \y) {\n}; 17 | \stepcounter{col} 18 | } 19 | \stepcounter{row} 20 | } 21 | 22 | \begin{document} 23 | \begin{tikzpicture}[scale=.5] %change la taille 24 | 25 | \begin{scope} 26 | \draw (0, 0) grid (9, 9); 27 | \draw[very thick, scale=3] (0, 0) grid (3, 3); %pemet de foncer les lignes 28 | 29 | \setcounter{row}{1} 30 | \setrow {\textit{4} }{{}}{ } {{}}{}{{}} { }{{}}{\textit{8} } 31 | \setrow {{}}{ }{ 1} {{}}{ }{{}} { 2}{ }{{}} 32 | \setrow { }{{\textit{5}}}{ } {\textit{9} }{{{}}}{3 } { }{{\textit{4}}}{ } 33 | 34 | \setrow { 1}{ }{{{}}} { }{6 }{ } {{{}}}{ }{ \textbf{9}} 35 | \setrow {{{}}}{{{\textit{7}}}}{ } {}{ }{ } { }{{{8}}}{{{}}} 36 | \setrow {3 }{ }{{{}}} {5 }{ }{7} {{{}}}{1 }{ } 37 | 38 | \setrow { }{\textit{9}}{ } {4 }{{{}}}{8 } { }{{{1}}}{ } 39 | \setrow {{{}}}{ }{ 5} {{{}}}{ }{{{}}} {\textit{7} }{ }{{{}}} 40 | \setrow { \textit{2}}{{{}}}{ } {{{}}}{ }{{{}}} { }{{{}}}{\textit{4 }} 41 | 42 | % \node[anchor=center] at (4.5, -0.5) {Unsolved Sudoku}; 43 | \end{scope} 44 | 45 | \begin{scope}[xshift=12cm] 46 | %\draw (0, 0) ;\node[anchor=center] at (0.42, 0.42) {{{0}}}; 47 | %\draw (0, 0) ;\node[anchor=center] at (0.42, 0.42) {{0}}; 48 | %\draw (0, 0) ;\node[anchor=center] at (0.42, 0.42) {{\textrm{0}}}; 49 | % \draw[very thick, scale=3] (0, 0) grid (3, 3); 50 | % 51 | 52 | % \setcounter{row}{1} 53 | % \setrow { }{2}{ } {5}{ }{1} { }{9}{ } 54 | % \setrow {8}{ }{ } {2}{ }{3} { }{ }{6} 55 | % \setrow { }{3}{ } { }{6}{ } { }{7}{ } 56 | % 57 | % \setrow { }{ }{1} { }{ }{ } {6}{ }{ } 58 | % \setrow {5}{4}{ } { }{ }{ } { }{1}{9} 59 | % \setrow { }{ }{2} { }{ }{ } {7}{ }{ } 60 | % 61 | % \setrow { }{9}{ } { }{3}{ } { }{8}{ } 62 | % \setrow {2}{ }{ } {8}{ }{4} { }{ }{7} 63 | % \setrow { }{1}{ } {9}{ }{7} { }{6}{ } 64 | % 65 | % \node[anchor=center] at (4.5, -0.5) {Solved Sudoku}; 66 | % 67 | % \begin{scope}[blue, font=\sffamily\slshape] 68 | % \setcounter{row}{1} 69 | % \setrow {4}{ }{6} { }{7}{ } {3}{ }{8} 70 | % \setrow { }{5}{7} { }{9}{ } {1}{4}{ } 71 | % \setrow {1}{ }{9} {4}{ }{8} {2}{ }{5} 72 | % 73 | % \setrow {9}{7}{ } {3}{8}{5} { }{2}{4} 74 | % \setrow { }{ }{3} {7}{2}{6} {8}{ }{ } 75 | % \setrow {6}{8}{ } {1}{4}{9} { }{5}{3} 76 | % 77 | % \setrow {7}{ }{4} {6}{ }{2} {5}{ }{1} 78 | % \setrow { }{6}{5} { }{1}{ } {9}{3}{ } 79 | % \setrow {3}{ }{8} { }{5}{ } {4}{ }{2} 80 | % \end{scope} 81 | 82 | \end{scope} 83 | 84 | 85 | \end{tikzpicture} 86 | 87 | pdftoppm -jpeg -r 300 generation.pdf > tt.jpeg 88 | \end{document} --------------------------------------------------------------------------------