Skip to content

Instantly share code, notes, and snippets.

View codebudo's full-sized avatar

Sebastian Mikkel Wilson codebudo

View GitHub Profile
@codebudo
codebudo / CMakeLists.txt
Created July 30, 2019 04:56
CMake file for compiling OpenCV tests
cmake_minimum_required(VERSION 2.8)
project( OpenCVTest )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( resizecpu resize_cpu.cpp )
target_link_libraries( resizecpu ${OpenCV_LIBS} )
add_executable( resizegpu resize_gpu.cpp )
target_link_libraries( resizegpu ${OpenCV_LIBS} )
@codebudo
codebudo / resize_gpu.cpp
Created July 30, 2019 04:54
OpenCV example resizing an image with CUDA GPU acceleration
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include "opencv2/cudaimgproc.hpp"
using namespace cv;
int main(int argc, char** argv ) {
if ( argc != 2 ) {
printf("usage: resizegpu <Image_Path>\n");
return -1;
@codebudo
codebudo / resize_cpu.cpp
Created July 30, 2019 04:50
OpenCV example resizing an image with CPU
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv ) {
if ( argc != 2 ) {
printf("usage: resizecpu <Image_Path>\n");
return -1;
}
@codebudo
codebudo / Dockerfile
Created July 30, 2019 04:31
Dockerfile for generating a CUDA + OpenCV 4.11 build container.
FROM nvidia/cuda:10.1-devel-ubuntu18.04
WORKDIR /build
RUN apt-get update
RUN apt-get install -y unzip python3 cmake g++
ADD vendor/opencv-4.1.1.tar.gz /build/
ADD vendor/opencv_contrib-4.1.1.tar.gz /build/
@codebudo
codebudo / mock.test.js
Created May 2, 2019 20:29
Kinda pseudocode test describing the use of beforeEach to create input data for a test.
/* eslint-env node, mocha */
const should = require('should');
describe('Some encrypt/decrypt test', function(){
const passphrase = 'good passphrases are long';
const passphraseIV = Buffer.from('AAAAAAAAAAAAAAAAAAAAAA==', 'base64');
let fileBlob = 'start';
let ciphertext = null;
let nock = require('nock');
@codebudo
codebudo / MultiSpeedI2CScanner.ino
Created March 16, 2019 00:49
Not my code, but found in an old forum post. Moving to Github so it can be forked, etc.
//
// FILE: MultiSpeedI2CScanner.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.04
// PURPOSE: I2C scanner @different speeds
// DATE: 2013-11-05
// URL: http://forum.arduino.cc/index.php?topic=197360
//
// Released to the public domain
//
from rplidar import RPLidar
lidar = RPLidar('/dev/tty.SLAB_USBtoUART')
info = lidar.get_info()
print(info)
health = lidar.get_health()
print(health)
for i, scan in enumerate(lidar.iter_scans()):
import numpy as np
import cv2 as cv
import glob
import pickle
# termination criteria
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 30, 0.001)
# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
objp = np.zeros((6*6,3), np.float32)
@codebudo
codebudo / imagecap.py
Created February 23, 2019 20:03
Capture a series of images from the raspberry pi camera
from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
import time
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (1280, 720)
camera.framerate = 10
rawCapture = PiRGBArray(camera, size=(1280, 720))