diff --git a/single_versions_for_3de_online_db_scripts/xg_delete_2d_curve.py b/single_versions_for_3de_online_db_scripts/xg_delete_2d_curve.py new file mode 100644 index 0000000..dfc3945 --- /dev/null +++ b/single_versions_for_3de_online_db_scripts/xg_delete_2d_curve.py @@ -0,0 +1,29 @@ +# +# +# 3DE4.script.name: Delete 2d Curve +# +# 3DE4.script.version: v1.0 +# +# 3DE4.script.gui: Manual Tracking::Edit +# 3DE4.script.gui: Object Browser::Context Menu Point +# +# 3DE4.script.comment: Delete 2d curve +# +# Giovanni Di Grezia 2016 +# http://www.xgiovio.com +# + +cam = tde4.getCurrentCamera() +current_point_group = tde4.getCurrentPGroup() +selected_points = tde4.getPointList (current_point_group,1) + +for point in selected_points: + tde4.deletePointCurve2D (current_point_group,point,cam) + + + + + + + + diff --git a/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points.py b/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points.py new file mode 100644 index 0000000..98af3d9 --- /dev/null +++ b/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points.py @@ -0,0 +1,66 @@ +# +# +# 3DE4.script.name: Average each 2 points 2D +# +# 3DE4.script.version: v1.0 +# +# 3DE4.script.comment: Average each 2 2D points +# +# 3DE4.script.gui: Manual Tracking Controls::Fill2D +# 3DE4.script.hide: false +# 3DE4.script.startup: false +# +# Giovanni Di Grezia 2016 +# http://www.xgiovio.com +# + +import itertools + +def average_each_2_points (dist = False): + cam = tde4.getCurrentCamera() + playback = tde4.getCameraPlaybackRange(cam) + firstframe = playback[0] + lastframe = playback[1] + current_point_group = tde4.getCurrentPGroup() + selected_points = tde4.getPointList (current_point_group,1) + if (len(selected_points) < 2): + tde4.postQuestionRequester("Info","You need to select 2 or more 2D points","OK") + else: + exit = 0 + tde4.postProgressRequesterAndContinue("Calculating","Computing Points",100,"Cancel") + couples_selected_points = list(itertools.combinations(selected_points,2)) + counter = 0 + for i in couples_selected_points: + if exit == 1: + break + avg = tde4.createPoint (current_point_group) + aname = tde4.getPointName(current_point_group,i[0]) + bname = tde4.getPointName(current_point_group,i[1]) + tde4.setPointName(current_point_group,avg, "AVG_" + aname + "_" + bname) + for frame in range (firstframe, lastframe + 1): + counter+=1 + percentage = (100 * counter) / (len(couples_selected_points) * (lastframe + 1 - firstframe)) + status = tde4.updateProgressRequester(percentage,str(percentage) + " % - Frame " + str(frame) + " Point AVG_" + aname + "_" + bname) + if status != -1: + exit = 1 + break + apos = tde4.getPointPosition2D (current_point_group,i[0],cam,frame) + if dist: + apos = tde4.removeDistortion2D(cam,frame,apos) + avalid =tde4.isPointPos2DValid(current_point_group,i[0],cam,frame) + aposx = apos[0] + aposy = apos[1] + bpos = tde4.getPointPosition2D (current_point_group,i[1],cam,frame) + if dist: + bpos = tde4.removeDistortion2D(cam,frame,bpos) + bvalid =tde4.isPointPos2DValid(current_point_group,i[1],cam,frame) + bposx = bpos[0] + bposy = bpos[1] + if avalid and bvalid: + avgpos = [ aposx + ( (bposx - aposx) / 2 ) , aposy + ( (bposy - aposy) / 2 ) ] + if dist: + avgpos = tde4.applyDistortion2D(cam,frame,avgpos) + tde4.setPointPosition2D (current_point_group,avg,cam,frame,avgpos) + + +average_each_2_points (dist = False) \ No newline at end of file diff --git a/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points_dist.py b/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points_dist.py new file mode 100644 index 0000000..eafa687 --- /dev/null +++ b/single_versions_for_3de_online_db_scripts/xg_fill2d_average_each_2_points_dist.py @@ -0,0 +1,66 @@ +# +# +# 3DE4.script.name: Average each 2 points 2D with Dist +# +# 3DE4.script.version: v1.0 +# +# 3DE4.script.comment: Average each 2 2D points with Distortion +# +# 3DE4.script.gui: Manual Tracking Controls::Fill2D +# 3DE4.script.hide: false +# 3DE4.script.startup: false +# +# Giovanni Di Grezia 2016 +# http://www.xgiovio.com +# + +import itertools + + +def average_each_2_points (dist = False): + cam = tde4.getCurrentCamera() + playback = tde4.getCameraPlaybackRange(cam) + firstframe = playback[0] + lastframe = playback[1] + current_point_group = tde4.getCurrentPGroup() + selected_points = tde4.getPointList (current_point_group,1) + if (len(selected_points) < 2): + tde4.postQuestionRequester("Info","You need to select 2 or more 2D points","OK") + else: + exit = 0 + tde4.postProgressRequesterAndContinue("Calculating","Computing Points",100,"Cancel") + couples_selected_points = list(itertools.combinations(selected_points,2)) + counter = 0 + for i in couples_selected_points: + if exit == 1: + break + avg = tde4.createPoint (current_point_group) + aname = tde4.getPointName(current_point_group,i[0]) + bname = tde4.getPointName(current_point_group,i[1]) + tde4.setPointName(current_point_group,avg, "AVG_" + aname + "_" + bname) + for frame in range (firstframe, lastframe + 1): + counter+=1 + percentage = (100 * counter) / (len(couples_selected_points) * (lastframe + 1 - firstframe)) + status = tde4.updateProgressRequester(percentage,str(percentage) + " % - Frame " + str(frame) + " Point AVG_" + aname + "_" + bname) + if status != -1: + exit = 1 + break + apos = tde4.getPointPosition2D (current_point_group,i[0],cam,frame) + if dist: + apos = tde4.removeDistortion2D(cam,frame,apos) + avalid =tde4.isPointPos2DValid(current_point_group,i[0],cam,frame) + aposx = apos[0] + aposy = apos[1] + bpos = tde4.getPointPosition2D (current_point_group,i[1],cam,frame) + if dist: + bpos = tde4.removeDistortion2D(cam,frame,bpos) + bvalid =tde4.isPointPos2DValid(current_point_group,i[1],cam,frame) + bposx = bpos[0] + bposy = bpos[1] + if avalid and bvalid: + avgpos = [ aposx + ( (bposx - aposx) / 2 ) , aposy + ( (bposy - aposy) / 2 ) ] + if dist: + avgpos = tde4.applyDistortion2D(cam,frame,avgpos) + tde4.setPointPosition2D (current_point_group,avg,cam,frame,avgpos) + +average_each_2_points (dist = True) \ No newline at end of file diff --git a/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points.py b/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points.py new file mode 100644 index 0000000..efbed2a --- /dev/null +++ b/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points.py @@ -0,0 +1,75 @@ +# +# +# 3DE4.script.name: Average each 2 points 3D +# +# 3DE4.script.version: v1.0 +# +# 3DE4.script.comment: Average each 2 3d points. Calculate from scratch delete this 3d calculated point +# +# 3DE4.script.gui: Manual Tracking Controls::Fill3D +# 3DE4.script.gui: Manual Tracking Controls::Reconstruction +# 3DE4.script.hide: false +# 3DE4.script.startup: false +# +# Giovanni Di Grezia 2016 +# http://www.xgiovio.com +# + +import itertools + + +def average_each_2_points (reelin= False, distortion = False, visible_only = False): + cam = tde4.getCurrentCamera() + current_point_group = tde4.getCurrentPGroup() + selected_points = tde4.getPointList (current_point_group,1) + playback = tde4.getCameraPlaybackRange(cam) + firstframe = playback[0] + lastframe = playback[1] + if (len(selected_points) < 2): + tde4.postQuestionRequester("Info","You need to select 2 or more 2D points with 3D Position","OK") + else: + tde4.postProgressRequesterAndContinue("Calculating","Computing Points",100,"Cancel") + couples_selected_points = list(itertools.combinations(selected_points,2)) + counter = 0 + for i in couples_selected_points: + counter+=1 + percentage = (100 * counter) / len(couples_selected_points) + aname = tde4.getPointName(current_point_group,i[0]) + bname = tde4.getPointName(current_point_group,i[1]) + status = tde4.updateProgressRequester(percentage,str(percentage) + " % -" + " Point AVG3D_" + aname + "_" + bname) + if tde4.getPointCalculated3DStatus(current_point_group,i[0]) != "NOT_CALCULATED" and tde4.getPointCalculated3DStatus(current_point_group,i[1]) != "NOT_CALCULATED" : + avg = tde4.createPoint (current_point_group) + tde4.setPointName(current_point_group,avg, "AVG3D_" + aname + "_" + bname) + + apos = tde4.getPointCalcPosition3D (current_point_group,i[0]) + aposx = apos[0] + aposy = apos[1] + aposz = apos[2] + bpos = tde4.getPointCalcPosition3D(current_point_group,i[1]) + bposx = bpos[0] + bposy = bpos[1] + bposz = bpos[2] + + + avgpos = [ aposx + ( (bposx - aposx) / 2 ) , aposy + ( (bposy - aposy) / 2 ), aposz + ( (bposz - aposz) / 2 ) ] + + tde4.setPointCalcPosition3D (current_point_group,avg,avgpos) + tde4.setPointCalculated3D(current_point_group,avg,1) + tde4.setPointCalculated3DStatus(current_point_group,avg,"TRIANGULATED") + if reelin : + for frame in range (firstframe, lastframe + 1): + if distortion: + pos = tde4.calcPointBackProjection2D(current_point_group,avg,cam,frame,1) + else: + pos = tde4.calcPointBackProjection2D(current_point_group,avg,cam,frame,0) + if visible_only : + if pos[0] >= 0 and pos[0] <= 1 and pos[1] >= 0 and pos[1] <= 1: + tde4.setPointPosition2D(current_point_group,avg,cam,frame,pos) + else: + tde4.setPointPosition2D(current_point_group,avg,cam,frame,pos) + + if status != -1: + break + + +average_each_2_points () \ No newline at end of file diff --git a/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points_reelin_dist_visible.py b/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points_reelin_dist_visible.py new file mode 100644 index 0000000..48e67c3 --- /dev/null +++ b/single_versions_for_3de_online_db_scripts/xg_fill3d_average_each_2_points_reelin_dist_visible.py @@ -0,0 +1,75 @@ +# +# +# 3DE4.script.name: Avg each 2 points 3D + Reel in Visible Dist +# +# 3DE4.script.version: v1.0 +# +# 3DE4.script.comment: Average each 2 3d points and reel in in visibile frames area with distortion +# +# 3DE4.script.gui: Manual Tracking Controls::Fill3D +# 3DE4.script.gui: Manual Tracking Controls::Reconstruction +# 3DE4.script.hide: false +# 3DE4.script.startup: false +# +# Giovanni Di Grezia 2016 +# http://www.xgiovio.com +# + +import itertools + + +def average_each_2_points (reelin= False, distortion = False, visible_only = False): + cam = tde4.getCurrentCamera() + current_point_group = tde4.getCurrentPGroup() + selected_points = tde4.getPointList (current_point_group,1) + playback = tde4.getCameraPlaybackRange(cam) + firstframe = playback[0] + lastframe = playback[1] + if (len(selected_points) < 2): + tde4.postQuestionRequester("Info","You need to select 2 or more 2D points with 3D Position","OK") + else: + tde4.postProgressRequesterAndContinue("Calculating","Computing Points",100,"Cancel") + couples_selected_points = list(itertools.combinations(selected_points,2)) + counter = 0 + for i in couples_selected_points: + counter+=1 + percentage = (100 * counter) / len(couples_selected_points) + aname = tde4.getPointName(current_point_group,i[0]) + bname = tde4.getPointName(current_point_group,i[1]) + status = tde4.updateProgressRequester(percentage,str(percentage) + " % -" + " Point AVG3D_" + aname + "_" + bname) + if tde4.getPointCalculated3DStatus(current_point_group,i[0]) != "NOT_CALCULATED" and tde4.getPointCalculated3DStatus(current_point_group,i[1]) != "NOT_CALCULATED" : + avg = tde4.createPoint (current_point_group) + tde4.setPointName(current_point_group,avg, "AVG3D_" + aname + "_" + bname) + + apos = tde4.getPointCalcPosition3D (current_point_group,i[0]) + aposx = apos[0] + aposy = apos[1] + aposz = apos[2] + bpos = tde4.getPointCalcPosition3D(current_point_group,i[1]) + bposx = bpos[0] + bposy = bpos[1] + bposz = bpos[2] + + + avgpos = [ aposx + ( (bposx - aposx) / 2 ) , aposy + ( (bposy - aposy) / 2 ), aposz + ( (bposz - aposz) / 2 ) ] + + tde4.setPointCalcPosition3D (current_point_group,avg,avgpos) + tde4.setPointCalculated3D(current_point_group,avg,1) + tde4.setPointCalculated3DStatus(current_point_group,avg,"TRIANGULATED") + if reelin : + for frame in range (firstframe, lastframe + 1): + if distortion: + pos = tde4.calcPointBackProjection2D(current_point_group,avg,cam,frame,1) + else: + pos = tde4.calcPointBackProjection2D(current_point_group,avg,cam,frame,0) + if visible_only : + if pos[0] >= 0 and pos[0] <= 1 and pos[1] >= 0 and pos[1] <= 1: + tde4.setPointPosition2D(current_point_group,avg,cam,frame,pos) + else: + tde4.setPointPosition2D(current_point_group,avg,cam,frame,pos) + + if status != -1: + break + + +average_each_2_points (reelin = True, distortion = True, visible_only = True) \ No newline at end of file