Unverified Commit 210421f7 authored by tilman's avatar tilman
Browse files

inbetween commit

parent e8cfa982
# From Python
import sys
import cv2
import numpy as np
import os
from sys import platform
from openpose import pyopenpose as op
from lib.triangles import *
from lib.bisection import *
from lib.misc import *
BISEC_VECTORS = True
CORRECTION_ANGLE = 0
img_name = "/Users/Tilman/Documents/Programme/Python/forschungspraktikum/art-structures-env/src/images/images_imdahl/Judas_und_Christus.jpg"
pose = np.array([[4.7613028e+02,3.3695804e+02,9.0203685e-01],[5.3667474e+02,3.8633786e+02,6.6615295e-01],[5.1645105e+02,3.8405157e+02,5.1514143e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.5459924e+02,3.8859457e+02,6.4240879e-01],[5.6353766e+02,4.7384988e+02,1.8810490e-01],[5.3886292e+02,5.2543573e+02,9.0144195e-02],[5.4566248e+02,5.3215259e+02,3.6083767e-01],[5.2768524e+02,5.3213129e+02,3.1196830e-01],[5.4556714e+02,6.3534674e+02,1.8182488e-01],[5.8149310e+02,7.2958716e+02,1.3625422e-01],[5.6579541e+02,5.3216382e+02,3.6866242e-01],[5.8822272e+02,6.2862476e+02,1.7708556e-01],[6.0843213e+02,7.2955762e+02,2.2736737e-01],[4.7597812e+02,3.2798129e+02,5.7176876e-01],[4.8729745e+02,3.3027243e+02,9.1296065e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.2090784e+02,3.3472034e+02,7.7942842e-01],[5.7928674e+02,7.5646222e+02,2.0351715e-01],[5.9049512e+02,7.5648248e+02,2.0819387e-01],[6.2183606e+02,7.3853394e+02,1.7312977e-01],[5.8145673e+02,7.5420642e+02,1.2660497e-01],[5.7701074e+02,7.5417773e+02,1.2881383e-01],[5.8374255e+02,7.3627380e+02,9.4869599e-02]])
# pose = np.array([[5.3406028e+02,3.3695804e+02,9.0203685e-01],[5.3667474e+02,3.8633786e+02,6.6615295e-01],[5.1645105e+02,3.8405157e+02,5.1514143e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.5459924e+02,3.8859457e+02,6.4240879e-01],[5.6353766e+02,4.7384988e+02,1.8810490e-01],[5.3886292e+02,5.2543573e+02,9.0144195e-02],[5.4566248e+02,5.3215259e+02,3.6083767e-01],[5.2768524e+02,5.3213129e+02,3.1196830e-01],[5.4556714e+02,6.3534674e+02,1.8182488e-01],[5.8149310e+02,7.2958716e+02,1.3625422e-01],[5.6579541e+02,5.3216382e+02,3.6866242e-01],[5.8822272e+02,6.2862476e+02,1.7708556e-01],[6.0843213e+02,7.2955762e+02,2.2736737e-01],[4.7597812e+02,3.2798129e+02,5.7176876e-01],[4.8729745e+02,3.3027243e+02,9.1296065e-01],[0.0000000e+00,0.0000000e+00,0.0000000e+00],[5.2090784e+02,3.3472034e+02,7.7942842e-01],[5.7928674e+02,7.5646222e+02,2.0351715e-01],[5.9049512e+02,7.5648248e+02,2.0819387e-01],[6.2183606e+02,7.3853394e+02,1.7312977e-01],[5.8145673e+02,7.5420642e+02,1.2660497e-01],[5.7701074e+02,7.5417773e+02,1.2881383e-01],[5.8374255e+02,7.3627380e+02,9.4869599e-02]])
img = cv2.imread(img_name)
bisecVector = poseToBisectVector(pose, CORRECTION_ANGLE)
cv2.arrowedLine(img, trp(bisecVector[1]), trp(bisecVector[0]), (0,0,255), 2)
cv2.arrowedLine(img, trp(pose[1]), trp(pose[0]), (0,255,0), 2)
cv2.arrowedLine(img, trp(pose[1]), trp(pose[8]), (0,255,0), 2)
cv2.namedWindow(img_name, cv2.WINDOW_NORMAL)
cv2.imshow(img_name, img)
cv2.waitKey(0)
cv2.destroyAllWindows()
\ No newline at end of file
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.2 + overlay * 0.2).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)
maxlevel = max(map(lambda t: len(t), intersections.keys()))
for combi in intersections:
#overlay = orig.copy()
is_not_last_level = len(combi) < maxlevel
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)
if not is_not_last_level: #draw centroid of last polygon
xy = (int(intersections[combi].centroid.x),int(intersections[combi].centroid.y))
cv2.circle(overlay, xy, 10, (0,255,0), -1)
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment