python_code
stringlengths
0
456k
#!/usr/bin/env python import confu parser = confu.standard_parser() parser.add_argument("--backend", dest="backend", default="auto", choices=["auto", "psimd", "scalar"]) parser.add_argument("--inference-only", dest="inference_only", default=False, action="store_true", ...
#!/usr/bin/env python from __future__ import print_function def extract_time(line, prefix): if line.startswith(prefix): line = line[len(prefix):].lstrip() line = line[:line.index(" ms")].rstrip() return line def convolution(mode, batch_size, input_channels, output_channels, image_size, kernel_size, padding,...
arg_mem = Argument(ptr(), "mem") arg_len = Argument(size_t, "n") with Function("read_memory", (arg_mem, arg_len)): reg_mem = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_mem, arg_mem) reg_len = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_len, arg_len) main_loop = Loop() SUB(reg_len, 64) JB(main_loop.end) wit...
import fft.complex_soa arg_t = Argument(ptr(const_float_), name="t") arg_f = Argument(ptr(float_), name="f") with Function("nnp_fft16_soa__avx2", (arg_t, arg_f), target=uarch.default + isa.fma3 + isa.avx2): reg_t = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_t, arg_t) reg_f = GeneralPurposeReg...
from __future__ import absolute_import from __future__ import division import fft16x16 import fft.complex_soa import fft.two_real_to_two_complex_soa_perm_planar import fft.two_complex_soa_perm_to_two_real_planar arg_t_pointer = Argument(ptr(const_float_), name="t") arg_f_pointer = Argument(ptr(float_), name="f") arg...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import butterfly, sqrt2_over_2 from common import butterfly, sqrt2_over_2, cos_npi_over_8, interleave def fft8_bitreverse(n): return int(format(n, "03b")[::-1], 2) def load_ym...
from __future__ import absolute_import from __future__ import division import fft.complex_soa arg_t = Argument(ptr(const_float_), name="t") arg_f = Argument(ptr(float_), name="f") with Function("nnp_fft4_8aos__fma3", (arg_t, arg_f), target=uarch.default + isa.fma3): reg_t = GeneralPurposeRegister64() ...
import fft.complex_soa import fft.two_real_to_two_complex_soa_perm_planar arg_t = Argument(ptr(const_float_), name="t") arg_f = Argument(ptr(float_), name="f") with Function("nnp_fft8_dualreal__avx2", (arg_t, arg_f), target=uarch.default + isa.fma3 + isa.avx2): reg_t = GeneralPurposeRegister64() LO...
import fft.complex_soa_perm_to_real from common import butterfly, cos_npi_over_8, sqrt2_over_2 def fft8_bitreverse(n): return int(format(n, "03b")[::-1], 2) arg_f = Argument(ptr(const_float_), name="f") arg_t = Argument(ptr(float_), name="t") with Function("nnp_ifft8_8real__fma3", (arg_f, arg_t), targ...
from __future__ import absolute_import from __future__ import division import winograd.o6x6k3x3 import block8x8 from common import _MM_SHUFFLE for post_operation in ["store", "stream"]: arg_d_pointer = Argument(ptr(const_float_), name="d_pointer") arg_wd_pointer = Argument(ptr(float_), name="wd_pointer") ...
from __future__ import absolute_import from __future__ import division import block8x8 import fft.complex_soa import fft.real_to_complex_soa_perm import fft.complex_soa_perm_to_real import fft.two_real_to_two_complex_soa_perm_planar import fft.two_complex_soa_perm_to_two_real_planar arg_t_pointer = Argument(ptr(cons...
import fft.complex_soa import fft.two_complex_soa_perm_to_two_real_planar arg_f = Argument(ptr(const_float_), name="f") arg_t = Argument(ptr(float_), name="t") with Function("nnp_ifft8_dualreal__avx2", (arg_f, arg_t), target=uarch.default + isa.fma3 + isa.avx2): reg_f = GeneralPurposeRegister64() L...
import fft.real_to_complex_soa_perm arg_t = Argument(ptr(const_float_), name="t") arg_f = Argument(ptr(float_), name="f") with Function("nnp_fft8_8real__fma3", (arg_t, arg_f), target=uarch.default + isa.fma3): reg_t = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_t, arg_t) reg_f = GeneralPurpose...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * def load_with_padding(ymm_data, reg_data, reg_stride, reg_row_offset, reg_row_count, reg_column_offset, reg_column_count): assert isinstance(ymm_data, list) and all(isinstance(ymm_row, YMMReg...
import winograd.o6x6k3x3 arg_d_pointer = Argument(ptr(const_float_), name="d") arg_w_pointer = Argument(ptr(float_), name="w") with Function("nnp_iwt_f6k3__fma3", (arg_d_pointer, arg_w_pointer), target=uarch.default + isa.fma3): reg_d = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_d, arg_d_pointer) ...
from common import _MM_SHUFFLE arg_src_pointer = Argument(ptr(const_float_), name="src_pointer") arg_dst_pointer = Argument(ptr(float_), name="dst_pointer") arg_src_stride = Argument(size_t, name="src_stride") arg_src_row_offset = Argument(uint32_t, name="src_row_offset") arg_src_row_count = Argument(uint32_t, name="...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * sqrt2_over_2 = float.fromhex("0x1.6A09E6p-1") cos_1pi_over_8 = float.fromhex("0x1.D906BCp-1") cos_3pi_over_8 = float.fromhex("0x1.87DE2Ap-2") tan_1pi_over_8 = float.fromhex("0x1.A8279Ap-2") tan_3...
arg_input = Argument(ptr(const_float_), "input") arg_output = Argument(ptr(float_), "output") arg_length = Argument(size_t, "length") arg_negative_slope = Argument(float_, "negative_slope") with Function("nnp_relu__avx2", (arg_input, arg_output, arg_length, arg_negative_slope), target=uarch.default + isa.avx2): reg...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * log2e = float.fromhex("+0x1.715476p+3") magic_bias = float.fromhex("+0x1.800000p+23") zero_cutoff = float.fromhex("-0x1.9FE368p+6") inf_cutoff = float.fromhex("+0x1.62E42Ep+6") minus_ln2_hi = floa...
from common import _MM_SHUFFLE from vecmath.exp import simd_exp arg_n = Argument(size_t, "n") arg_v = Argument(ptr(const_float_), "v") with Function("max__avx", (arg_n, arg_v), float_, target=uarch.default + isa.avx): reg_n = GeneralPurposeRegister64() LOAD.ARGUMENT(reg_n, arg_n) reg_v = GeneralPurp...
from __future__ import absolute_import from __future__ import division mr, nr = 3, 4 arg_k = Argument(size_t, "k") arg_update = Argument(size_t, "update") arg_a = Argument(ptr(const_float_), "a") arg_b = Argument(ptr(const_float_), "b") arg_c = Argument(ptr(float_), "c") arg_row_stride = Argument(size_t, "row_stride_...
from __future__ import absolute_import from __future__ import division mr, nr = 2, 4 arg_input_channels = Argument(size_t, "input_channels") arg_image_size = Argument(size_t, "image_size") arg_input = Argument(ptr(const_float_), "input") arg_kernel = Argument(ptr(const_float_), "kernel") arg_output = Argument(ptr...
from __future__ import absolute_import from __future__ import division simd_width = YMMRegister.size // float_.size for fusion_factor in range(1, 8 + 1): arg_x = Argument(ptr(const_float_), "x") arg_y = Argument(ptr(const_float_), "y") arg_stride_y = Argument(size_t, "stride_y") arg_sum = Argument(ptr(float_), "s...
from __future__ import absolute_import from __future__ import division from fp16.avx import fp16_alt_xmm_to_fp32_xmm from fp16.avx2 import fp16_alt_xmm_to_fp32_ymm simd_width = YMMRegister.size // float_.size for fusion_factor in range(1, 8 + 1): arg_x = Argument(ptr(const_float_), "x") arg_y = Argument(ptr(const_...
from __future__ import absolute_import from __future__ import division from common import _MM_SHUFFLE simd_width = YMMRegister.size // float_.size mr = 4 nr = 3 * simd_width arg_k = Argument(size_t, "k") arg_update = Argument(size_t, "update") arg_a = Argument(ptr(const_float_), "a") arg_b = Argument(ptr(const_float...
from __future__ import absolute_import from __future__ import division mr, nr = 2, 2 for conjugate_b, transpose_c in [(False, False), (True, False), (True, True)]: arg_k = Argument(size_t, "k") arg_update = Argument(size_t, "update") arg_a = Argument(ptr(const_float_), "a") arg_b = Argument(ptr(const_float_), "b"...
from __future__ import absolute_import from __future__ import division mr, nr = 2, 2 for conjugate_b, transpose_c in [(False, False), (True, False), (True, True)]: arg_k = Argument(size_t, "k") arg_update = Argument(size_t, "update") arg_a = Argument(ptr(const_float_), "a") arg_b = Argument(ptr(const_float_), "b"...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import sqrt2_over_2 from common import butterfly import fft.complex_soa def fft8_across_rows(ymm_data): assert isinstance(ymm_data, list) and len(ymm_data) == 8 ymm_real = y...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import interleave def ifft8_within_rows_preprocess(ymm_wr, ymm_wi): assert isinstance(ymm_wr, YMMRegister) assert isinstance(ymm_wi, YMMRegister) # w0.re, w1.re, w2.re, ...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import sqrt2_over_2 from common import butterfly import fft.complex_soa def ifft8_across_rows(ymm_data, bias=None): assert isinstance(ymm_data, list) and len(ymm_data) == 8 y...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * def fft8_within_rows_postprocess(ymm_wr, ymm_wi): assert isinstance(ymm_wr, YMMRegister) assert isinstance(ymm_wi, YMMRegister) ymm_shuffle_44112233 = YMMRegister() VMOVDQA(ymm_s...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import cos_npi_over_8, sin_npi_over_8, cos_npi_over_4, sin_npi_over_4 from common import _MM_SHUFFLE from common import butterfly, transpose2x2x128, transpose2x2x2x64, interleave def ...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * log2e = float.fromhex("+0x1.715476p+3") magic_bias = float.fromhex("+0x1.800000p+23") zero_cutoff = float.fromhex("-0x1.9FE368p+6") inf_cutoff = float.fromhex("+0x1.62E42Ep+6") minus_ln2_hi = floa...
from __future__ import absolute_import from __future__ import division from peachpy import * from peachpy.x86_64 import * from common import _MM_SHUFFLE from common import transpose2x2x128, transpose2x2x2x64, butterfly def input_transform(ymm_d): assert isinstance(ymm_d, list) and len(ymm_d) == 8 and all(isin...
#!/usr/bin/env python ''' This module contains some common routines used by other samples. ''' import numpy as np import cv2 as cv # built-in modules import os import itertools as it from contextlib import contextmanager image_extensions = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff', '.pbm', '.pgm', '.ppm'] ...
#!/usr/bin/env python ''' This example shows the functionalities of lines extraction finished by LSDDetector class. USAGE: lsd_lines_extraction.py [<path_to_input_image>] ''' import sys import cv2 as cv if __name__ == '__main__': print(__doc__) if len(sys.argv) > 1: fname = sys.argv[1] else : ...
#!/usr/bin/env python ''' This sample demonstrates SEEDS Superpixels segmentation Use [space] to toggle output mode Usage: seeds.py [<video source>] ''' import numpy as np import cv2 as cv # relative module import video # built-in module import sys if __name__ == '__main__': print __doc__ try: ...
#!/usr/bin/env python ''' Video capture sample. Sample shows how VideoCapture class can be used to acquire video frames from a camera of a movie file. Also the sample provides an example of procedural video generation by an object, mimicking the VideoCapture interface (see Chess class). 'create_capture' is a convini...
import numpy as np import cv2 as cv # aruco config adict = cv.aruco.Dictionary_get(cv.aruco.DICT_4X4_50) cv.imshow("marker", cv.aruco.drawMarker(adict, 0, 400)) marker_len = 5 # rapid config obj_points = np.float32([[-0.5, 0.5, 0], [0.5, 0.5, 0], [0.5, -0.5, 0], [-0.5, -0.5, 0]]) * marker_len tris = np.int32([[0, 2, ...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import os, numpy import cv2 as cv from tests_common import NewOpenCVTests class structured_light_test(NewOpenCVTests): def test_unwrap(self): paramsPsp = cv.structured_light_SinusoidalPattern_Params(); param...
import cv2 as cv N = 2 modelname = "parasaurolophus_6700" scenename = "rs1_normals" detector = cv.ppf_match_3d_PPF3DDetector(0.025, 0.05) print('Loading model...') pc = cv.ppf_match_3d.loadPLYSimple("data/%s.ply" % modelname, 1) print('Training...') detector.trainModel(pc) print('Loading scene...') pcTest = cv.pp...
import cv2 as cv import numpy as np def rotation(theta): tx, ty, tz = theta Rx = np.array([[1, 0, 0], [0, np.cos(tx), -np.sin(tx)], [0, np.sin(tx), np.cos(tx)]]) Ry = np.array([[np.cos(ty), 0, -np.sin(ty)], [0, 1, 0], [np.sin(ty), 0, np.cos(ty)]]) Rz = np.array([[np.cos(tz), -np.sin(tz), 0], [np.sin(t...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudafilters_test(NewOpenCVTests): def setUp(self): super(cudafilters_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-capabl...
#!/usr/bin/python import cv2 as cv import numpy as np import sys img1 = cv.imread(sys.argv[1]) img1 = img1.astype(np.float32) shift = np.array([5., 5.]) mapTest = cv.reg_MapShift(shift) img2 = mapTest.warp(img1) mapper = cv.reg_MapperGradShift() mappPyr = cv.reg_MapperPyramid(mapper) resMap = mappPyr.calculate(img...
#!/usr/bin/env python from __future__ import print_function import os, sys, argparse, json import numpy as np import scipy.io import cv2 as cv import timeit from learn_color_balance import load_ground_truth def load_json(path): f = open(path, "r") data = json.load(f) return data def save_json(obj, path)...
#!/usr/bin/env python from __future__ import print_function import os, sys, argparse import numpy as np import scipy.io from sklearn.tree import DecisionTreeRegressor import cv2 as cv import random def parse_sequence(input_str): if len(input_str) == 0: return [] else: return [o.strip() for o i...
#!/usr/bin/env python3 # SPDX-License-Identifier: BSD-3-Clause # # Copyright (c) 2019, Josh Chien. All rights reserved. from argparse import ArgumentParser import numpy as np from PIL import Image import io import warnings import os import cairo from cairosvg import svg2png import math import tempfile def SaveArucoD...
#!/usr/bin/env python3 # SPDX-License-Identifier: BSD-3-Clause # # Copyright (c) 2019, Josh Chien. All rights reserved. from MarkerPrinter import * import tkinter as tk from tkinter import ttk, filedialog, messagebox import time import PIL.Image import PIL.ImageTk class MarkerPrinterGUI: def VisDPI(self, sha...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import os import cv2 as cv from tests_common import NewOpenCVTests SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) MODULE_DIR = os.path.join(SCRIPT_DIR, '../../../') class shape_test(NewOpenCVTests): def test_compu...
#!/usr/bin/env python import os import cv2 as cv from tests_common import NewOpenCVTests, unittest class test_dnn_superres(NewOpenCVTests): @unittest.skipIf('OPENCV_TEST_DATA_PATH' not in os.environ, "OPENCV_TEST_DATA_PATH is not defined") def test_single_output(self): # Get test...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudaobjdetect_test(NewOpenCVTests): def setUp(self): super(cudaobjdetect_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-ca...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudabgsegm_test(NewOpenCVTests): def setUp(self): super(cudabgsegm_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-capable ...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudacodec_test(NewOpenCVTests): def setUp(self): super(cudacodec_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-capable de...
import random import numpy as np import cv2 as cv frame1 = cv.imread(cv.samples.findFile('lena.jpg')) if frame1 is None: print("image not found") exit() frame = np.vstack((frame1,frame1)) facemark = cv.face.createFacemarkLBF() try: facemark.loadModel(cv.samples.findFile('lbfmodel.yaml')) except cv.error: ...
#!/usr/bin/env python import sys import os.path # This is a tiny script to help you creating a CSV file from a face # database with a similar hierarchie: # # philipp@mango:~/facerec/data/at$ tree # . # |-- README # |-- s1 # | |-- 1.pgm # | |-- ... # | |-- 10.pgm # |-- s2 # | |-- 1.pgm # | |-- ... ...
#!/usr/bin/env python # Software License Agreement (BSD License) # # Copyright (c) 2012, Philipp Wagner # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudaimgproc_test(NewOpenCVTests): def setUp(self): super(cudaimgproc_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-capabl...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class xfeatures2d_test(NewOpenCVTests): def setUp(self): super(xfeatures2d_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-capabl...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import os import numpy as np import cv2 as cv from tests_common import NewOpenCVTests class sift_compatibility_test(NewOpenCVTests): def test_create(self): sift = cv.xfeatures2d.SIFT_create() self.assertFals...
#!/usr/bin/python """ /********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2016 * * Balint Cristian <cristian dot balint at gmail dot com> * * * Redistribution and use in source and binary forms, with or without * modification, ...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest def create_affine_transform_matrix(size,angle): return np.array([[np.cos(angle), -np.sin(angle), size[1]/2], [np.sin(angle), np.cos(angle), 0]]) def create_perspective_transform_matrix(size,angle)...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class intensity_transform_test(NewOpenCVTests): def setUp(self): super(intensity_transform_test, self).setUp() tr...
import argparse import glob import os import subprocess FRAME_DIST = 2 assert (FRAME_DIST >= 1) def execute(cmd): popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) for stdout_line in iter(popen.stdout.readline, ''): ...
#!/usr/bin/env python from __future__ import print_function import os, sys, shutil import argparse import json, re from subprocess import check_output import datetime import matplotlib.pyplot as plt def load_json(path): f = open(path, "r") data = json.load(f) return data def save_json(obj, path): tm...
import argparse import glob import os import subprocess def execute(cmd): popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) for stdout_line in iter(popen.stdout.readline, ''): print(stdout_line.rstrip()) for stde...
#!/usr/bin/env python import numpy as np import cv2 as cv MHI_DURATION = 0.5 DEFAULT_THRESHOLD = 32 MAX_TIME_DELTA = 0.25 MIN_TIME_DELTA = 0.05 # (empty) trackbar callback def nothing(dummy): pass def draw_motion_comp(vis, rect, angle, color): x, y, w, h = rect cv.rectangle(vis, (x, y), (x+w, y+h), (0, 2...
#!/usr/bin/env python import os import sys import numpy as np import cv2 as cv import struct import argparse from math import sqrt argparser = argparse.ArgumentParser( description='''Use this script to generate prior for using with PCAFlow. Basis size here must match corresponding parameter in the PCAFlow. Gamma ...
import argparse import cv2 as cv import glob import numpy as np import os import time # This tool is intended for evaluation of different background subtraction algorithms presented in OpenCV. # Several presets with different settings are available. You can see them below. # This tool measures quality metrics as well...
import cv2 as cv import argparse def main(): argparser = argparse.ArgumentParser(description='Vizualization of the SyntheticSequenceGenerator.') argparser.add_argument('-b', '--background', help='Background image.', required=True) argparser.add_argument('-o', '--obj', help='Object image. It must be stric...
import numpy as np import cv2 as cv import argparse import os def main(): argparser = argparse.ArgumentParser(description='Vizualization of the LSBP/GSOC background subtraction algorithm.') argparser.add_argument('-g', '--gt', help='Directory with ground-truth frames', required=True) argparser.add_argume...
#!/usr/bin/env python import cv2 as cv import numpy as np from tests_common import NewOpenCVTests class disparity_test(NewOpenCVTests): def test_disp(self): # readGT ret,GT = cv.ximgproc.readGT(self.find_file("cv/disparityfilter/GT.png")) self.assertEqual(ret, 0) # returns 0 on success! ...
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' This sample demonstrates structured edge detection and edgeboxes. Usage: edgeboxes_demo.py [<model>] [<input_image>] ''' import cv2 as cv import numpy as np import sys if __name__ == '__main__': print(__doc__) model = sys.argv[1] im = cv.imread(sys.arg...
# USAGE - How to run this code ? # python find_shapes.py --image shapes.png #python findredlinedpolygonfromgooglemaps.py --image stanford.png import numpy as np import argparse import cv2 as cv # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-i", "--image", help...
import sys import numpy as np import cv2 as cv def AddSlider(sliderName,windowName,minSlider,maxSlider,valDefault, update=[]): if update is None: cv.createTrackbar(sliderName, windowName, valDefault,maxSlider-minSlider+1) else: cv.createTrackbar(sliderName, windowName, valDefault,maxSlider-minS...
#!/usr/bin/env python ''' A program demonstrating the use and capabilities of a particular image segmentation algorithm described in Jasper R. R. Uijlings, Koen E. A. van de Sande, Theo Gevers, Arnold W. M. Smeulders: "Selective Search for Object Recognition" International Journal of Computer Vision, Volume 104 (2...
import numpy as np import cv2 as cv import math class ThParameters: def __init__(self): self.levelNoise=6 self.angle=45 self.scale10=5 self.origin=10 self.xg=150 self.yg=150 self.update=True def UpdateShape(x ): p.update = True def union(a,b): x = min...
import collections from textwrap import fill from filters import * try: # Python 2.7+ basestring except NameError: # Python 3.3+ basestring = str valid_types = ( 'int', 'bool', 'float', 'double', 'size_t', 'char', 'Mat', 'Scalar', 'String', 'TermCriteria', 'Size', 'Point', 'Point2f', 'Point2d', 'R...
#!/usr/bin/env python import sys, re, os, time from string import Template from parse_tree import ParseTree, todict, constants from filters import * updated_files = [] def update_file(fname, content): if fname in updated_files: print('ERROR(gen_matlab.py): attemption to write file multiple times: {}'.form...
#!/usr/bin/env python def substitute(cv, output_dir): # setup the template engine template_dir = os.path.join(os.path.dirname(__file__), 'templates') jtemplate = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True) # add the filters jtemplate.filters['cellar...
#!/usr/bin/env python def substitute(build, output_dir): # setup the template engine template_dir = os.path.join(os.path.dirname(__file__), 'templates') jtemplate = Environment(loader=FileSystemLoader(template_dir), trim_blocks=True, lstrip_blocks=True) # add the filters jtemplate.filters['csv...
from textwrap import TextWrapper import re, os # precompile a URL matching regular expression urlexpr = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.MULTILINE|re.UNICODE) def inputs(args): '''Keeps only the input arguments in a list of elements. ''' try: return [arg for arg...
import numpy as np import cv2 as cv import sys if len(sys.argv) != 2: print('Input video name is missing') exit() print('Select 3 tracking targets') cv.namedWindow("tracking") camera = cv.VideoCapture(sys.argv[1]) tracker = cv.MultiTracker_create() init_once = False ok, image=camera.read() if not ok: pr...
import numpy as np import cv2 as cv import sys if len(sys.argv) != 2: print('Input video name is missing') exit() cv.namedWindow("tracking") camera = cv.VideoCapture(sys.argv[1]) ok, image=camera.read() if not ok: print('Failed to read video') exit() bbox = cv.selectROI("tracking", image) tracker = cv...
#!/usr/bin/env python # This file is part of OpenCV project. # It is subject to the license terms in the LICENSE file found in the top-level directory # of this distribution and at http://opencv.org/license.html # Copyright (C) 2020 by Archit Rungta import hdr_parser, sys, re, os from string import Template from ppr...
#!/usr/bin/python # This file is part of OpenCV project. # It is subject to the license terms in the LICENSE file found in the top-level directory # of this distribution and at http://opencv.org/license.html # Copyright (C) 2020 by Archit Rungta import sys import subprocess import os mod_path = sys.argv[1] hdr_lis...
#!/usr/bin/env python # This file is part of OpenCV project. # It is subject to the license terms in the LICENSE file found in the top-level directory # of this distribution and at http://opencv.org/license.html # Copyright (C) 2020 by Archit Rungta from __future__ import unicode_literals # Needed for python2 import...
#!/usr/bin/env python # This file is part of OpenCV project. # It is subject to the license terms in the LICENSE file found in the top-level directory # of this distribution and at http://opencv.org/license.html # Copyright (C) 2020 by Archit Rungta from __future__ import unicode_literals # Needed for python2 import...
#!/usr/bin/env python # This file is part of OpenCV project. # It is subject to the license terms in the LICENSE file found in the top-level directory # of this distribution and at http://opencv.org/license.html # Copyright (C) 2020 by Archit Rungta from __future__ import unicode_literals # Needed for python2 impor...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import os, numpy import cv2 as cv from tests_common import NewOpenCVTests class rgbd_test(NewOpenCVTests): def test_computeRgbdPlane(self): depth_image = self.get_sample('/cv/rgbd/depth.png', cv.IMREAD_ANYDEPTH) ...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest class cudafeatures2d_test(NewOpenCVTests): def setUp(self): super(cudafeatures2d_test, self).setUp() if not cv.cuda.getCudaEnabledDeviceCount(): self.skipTest("No CUDA-...
#!/usr/bin/python import sys import os import cv2 as cv import numpy as np print('\ntextdetection.py') print(' A demo script of the Extremal Region Filter algorithm described in:') print(' Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012\n') if (len(sys.argv) < 2): p...
# -*- coding: utf-8 -*- #!/usr/bin/python import sys import os import cv2 as cv import numpy as np def main(): print('\nDeeptextdetection.py') print(' A demo script of text box alogorithm of the paper:') print(' * Minghui Liao et al.: TextBoxes: A Fast Text Detector with a Single Deep Neural Ne...
#!/usr/bin/python import sys import os import cv2 as cv import numpy as np print('\ndetect_er_chars.py') print(' A simple demo script using the Extremal Region Filter algorithm described in:') print(' Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012\n') if (len(sys.arg...
from skimage import io, transform from multiprocessing.dummy import Pool as ThreadPool def rescale(root_new, root_old, img_path, ann_path, out_shape): try: img = io.imread(root_old+"/"+img_path) except Exception as E: print E h, w, _ = img.shape f_h, f_w = float(out_shape)/h, float(out_shape)/w trans...
import argparse import sys import os import time import numpy as np from sklearn.cluster import KMeans import matplotlib.pyplot as plt def k_means(K, data, max_iter, n_jobs, image_file): X = np.array(data) np.random.shuffle(X) begin = time.time() print 'Running kmeans' kmeans = KMeans(n_clusters=K, max_iter...