Python, Cv2, numpy to indicate areas in a picture/image -


i want specify areas in image.

to specify 1 area can this:

import cv2 import numpy np  the_picture = cv2.imread("c:\\picture.jpg")  target_area = the_picture[300:360, 130:280] 

the type of target_area type 'numpy.ndarray'.

but list of coordinates problem. struggling in turning list of coordinates values required.

what want is:

the_picture = cv2.imread("c:\\picture.jpg")  list_of_areas = [ [300:360 , 130:280] [300:360 , 440:540] [400:460 , 0:130] [400:460 , 250:400] [400:460 , 560:740]  area in list_of_areas:     the_picture(area)     ### failed 

here coordinates:

        x   y       x1  y1  area1   130 300     280 360 area2   440 300     540 360 area3   0   400     130 460 area4   250 400     400 460 area5   560 400     740 460 

i tried give list below doesn’t work. tried make them strings in list, changed square brackets round brackets neither worked.

syntaxerror: invalid syntax 

what’s proper way give coordinates?

if understood correctly want do, , please correct me if i'm wrong, solve problem saving , retrieving area coordinates individual values, , not pairs

the_picture = cv2.imread("c:\\picture.jpg")  list_of_areas = [ [300, 360, 130, 280], [300, 360, 440, 540], [400, 460, 0, 130], [400, 460 , 250, 400], [400, 460, 560, 740]]  y,y1,x,x1 in list_of_areas:     the_picture[y:y1, x:x1] 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -