Skip to content

Instantly share code, notes, and snippets.

View qingswu's full-sized avatar

qingswu

  • Canada
View GitHub Profile
@qingswu
qingswu / allocator.hpp
Created March 6, 2016 15:03 — forked from kazuki-ma/allocator.hpp
OpenCV Custom Allocator for OpenGL, DirectX, QImage
// Custom Allocator for OpenCV's cv::Mat
// this code samples writen by facebook.com/matsuda.kazuki and published under public domain.
// You can copy and use this code in any situation under any license.
#ifndef __CVUT_ALLOCATOR__
#define __CVUT_ALLOCATOR__ 1
#include <opencv2/core/core.hpp>
/**
* Fast non-maximum suppression in C, port from
* http://quantombone.blogspot.com/2011/08/blazing-fast-nmsm-from-exemplar-svm.html
*
* @blackball (bugway@gmail.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
@qingswu
qingswu / arma2opencv.hpp
Created March 9, 2016 17:00 — forked from psycharo-zz/arma2opencv.hpp
convertions between armadillo and opencv
// convert an OpenCV multi-channel matrix to Armadillo cube. A copy is made
template <typename T, int NC>
Cube<T> to_arma(const cv::Mat_<cv::Vec<T, NC>> &src)
{
vector<cv::Mat_<T>> channels;
Cube<T> dst(src.cols, src.rows, NC);
for (int c = 0; c < NC; ++c)
channels.push_back({src.rows, src.cols, dst.slice(c).memptr()});
cv::split(src, channels);
return dst;
@qingswu
qingswu / preprocessor_fun.h
Created May 18, 2016 11:17 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@qingswu
qingswu / for_each_macro
Created May 19, 2016 14:13 — forked from dhh1128/for_each_macro
"for each"-style macro
// Accept any number of args >= N, but expand to just the Nth one.
// Here, N == 6.
#define _GET_NTH_ARG(_1, _2, _3, _4, _5, N, ...) N
// Define some macros to help us create overrides based on the
// arity of a for-each-style macro.
#define _fe_0(_call, ...)
#define _fe_1(_call, x) _call(x)
#define _fe_2(_call, x, ...) _call(x) _fe_1(_call, __VA_ARGS__)
#define _fe_3(_call, x, ...) _call(x) _fe_2(_call, __VA_ARGS__)
@qingswu
qingswu / eggs_detector.cpp
Created May 18, 2017 02:11 — forked from BloodAxe/eggs_detector.cpp
Image enchancement and Hough transform example
/**
* @brief Image enchancement and Hough transform example
* @author Eugene Khvedchenya <ekhvedchenya@gmail.com>
* @copyright computer-vision-talks.com/articles/how-to-detect-circles-in-noisy-image/
*/
#include <opencv2/opencv.hpp>
@qingswu
qingswu / client.cpp
Created November 21, 2017 04:57 — forked from SteveRuben/client.cpp
Multiple streaming in c++ using opencv; OpenCV video streaming over TCP/IP
/**
* OpenCV video streaming over TCP/IP
* Client: Receives video from server and display it
* by Steve Tuenkam
*/
#include "opencv2/opencv.hpp"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
@qingswu
qingswu / tf_data_augmentation_on_gpu.py
Created September 17, 2020 13:44 — forked from vertix/tf_data_augmentation_on_gpu.py
TF data augmentation on GPU
def augment(images, labels,
resize=None, # (width, height) tuple or None
horizontal_flip=False,
vertical_flip=False,
rotate=0, # Maximum rotation angle in degrees
crop_probability=0, # How often we do crops
crop_min_percent=0.6, # Minimum linear dimension of a crop
crop_max_percent=1., # Maximum linear dimension of a crop
mixup=0): # Mixup coeffecient, see https://arxiv.org/abs/1710.09412.pdf
if resize is not None: