Skip to content

Instantly share code, notes, and snippets.

@prostoiChelovek
prostoiChelovek / image.png
Last active April 10, 2020 10:17
dispenser configuration
image.png
@prostoiChelovek
prostoiChelovek / fixBound.hpp
Created September 9, 2019 08:26
Simple function to prevent rect from going abroad
#include <opencv2/core.hpp>
static bool fixBound(cv::Rect &rect, const cv::Size &roi) {
bool ok = true;
if (rect.width <= 0) {
ok = false;
rect.width = roi.width;
}
if (rect.height <= 0) {
ok = false;
@prostoiChelovek
prostoiChelovek / NeuralNet.hpp
Last active September 9, 2019 08:07
Simple wrapper around OpenCV DNN module
//
// Created by prostoichelovek on 14.08.19.
//
#ifndef NEURALNET_HPP
#define NEURALNET_HPP
#include <string>
#include <utility>
#include <vector>
@prostoiChelovek
prostoiChelovek / log.hpp
Last active September 9, 2019 08:17
Simple log function
#include <iostream>
enum LogType {
INFO, WARNING, ERROR
};
template<typename T>
void coutMany(T t) {
std::cout << t << " " << std::endl;
@prostoiChelovek
prostoiChelovek / main.cpp
Created August 10, 2019 12:20
opencv SMV testing
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/face.hpp>
#include <opencv2/ml.hpp>
using namespace std;
using namespace cv;
@prostoiChelovek
prostoiChelovek / svm_faceDescriptor_classification.cpp
Created July 26, 2019 15:02
Classification of 128D face descriptors using Dlib`s SVM
#include <iostream>
#include <ctime>
#include <vector>
#include <dlib/svm.h>
using namespace std;
using namespace dlib;
int main() {
cmake_minimum_required(VERSION 3.11)
project(dlibFaces)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory($ENV{HOME}/dlib dlib_build)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
@prostoiChelovek
prostoiChelovek / setupPiWifi.sh
Created June 18, 2019 09:00
simple sctipr for setup wifi password on RPI headless
#!/usr/bin/env bash
cd /media/`whoami`/rootfs/
cd /etc/wpa_supplicant/
echo "" >> wpa_supplicant.conf
echo "network={" >> wpa_supplicant.conf
echo " ssid=\"${1}\"" >> wpa_supplicant.conf
echo " psk=\"${2}\"" >> wpa_supplicant.conf
echo " key_mgmt=WPA-PSK" >> wpa_supplicant.conf
echo "}" >> wpa_supplicant.conf
@prostoiChelovek
prostoiChelovek / dict.sh
Created June 18, 2019 06:56
simple script that makes custom dict using big language dict
#!/usr/bin/env bash
while read p; do
word=`echo $p | sed 's/ .*//'`
if [[ ${word} == "" ]]; then
continue
fi
if [[ ${word} == *"("* ]]; then
continue
vector<int> string2int(const string &str) {
vector<int> res;
string temp = str;
map<string, int> oneDgtNums = {{"ноль", 0},
{"один", 1},
{"два", 2},
{"три", 3},
{"четыре", 4},
{"пять", 5},
{"шесть", 6},