Bonjour !

Je continue ma quête dans le merveilleux monde d'OPenCV python et tkinter et je pense avoir enfin réussi à coder quelque chose de pas mal mais cela bug sans afficher d'erreur et je ne vois pas trop le problème .. (le but est d'afficher dans deux fenetres différentes ma tête capté par a webcam en noir et blanc et dans l'autre fenetre la video originale).

J'ai mis de "mouchards" dans mon code pour voir si ça allait bien où je voulais et oui ..

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import cv2
import numpy as np
 
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
from Tkinter import *
from PIL import Image
from PIL import ImageTk
import tkFileDialog
from tkMessageBox import *
 
 
 
def live():
 
        # grab a reference to the image panels
        global panelA, panelB
 
        cap = cv2.VideoCapture(0)
        print "Coucou1"
        while 1:
 
                ret, image = cap.read()
                gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
                image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
 
                retval, threshold = cv2.threshold(gray, 40, 255, cv2.THRESH_BINARY)
 
                # convert the images to PIL format...
                image = Image.fromarray(image)
                threshold = Image.fromarray(threshold)
                print "Niveau 1"
 
                # ...and then to ImageTk format
                image = ImageTk.PhotoImage(image)
                threshold = ImageTk.PhotoImage(threshold)
                print "Niveau 2"
 
 
		# if the panels are None, initialize them
                if panelA is None or panelB is None:
			# the first panel will store our original image
                        panelA = Label(image=image)
                        panelA.image = image
                        panelA.pack(side="left", padx=10, pady=10)
 
			# while the second panel will store the edge map
                        panelB = Label(image=threshold)
                        panelB.image = threshold
                        panelB.pack(side="right", padx=10, pady=10)
                        print "Niveau 3"
 
		# otherwise, update the image panels
                else:
			# update the pannels
                        panelA.configure(image=image)
                        panelB.configure(image=threshold)
                        panelA.image = image
                        panelB.image = threshold
                        print "Niveau4"
 
 
 
                print "Niveau 5"
                k = cv2.waitKey(30) & 0xff
                if k == 27:
                        print "Au revoir3"
                        break
 
        cap.release()
        cv2.destroyAllWindows()
 
# initialize the window toolkit along with the two image panels
root = Tk()
 
panelA = None
panelB = None
 
# create a button, then when pressed, will trigger a file chooser
# dialog and allow the user to select an input image; then add the
# button the GUI
btn = Button(root, text="Demarrer le programme", command=live)
btn.pack(side="bottom", fill="both", expand="yes", padx="10", pady="10")
 
# bouton de sortie
bouton=Button(root, text="Fermer", command=root.destroy)
bouton.pack()
 
# kick off the GUI
root.mainloop()
Merci d'avance pour vos réponses parce que là j'ai vraiment besoin de vous !!