-
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
66 changed files
with
6,183 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.dropbox | ||
.ipynb_checkpoints | ||
__pycache__ | ||
*.pyc | ||
|
||
_library |
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,7 @@ | ||
Copyright 2018 Joshua Horowitz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,38 @@ | ||
# whiteboard-stitch | ||
|
||
See http://joshuahhh.com/projects/whiteboard-stitch. | ||
|
||
The source code to **whiteboard-stitch** is freely available for study. However, it is not packaged for turn-key operation, and you should not expect: | ||
* the code to be easy to use, or | ||
* anyone to assist you in use of the code. | ||
|
||
I hope it is useful nonetheless. | ||
|
||
## Dependencies | ||
|
||
* opencv (with numpy) | ||
* imutils | ||
* numba | ||
* clint | ||
* yaml | ||
* [possibly more?] | ||
|
||
## Usage | ||
|
||
To stitch together the concurrency whiteboard, run: | ||
|
||
``` | ||
python stitch-cli.py whiteboards/concurrency/a.yaml | ||
``` | ||
|
||
To generate image pyramids for the viewer, run: | ||
|
||
``` | ||
python bundle.py whiteboards viewer/static/data | ||
``` | ||
|
||
To build the viewer, go into the `viewer` directory and run: | ||
|
||
``` | ||
yarn build | ||
``` |
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,85 @@ | ||
import os | ||
import shutil | ||
import json | ||
import hashlib | ||
|
||
from clint.arguments import Args | ||
import deepzoom | ||
|
||
from library import Library | ||
|
||
_library = Library('_library') | ||
|
||
|
||
def subdirs(dir): | ||
maybe_subdirs = (os.path.join(dir, subdir_part) for subdir_part in os.listdir(dir)) | ||
return (maybe_subdir for maybe_subdir in maybe_subdirs if os.path.isdir(maybe_subdir)) | ||
|
||
|
||
creator = deepzoom.ImageCreator( | ||
tile_size=128, tile_overlap=2, tile_format="png", | ||
image_quality=1, resize_filter="bicubic") | ||
|
||
|
||
def cached_deepzoom(image_path, destination): | ||
image_hasher = hashlib.sha1() | ||
with open(image_path, 'rb') as f: | ||
for chunk in iter(lambda: f.read(4096), b''): | ||
image_hasher.update(chunk) | ||
image_hash = image_hasher.hexdigest() | ||
|
||
def calculate(temp_dir): | ||
creator.create(image_path, os.path.join(temp_dir, 'image.dzi')) | ||
_library.get_dir(destination, calculate, image_hash, 'dzi') | ||
|
||
|
||
def main(): | ||
args = Args() | ||
|
||
input_path = os.path.realpath(args.get(0)) | ||
output_path = os.path.realpath(args.get(1)) | ||
|
||
image_names = ['homographies', 'masks', 'stitched'] | ||
|
||
# Scan the input directory to get the structure | ||
whiteboards = {} # whiteboards[whiteboard name] = list of stitching names | ||
num_stitchings = 0 | ||
for whiteboard_path in subdirs(input_path): | ||
stitchings = [] | ||
for stitching_path in subdirs(whiteboard_path): | ||
files = [os.path.join(stitching_path, part + '.png') for part in image_names] | ||
if all(os.path.exists(file) for file in files): | ||
stitchings.append(os.path.basename(stitching_path)) | ||
num_stitchings += 1 | ||
if stitchings: | ||
whiteboards[os.path.basename(whiteboard_path)] = stitchings | ||
|
||
# Remake the output directory | ||
shutil.rmtree(output_path) | ||
os.mkdir(output_path) | ||
|
||
# Write the structure | ||
with open(os.path.join(output_path, 'whiteboards.json'), 'w') as f: | ||
json.dump(whiteboards, f) | ||
|
||
# Write the deepzooms | ||
num_deepzooms_written = 0 | ||
for whiteboard_name, stitchings in whiteboards.iteritems(): | ||
input_whiteboard_path = os.path.join(input_path, whiteboard_name) | ||
output_whiteboard_path = os.path.join(output_path, whiteboard_name) | ||
os.mkdir(output_whiteboard_path) | ||
for stitching_name in stitchings: | ||
input_stitching_path = os.path.join(input_whiteboard_path, stitching_name) | ||
output_stitching_path = os.path.join(output_whiteboard_path, stitching_name) | ||
os.mkdir(output_stitching_path) | ||
for image_name in image_names: | ||
print (num_deepzooms_written + 1), '/', len(image_names) * num_stitchings | ||
cached_deepzoom( | ||
os.path.join(input_stitching_path, image_name + '.png'), | ||
os.path.join(output_stitching_path, image_name) | ||
) | ||
num_deepzooms_written += 1 | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.