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
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: |
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
def get_versions(): | |
versions = [] | |
import sys | |
versions.append('Python verison: {}.{}.{}'.format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro)) | |
import cv2 | |
versions.append('OpenCV: {}'.format(cv2.__version__)) | |
import numpy as np |
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
#include <opencv2/highgui.hpp> | |
#include <opencv2/videoio.hpp> | |
int main(int argc, char** argv) { | |
cv::VideoCapture cap(0); | |
// cap.set(cv::CAP_PROP_FRAME_WIDTH, 1280); | |
// cap.set(cv::CAP_PROP_FRAME_HEIGHT, 720); | |
cv::Mat im; |
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
/** | |
* 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> |
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 <[email protected]> | |
* @copyright computer-vision-talks.com/articles/how-to-detect-circles-in-noisy-image/ | |
*/ | |
#include <opencv2/opencv.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
# 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
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
#!/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
#!/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
// 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__) |
NewerOlder