Commit 702b15cd by tilman

### add new bise cone work

 ... @@ -3,7 +3,7 @@ ... @@ -3,7 +3,7 @@ import cv2 import cv2 import numpy as np import numpy as np import numpy.linalg as la import numpy.linalg as la from scipy import stats from shapely.geometry import Polygon from lib.bisection import * from lib.bisection import * ... @@ -40,14 +40,25 @@ print("distance",dist1,dist2) ... @@ -40,14 +40,25 @@ print("distance",dist1,dist2) angle = getAngle(a,b,c) angle = getAngle(a,b,c) print(np.degrees(angle)) #degress print(np.degrees(angle)) #degress print(angle) #radians print(angle) #radians pd = getBisecPoint(a,b,c) #pd = getBisecPoint(a,b,c) print(pd) pd1, pd2 = getBisecCone(a,b,c,np.deg2rad(30)) img = cv2.imread("/Users/Tilman/Documents/Programme/Python/forschungspraktikum/openpose/examples/media/art/28165_gw.jpg") #cone = np.array([pd1, pd2, b]) conePoly = Polygon([pd1, pd2, b]) #print(cone) print(polyToArr(conePoly)) img = cv2.imread("/Users/Tilman/Documents/Programme/Python/forschungspraktikum/openpose/examples/media/art/page_5_item_17_annunci1.jpg") cv2.namedWindow("test", cv2.WINDOW_NORMAL) cv2.namedWindow("test", cv2.WINDOW_NORMAL) cv2.line(img, pa, pb, (0,255,0)); cv2.line(img, pa, pb, (0,255,0)); cv2.line(img, pb, pc, (0,255,0)); cv2.line(img, pb, pc, (0,255,0)); cv2.line(img, pb, pd, (0,0,255)); cv2.line(img, pb, pd1, (0,0,255)); cv2.line(img, pb, pd2, (0,0,255)); print(len(img)) print(len(img[0])) mainCanvas = Polygon(((0,len(img)), (0,0), (len(img[0]),0), (len(img[0]),len(img)))) cv2.drawContours(img, [polyToArr(conePoly)], 0, 255, -1) cv2.drawContours(img, [polyToArr(mainCanvas)], 0, 255, -1) cv2.imshow("test", img) cv2.imshow("test", img) ... ...
