Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| import cv2 | |
| import time | |
| person_cascade = cv2.CascadeClassifier( | |
| os.path.join('/path/to/haarcascade_fullbody.xml')) | |
| cap = cv2.VideoCapture("/path/to/test/video") | |
| while True: | |
| r, frame = cap.read() | |
| if r: | |
| start_time = time.time() |
| import cv2 | |
| import time | |
| hog = cv2.HOGDescriptor() | |
| hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector()) | |
| cap = cv2.VideoCapture("/path/to/test/video") | |
| while True: | |
| r, frame = cap.read() | |
| if r: | |
| start_time = time.time() |
| # Code adapted from Tensorflow Object Detection Framework | |
| # https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb | |
| # Tensorflow Object Detection Detector | |
| import numpy as np | |
| import tensorflow as tf | |
| import cv2 | |
| import time |
| # For more info: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html | |
| import cv2 | |
| import numpy as np | |
| import os | |
| FILE_OUTPUT = 'output.avi' | |
| # Checks and deletes the output file | |
| # You cant have a existing file or it will through an error | |
| if os.path.isfile(FILE_OUTPUT): |
| # This file is useful for reading the contents of the ops generated by ruby. | |
| # You can read any graph defination in pb/pbtxt format generated by ruby | |
| # or by python and then convert it back and forth from human readable to binary format. | |
| import tensorflow as tf | |
| from google.protobuf import text_format | |
| from tensorflow.python.platform import gfile | |
| def pbtxt_to_graphdef(filename): | |
| with open(filename, 'r') as f: |
| // | |
| // AssetRecorderView.swift | |
| // Snowball | |
| // | |
| // Created by Le Tai on 7/20/16. | |
| // Copyright © 2016 Snowball. All rights reserved. | |
| // | |
| import UIKit | |
| import AVFoundation |
| extension AVCaptureDevice { | |
| /// http://stackoverflow.com/questions/21612191/set-a-custom-avframeraterange-for-an-avcapturesession#27566730 | |
| func configureDesiredFrameRate(_ desiredFrameRate: Int) { | |
| var isFPSSupported = false | |
| do { | |
| if let videoSupportedFrameRateRanges = activeFormat.videoSupportedFrameRateRanges as? [AVFrameRateRange] { |
| var mediaJSON = { "categories" : [ { "name" : "Movies", | |
| "videos" : [ | |
| { "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
| "sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
| "subtitle" : "By Blender Foundation", | |
| "thumb" : "images/BigBuckBunny.jpg", | |
| "title" : "Big Buck Bunny" | |
| }, | |
| { "description" : "The first Blender Open Movie from 2006", | |
| "sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |