This file contains hidden or 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
import os | |
import json | |
import functools | |
import hashlib | |
import pandas as pd | |
# Taken from https://bobbyhadz.com/blog/python-typeerror-object-of-type-ndarray-is-not-json-serializable | |
class NpEncoder(json.JSONEncoder): | |
def default(self, obj): |
This file contains hidden or 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
import perception.hashers.tools as pht | |
import numpy as np | |
import cv2 | |
def describe_transformation(image1, image2, sift, matcher, min_match_count=5, min_inliers=0.8): | |
"""Get a transformation description between two images by using the top-left and | |
bottom-right coordinate transformations for each. | |
Args: | |
image1: The first image |
This file contains hidden or 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
# Before running this script, you must clone the ThreatExchange | |
# repo (containing the pure Python implementation) | |
# and install the pdqhash package (containing the C bindings). | |
# You can do this by executing the following at the command line. | |
# git clone https://github.com/facebook/ThreatExchange.git | |
# pip install pdqhash | |
import urllib.request | |
import timeit | |
import sys |
This file contains hidden or 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
import cv2 | |
import numpy as np | |
# Code assumes that the video lives in the following | |
# folder and is titled video.wmv. | |
folder_template = 'data/folder/{0}' | |
# Reset frequency determines how many frames the | |
# stabilization will track before resetting to the | |
# identity transform. May switch to using a maximum | |
# translation, rotation, scale, etc. |
This file contains hidden or 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
/* Using this directive is as easy as 1, 2, 3. | |
1. Grab the Tableau API JavaScript library as well as this module. | |
a. <script src="path/to/tableau-2.0.0.min.js"></script> | |
b. <script src="path/to/angular-tableau.js"></script> | |
2. Import the module into your app by adding 'angular-tableau' to your dependencies. | |
3. Use the directive like this: | |
<tableau-viz height="'500px'" | |
url="path/to/tableau-dashboard" | |
filters={'field1':['item1', 'item2'], 'dateField':{'min':startDate, 'max':endDate}}"> | |
</tableau-viz> |
This file contains hidden or 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
// Creates a very pretty duration icon | |
angular.module('utilities').directive('timeDuration', [function () { | |
return { | |
restrict: 'E', | |
template: '<canvas></canvas>', | |
link: function (scope, element, attrs) { | |
var time = attrs.time; | |
var size = attrs.size ? attrs.size : 50; | |
var shadow = attrs.hasOwnProperty('shadow'); | |
var background = attrs.background ? attrs.background : '#FFF'; |