class IP_Cam: [...] def gotoMatrixElement(self, x, y): if y<2: dv=self.UP else: dv=self.DOWN if x<2: dh=self.LEFT else: dh=self.RIGHT if y in (0, 3): tv=0.57 # 1.5 Felder rauf/runter else: tv=0.23 # 0.5 Felder rauf/runter if x in (0, 3): th=2.3 # 1.5 Felder links/rechts else: th=0.86 # 0.5 Felder links/rechts self.gotoDirection(dv, tv) self.gotoDirection(dh, th) # ########################################################### # Main if __name__=="__main__": cam=IP_Cam() img1=cam.getImageGrayscale() while True: time.sleep(0.2) img2=cam.getImageGrayscale() diff=cam.removeNoise(img1-img2, 32) s=np.sum(diff) if s>500000: p_mh, p_mv=findBrightestArea(diff) print(p_mh, p_mv) cam.gotoMatrixElement(p_mh, p_mv) time.sleep(0.2) img2=cam.getImageGrayscale() img1=img2 |
a=np.array([[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]]) print(a) print(a[0:3, 0:3]) print(a[2:4, 2:4]) |
Sehr schön.
[[ 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]]
[[ 1 2 3]
[ 6 7 8]
[11 12 13]]
[[13 14]
[18 19]]
if
__name__=="__main__": cam=IP_Cam() img=cam.getImageGrayscale() cx=7 # Anzahl Elemente auf der X-Achse cy=5 # Anzahl Elemente auf der Y-Achse w=91 # Breite eines Elements h=96 # Höhe eines Elements print(img.shape) for y in range(cy): for x in range(cx): elem=img[y*h:y*h+h, 1+x*w:1+x*w+w] cam.saveImage(elem, "m%d%d"%(x,y)) |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |