Skip to the relevant sections if needed.
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
void imageScaleAndRotate(const cv::Mat &src, cv::Mat &out, double scale, double roll) { | |
// scaling | |
cv::Mat imSmall; | |
cv::resize(src, imSmall, cv::Size(), scale, scale); | |
// prepare for rotating | |
int width = imSmall.cols, height = imSmall.rows; | |
int diagonal = int(sqrt(height * height + width * width)); | |
int offsetX = (diagonal - width) / 2, offsetY = (diagonal - height) / 2; |
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
all: | |
cc -shared -fPIC lib_one.c lib_one.h -o libone.so | |
cc -shared -fPIC lib_two.c lib_two.h -o libtwo.so -L. -lone -Wl,-rpath=libs | |
mkdir -p libs | |
mv libone.so libs | |
# -L. 是针对编译时的,使得链接器(ld)可以在 gcc 编译时找到 libtwo.so 让 name loopup 成功 | |
# -rpath=. 是针对运行时的,使得在执行 main 时让动态链接器(ld.so)可以找到 main 依赖的 so | |
# Wl 表示后面的是一个链接器选项(针对 ld,而不是 gcc 的选项) | |
cc main.c -o main -L. -ltwo -Wl,-rpath=. |
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 <cstddef> | |
#include <cstdlib> | |
template <typename R, auto getter, auto setter, size_t (*offset)()> | |
struct property { | |
inline R *self() { | |
return reinterpret_cast<R *>(reinterpret_cast<size_t>(this) - offset()); | |
} | |
inline operator auto() { return (self()->*getter)(); } | |
inline void operator=(auto t) { (self()->*setter)(t); } |
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
/* recursive mkdir based on | |
http://nion.modprobe.de/blog/archives/357-Recursive-directory-creation.html | |
*/ | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <string.h> | |
#define PATH_MAX_STRING_SIZE 256 |
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
Lisp interpreter in 90 lines of C++ | |
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second. | |
Just for fun I wondered if I could write one in C++. My goals would be | |
1. A Lisp interpreter that would complete Peter's Lis.py test cases correctly... | |
2. ...in no more than 90 lines of C++. | |
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake! |
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
#!/bin/bash | |
## This gist contains instructions about cuda v11.2 and cudnn8.1 installation in Ubuntu 20.04 for Pytorch 1.8 & Tensorflow 2.7.0 | |
### steps #### | |
# verify the system has a cuda-capable gpu | |
# download and install the nvidia cuda toolkit and cudnn | |
# setup environmental variables | |
# verify the installation | |
### |
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 <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <windows.h> // 各种位图数据结构 | |
class Converter | |
{ | |
public: | |
Converter() : pixels_(NULL), width_(0), height_(0) {} |
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
#!/bin/sh | |
# Copy the contents of this file to the clipboard, then get a terminal open on your device and enter: | |
# $ cat > n.sh | |
# [Ctrl+V] or Right Click, Paste. Then [Ctrl+D]. | |
# chmod +x n.sh | |
# To run: ./n.sh eth0 | |
SLP=1 # display / sleep interval | |
DEVICE=$1 | |
IS_GOOD=0 | |
for GOOD_DEVICE in `grep \: /proc/net/dev | awk -F: '{print $1}'`; do |
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
name: "YOLONET" | |
layer { | |
name: "data" | |
type: "Input" | |
top: "data" | |
input_param { shape: { dim: 1 dim: 3 dim: 416 dim: 416 } } | |
} | |
layer { | |
name: "conv1" | |
type: "Convolution" |
NewerOlder