Skip to content

Commit

Permalink
Merge 581a312 into 639db1d
Browse files Browse the repository at this point in the history
  • Loading branch information
dnilosek committed Jan 23, 2020
2 parents 639db1d + 581a312 commit c5450fd
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 7 deletions.
7 changes: 0 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ EVTech

Simple tools for working with data provided by Eagleview for the RIT Hack.tiff 2020 Hackathon


* Free software: MIT license
* Documentation: https://evtech.readthedocs.io.

====
TODO
====

* Create example

.. include:: ./HISTORY.rst
Binary file added docs/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/demo.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../example/README.rst
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Welcome to EVTech's documentation!
contributing
authors
history
demo

Indices and tables
==================
Expand Down
24 changes: 24 additions & 0 deletions example/README.rst
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
56 changes: 56 additions & 0 deletions example/main.py
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()

0 comments on commit c5450fd

Please sign in to comment.