Skip to content

Instantly share code, notes, and snippets.

@ShawonAshraf
ShawonAshraf / guicode.swift
Last active November 30, 2017 21:15
ClassifierGUISwift.md
//
// ViewController.swift
// macOS_GUI
//
// Created by Shawon Ashraf on 7/8/17.
// Copyright © 2017 Shawon Ashraf. All rights reserved.
//
import Cocoa
@creotiv
creotiv / vehicle_counter.py
Last active August 29, 2018 13:30
Class that used in car counting during CV traffic analysis
import logging
import math
import numpy as np
from scipy import spatial
import cv2
# ============================================================================
CAR_COLOURS = [ (0,0,255), (0,106,255), (0,216,255), (0,255,182), (0,255,76)
, (144,255,0), (255,255,0), (255,148,0), (255,0,178), (220,0,255) ]
# 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:
@TheSalarKhan
TheSalarKhan / backgroundAveraging.py
Last active February 12, 2023 03:47
Background Averaging (Background Subtraction) in Python+OpenCV
import numpy as np
import cv2
class BackGroundSubtractor:
# When constructing background subtractor, we
# take in two arguments:
# 1) alpha: The background learning factor, its value should
# be between 0 and 1. The higher the value, the more quickly
# your program learns the changes in the background. Therefore,
@radames
radames / opencv_video_to_pygame.py
Last active April 17, 2023 15:34
OpenCV VideoCapture running on PyGame - repo ref https://github.com/radames/opencv_video_to_pygame
from pygame.locals import KEYDOWN, K_ESCAPE, K_q
import pygame
import cv2
import sys
camera = cv2.VideoCapture(1)
pygame.init()
pygame.display.set_caption("OpenCV camera stream on Pygame")
screen = pygame.display.set_mode([1280, 720])
@dave-andersen
dave-andersen / kmeans.py
Last active September 1, 2022 11:15
k-means in Tensorflow
import tensorflow as tf
import numpy as np
import time
N=10000
K=4
MAX_ITERS = 1000
start = time.time()
from kivy.app import App
from kivy.clock import Clock
from kivy.lang import Builder
from kivy.properties import NumericProperty, ListProperty
from kivy.uix.widget import Widget
KV = '''
#:import chain itertools.chain
#:import sin math.sin
#:import cos math.cos