Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
ws1617:bilder_zu_bildern:protokolle:170202 [2017/02/02 17:42] Chai_Tee.95-Cara |
ws1617:bilder_zu_bildern:protokolle:170202 [2017/03/24 18:20] (aktuell) Chai_Tee.95-Cara |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
=== Protokoll vom 2. Februar 2017 === | === Protokoll vom 2. Februar 2017 === | ||
+ | |||
+ | Das folgende Programm liest ein Bild ein (Webcam) und findet Konturen darin, indem es nach Niveaulinien sucht (siehe letzte Woche). Die Funktion Isolux liefert eine Liste "res2", die alle Konturen unter der Voraussetzung, dass sie länger als 15 Punkte sind, auflistet. | ||
<code python> | <code python> | ||
- | dgfdb | + | #Niveaulinien-Programm |
+ | import numpy as np | ||
+ | import matplotlib.pyplot as plt | ||
+ | from scipy import misc, ndimage, signal | ||
+ | import cv2 | ||
+ | import scipy.misc as misc | ||
+ | import skimage.color as color | ||
+ | |||
+ | #bild=misc.imread('hund_mittel_kl.jpg') # bild einlesen | ||
+ | |||
+ | cap = cv2.VideoCapture(0) #bei kamera | ||
+ | res, bild2 = cap.read() #bei kamera | ||
+ | |||
+ | imgray = color.rgb2gray(bild2) | ||
+ | |||
+ | from skimage.measure import find_contours | ||
+ | res = [] | ||
+ | for value in np.linspace(np.min(imgray), np.max(imgray),10): | ||
+ | res.extend(find_contours(imgray,value)) | ||
+ | |||
+ | for cont in res: | ||
+ | print cont.shape | ||
+ | |||
+ | cap.release() | ||
+ | |||
+ | def Isolux(): | ||
+ | #a_als_farbbild = cv2.cvtColor(a, cv2.COLOR_GRAY2BGR) | ||
+ | res2 = [] | ||
+ | for cont in res: | ||
+ | if cont.shape[0]>15: #and ... Fkt.Check | ||
+ | for i,j in cont: | ||
+ | cv2.circle(bild2,(int(round(j)),int(round(i))),1,(1,0,0),-1) | ||
+ | res2.append(cont) | ||
+ | cv2.imshow("Bild:",bild) | ||
+ | cv2.waitKey(0) | ||
+ | cv2.destroyAllWindows() | ||
+ | return res2 | ||
+ | |||
+ | res2 = Isolux() | ||
</code> | </code> | ||
+ | |||
+ | Ergebnis: \\ | ||
+ | {{feb_2.png}} | ||
+ | |||
+ | ---- | ||
+ | |||
+ | To Do:\\ | ||
+ | * Funktion schreiben, die die res2 Inhalte und die Inhalte des Kantenprogramms einbindet und eine Liste ausgibt, die gute Konturen liefert ✔ | ||
+ | * Turtle läuft diese Konturen ab ✔ | ||
+ | * Turtle.mod nutzen ✔ | ||
+ |