conesTest.py 0 → 100644
 #np.array([[[-842,975],[-960,467],[ 536,386],[-842,975]],[[-685, 1038],[-823,535],[ 669,397],[-685, 1038]],[[-524, 1232],[- from shapely.geometry import Polygon import numpy as np import itertools import cv2 from lib.bisection import * def overlay_two_image_v2(image, overlay, ignore_color=[0,0,0]): ignore_color = np.asarray(ignore_color) mask = (overlay==ignore_color).all(-1,keepdims=True) out = np.where(mask,image,(image * 0.5 + overlay * 0.5).astype(image.dtype)) return out bisecCones = np.array([ Polygon([[-719, 1205], [-952, 207], [ 536, 386], [-719, 1205]]), Polygon([[-554, 1264], [-824, 275], [ 669, 397], [-554, 1264]]), Polygon([[-371, 1444], [-738, 486], [ 760, 460], [-371, 1444]]), Polygon([[1473, 1200], [ 653, 1818], [ 215, 384], [1473, 1200]]) ]) img_name = "/Users/Tilman/Documents/Programme/Python/forschungspraktikum/art-structures-env/src/images/images_imdahl/Judas_und_Christus.jpg" img = cv2.imread(img_name) orig = img.copy() def overlay_two_image_v2(image, overlay, ignore_color=[0,0,0]): ignore_color = np.asarray(ignore_color) mask = (overlay==ignore_color).all(-1,keepdims=True) out = np.where(mask,image,(image * 0.5 + overlay * 0.5).astype(image.dtype)) return out intersections = coneIntersections(bisecCones) for combi in intersections: #overlay = orig.copy() overlay = np.zeros((len(img),len(img[0]),3), np.uint8) color = min(((len(combi)-2)*150,255)) cv2.drawContours(overlay, [polyToArr(intersections[combi])], 0, (color,0,255), -1) #cv2.addWeighted(overlay, 0.5, img, 1 - 0.5, 0, img) img = overlay_two_image_v2(img, overlay, [0,0,0]) cv2.namedWindow(img_name, cv2.WINDOW_NORMAL) cv2.imshow(img_name, img) cv2.waitKey(0) cv2.destroyAllWindows() \ No newline at end of file
 ... @@ -15,9 +15,21 @@ SHOW_WINDOW = True ... @@ -15,9 +15,21 @@ SHOW_WINDOW = True SAVE_FILE = False SAVE_FILE = False TRIANGLES = True TRIANGLES = True BISEC_VECTORS = True BISEC_VECTORS = True OUT_DIR = 'images/out/first_email/' BISEC_CONES = True BISEC_CONE_ANGLE = 40 OUT_DIR = 'images/out/images_imdahl/' #IN_DIR = "images/first_email/" # images from first email #IN_DIR = "images/first_email/" # images from first email IN_DIR = "images/first_email/" # images from imdahl IN_DIR = "images/images_imdahl/" # images from imdahl ## misc functions def overlay_two_image_v2(image, overlay, ignore_color=[0,0,0]): ignore_color = np.asarray(ignore_color) mask = (overlay==ignore_color).all(-1,keepdims=True) out = np.where(mask,image,(image * 0.5 + overlay * 0.5).astype(image.dtype)) return out ## misc functions end params = dict() params = dict() #params["model_folder"] = "/Users/Tilman/Documents/Programme/Python/forschungspraktikum/openpose/models/" #params["model_folder"] = "/Users/Tilman/Documents/Programme/Python/forschungspraktikum/openpose/models/" ... @@ -41,20 +53,42 @@ for img_name in images: ... @@ -41,20 +53,42 @@ for img_name in images: datum.cvInputData = img datum.cvInputData = img opWrapper.emplaceAndPop([datum]) opWrapper.emplaceAndPop([datum]) #img = datum.cvOutputData img = datum.cvOutputData overlay = img.copy() #print("poses:"+str(len(datum.poseKeypoints))) #print("poses:"+str(len(datum.poseKeypoints))) if TRIANGLES: if TRIANGLES: triangles = [poseToTriangle(pose) for pose in datum.poseKeypoints] triangles = [poseToTriangle(pose) for pose in datum.poseKeypoints] for triangle in triangles: for triangle in triangles: if triangle is not None: if triangle is not None: cv2.drawContours(img, [triangle], 0, 255, -1) cv2.drawContours(overlay, [triangle], 0, 255, -1) if BISEC_VECTORS: if BISEC_VECTORS: bisecVectors= [poseToBisectVector(pose) for pose in datum.poseKeypoints] bisecVectors = [poseToBisectVector(pose) for pose in datum.poseKeypoints] for bisecVector in bisecVectors: for bisecVector in bisecVectors: if bisecVector is not None: if bisecVector is not None: cv2.arrowedLine(img, trp(bisecVector[1]), trp(bisecVector[0]), (0,0,255), 2); cv2.arrowedLine(overlay, trp(bisecVector[1]), trp(bisecVector[0]), (0,0,255), 2) if BISEC_CONES: bisecCones = [poseToBisectCone(pose, BISEC_CONE_ANGLE) for pose in datum.poseKeypoints] print([polyToArr(bisecCone) for bisecCone in bisecCones]) # for bisecCone in bisecCones: # if bisecCone is not None: # cv2.drawContours(overlay, [polyToArr(bisecCone)], 0, (0,0,255), -1) # mainCanvas = Polygon(((0,len(img)), (0,0), (len(img[0]),0), (len(img[0]),len(img)))) # for cone in bisecCones: # if cone is not None: # mainCanvas = mainCanvas.intersection(cone) # if not mainCanvas.is_empty: # cv2.drawContours(overlay, [polyToArr(mainCanvas)], 0, (255,255,0), -1) intersections = coneIntersections(bisecCones) for combi in intersections: #overlay = orig.copy() overlay = np.zeros((len(img),len(img[0]),3), np.uint8) color = min(((len(combi)-2)*150,255)) cv2.drawContours(overlay, [polyToArr(intersections[combi])], 0, (color,0,255), -1) #cv2.addWeighted(overlay, 0.5, img, 1 - 0.5, 0, img) img = overlay_two_image_v2(img, overlay, [0,0,0]) cv2.addWeighted(overlay, 0.5, img, 1 - 0.5, 0, img) if SAVE_FILE: if SAVE_FILE: cv2.imwrite(os.path.basename(img_name),img) cv2.imwrite(os.path.basename(img_name),img) if SHOW_WINDOW: if SHOW_WINDOW: ... ...

946 KB | W: | H:

527 KB | W: | H:

• 2-up
• Swipe
• Onion skin

231 KB | W: | H:

428 KB | W: | H:

• 2-up
• Swipe
• Onion skin

523 KB | W: | H:

360 KB | W: | H:

• 2-up
• Swipe
• Onion skin

190 KB | W: | H:

97.1 KB | W: | H:

• 2-up
• Swipe
• Onion skin

160 KB | W: | H:

81.8 KB | W: | H:

• 2-up
• Swipe
• Onion skin

396 KB | W: | H:

188 KB | W: | H:

• 2-up
• Swipe
• Onion skin

310 KB | W: | H:

160 KB | W: | H:

• 2-up
• Swipe
• Onion skin

350 KB | W: | H:

181 KB | W: | H:

• 2-up
• Swipe
• Onion skin

173 KB | W: | H:

87.9 KB | W: | H:

• 2-up
• Swipe
• Onion skin

474 KB | W: | H:

855 KB | W: | H:

• 2-up
• Swipe
• Onion skin

1.15 MB | W: | H:

665 KB | W: | H:

• 2-up
• Swipe
• Onion skin

180 KB | W: | H:

121 KB | W: | H:

• 2-up
• Swipe
• Onion skin

149 KB | W: | H:

94.4 KB | W: | H:

• 2-up
• Swipe
• Onion skin
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!