-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../example/README.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
======= | ||
Example | ||
======= | ||
|
||
A simple tool that uses the height measurement tool to allow a user to measure height on the first oblique image in a dataset | ||
|
||
This app uses the following dependecies: | ||
|
||
* EVTech | ||
* OpenCV | ||
|
||
==== | ||
Demo | ||
==== | ||
|
||
.. figure:: ../docs/demo.gif | ||
:scale: 100 % | ||
:alt: Demo of height measurments | ||
|
||
====== | ||
Source | ||
====== | ||
|
||
.. literalinclude:: ../example/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import argparse | ||
import evtech | ||
import cv2 | ||
|
||
# Load arguments | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-d", | ||
"--dataset", | ||
help="Location of dataset", | ||
type=str) | ||
args = parser.parse_args() | ||
|
||
# Only care about obliques for this app | ||
_, obliques = evtech.load_dataset(args.dataset) | ||
|
||
# Load first oblique image | ||
img = obliques[0].load_image() | ||
|
||
# mouse callback function | ||
# For drawing | ||
drawing = False # true if mouse is pressed | ||
ix,iy = -1,-1 | ||
def draw_line(event,x,y,flags,param): | ||
global ix,iy,drawing,mode | ||
if event == cv2.EVENT_LBUTTONDOWN: | ||
if drawing: | ||
drawing = False | ||
# Draw line | ||
cv2.line(img,pt1=(ix,iy),pt2=(x,y),color=(0,0,255),thickness=3) | ||
|
||
# Compute height | ||
height = obliques[0].height_between_points([ix,iy],[x,y]) | ||
|
||
# Computed in meters, convert to feet | ||
height *= 3.28084 | ||
|
||
# Label line | ||
lbl = "{:.2f}".format(height) + " feet" | ||
cv2.putText(img, lbl, (x+10,y-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 1) | ||
else: | ||
drawing = True | ||
ix,iy = x,y | ||
|
||
# Making Window For The Image | ||
cv2.namedWindow("Image") | ||
# Adding Mouse CallBack Event | ||
cv2.setMouseCallback("Image",draw_line) | ||
|
||
# Starting The Loop So Image Can Be Shown | ||
while(True): | ||
cv2.imshow("Image",img) | ||
|
||
if cv2.waitKey(20) & 0xFF == ord('q'): | ||
break | ||
|
||
cv2.destroyAllWindows() |