Skip to content

Instantly share code, notes, and snippets.

View doleron's full-sized avatar
💭
I may be slow to respond.

Luiz doleron | Luiz d'Oleron doleron

💭
I may be slow to respond.
View GitHub Profile
@doleron
doleron / config_cmake_eclipse_git_project.sh
Last active December 25, 2017 15:45
Bash script to import CMake project from Github and create local Eclipse CDT compatible project
#!/bin/bash
###################################################################################################
# Bash script to import CMake project from Github and create local Eclipse CDT compatible project #
# #
# The CMake Eclipse CDT strategy was taken from here: https://stackoverflow.com/a/9663686/3055724 #
# After run this script you need to import the project in eclipse: #
# File->Import->C/C++->Existing code as Makefile Project->Next #
# Tested in Eclise Oxygen and Luna #
###################################################################################################
@doleron
doleron / forward.txt
Last active September 25, 2018 13:22
// inverse kinematics
// helper functions, calculates angle theta1 (for YZ-pane)
int delta_calcAngleYZ(float x0, float y0, float z0, float &theta) {
float y1 = -0.5 * 0.57735 * f; // f/2 * tg 30
y0 -= 0.5 * 0.57735 * e; // shift center to edge
// z = a + b*y
float a = (x0*x0 + y0*y0 + z0*z0 +rf*rf - re*re - y1*y1)/(2*z0);
float b = (y1-y0)/z0;
// discriminant
float d = -(a+b*y1)*(a+b*y1)+rf*(b*b*rf+rf);
@doleron
doleron / wifi_relay_module.ino
Last active May 5, 2019 13:02
Esp8266 01 cheap WIFI Relay Module from Shenzhen LC Technology Co or just lctech-inc.com. Just a example how to control the relay by sending serial hex codes
void setup() {
Serial.begin(9600);
}
void loop() {
byte close[] = {0xA0, 0x01, 0x01, 0xA2};
Serial.write(close, sizeof(close));
delay(2000);
byte open[] = {0xA0, 0x01, 0x00, 0xA1};
@doleron
doleron / sync your fork with original repo.md
Last active June 18, 2020 03:01
commands to synchronize your fork with original repo
@doleron
doleron / medium_yolov5_frame_input.py
Last active January 23, 2022 11:36
python format input
def format_yolov5(source):
# put the image in square big enough
col, row, _ = source.shape
_max = max(col, row)
resized = np.zeros((_max, _max, 3), np.uint8)
resized[0:col, 0:row] = source
# resize to 640x640, normalize to [0,1[ and swap Red and Blue channels
result = cv2.dnn.blobFromImage(resized, 1/255.0, (640, 640), swapRB=True)
#include <opencv2/opencv.hpp>
int main(int, char **)
{
auto net = cv::dnn::readNet("yolov5s.onnx");
return 0;
}
@doleron
doleron / medium_yolov5_importing_model.py
Last active January 23, 2022 11:37
Python loading model
import cv2
net = cv2.dnn.readNet('yolov5s.onnx')
@doleron
doleron / medium_yolov5_calling_model.cpp
Last active January 23, 2022 11:47
C++ calling model
std::vector<cv::Mat> predictions;
net.forward(predictions, net.getUnconnectedOutLayersNames());
const cv::Mat &output = predictions[0];
@doleron
doleron / medium_yolov5_calling_model.py
Last active January 23, 2022 11:47
Python calling model
predictions = net.forward()
output = predictions[0]
@doleron
doleron / medium_yolov5_unwrapping_data.py
Last active January 23, 2022 12:49
Python unwrapping the data
def unwrap_detection(input_image, output_data):
class_ids = []
confidences = []
boxes = []
rows = output_data.shape[0]
image_width, image_height, _ = input_image.shape
x_factor = image_width / 640