This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from glob import glob | |
import cv2 | |
pngs = glob('./*.png') | |
for j in pngs: | |
img = cv2.imread(j) | |
cv2.imwrite(j[:-3] + 'jpg', img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from glob import glob | |
import cv2 | |
jpgs = glob('./*.jpg') | |
shapes = [cv2.imread(f).shape for f in jpgs] | |
a = [list(i) for i in shapes] | |
width = [row[1] for row in a] | |
height = [row[0] for row in a] | |
print 'width min:', min(width), ', max:', max(width), '; height min:', min(height), ', max:', max(height) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake -DWITH_CUDA=ON -DWITH_CUFFT=ON -DWITH_CUBLAS=ON -DCMAKE_BUILD_TYPE=Release -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DBUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_DOCS=OFF -DCUDA_ARCH_BIN=3.0 -DCUDA_ARCH_PTX=3.0 -DPYTHON2_LIBRARY=$(python-config --prefix)/lib/libpython2.7.dylib -DPYTHON2_INCLUDE_DIR=$(python-config --prefix)/include/python2.7 .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create new build dir | |
rm -rf build | |
cd build | |
cmake .. # some options | |
cmake --build . --config release --target install # build install | |
cmake --build . --config releasee --target clean # cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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> |
OlderNewer