Skip to content

Instantly share code, notes, and snippets.

View leandrobmarinho's full-sized avatar

Leandro Bezerra Marinho leandrobmarinho

View GitHub Profile
@leandrobmarinho
leandrobmarinho / darknet_opencv_camera.py
Last active December 2, 2023 20:18
Darknet using OpenCV in python
import cv2
import numpy as np
# Load YOLO
net = cv2.dnn.readNet("./yolov2.weights", "./cfg/yolov2.cfg")
classes = []
with open("./data/coco.names", "r") as f:
classes = [line.strip() for line in f]
# Set up OpenCV video capture
import os
import cv2
import glob
from pathlib import Path
FOLDER_VIDEOS = "<<PATH>>/*.mp4"
FOLDER_FRAMES = "<<PATH>>"
for i, video in enumerate(glob.glob(FOLDER_VIDEOS)):
@leandrobmarinho
leandrobmarinho / virtualenv_4_jupyter.sh
Last active April 16, 2019 14:52
Setting up an virtualenv for the Jupyter
# pip install ipykernel
python -m ipykernel install --user --name .env --display-name ".env"
@leandrobmarinho
leandrobmarinho / fixed_matplotlib.sh
Created March 15, 2019 00:05
ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework
echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
# https://stackoverflow.com/questions/52629661/matplotlib-3-0-with-osx-backend
@leandrobmarinho
leandrobmarinho / yolo.py
Last active December 11, 2021 09:37
An example in Python using Yolo from Opencv.
import cv2
import numpy as np
scale = 0.00392
classes_file = "coco.names"
weights = "yolov2.weights"
config_file = "yolov2.cfg"
# read class names from text file
classes = None
@leandrobmarinho
leandrobmarinho / read_fstream.cpp
Created March 6, 2019 21:29
Here is a simple program in C++ to read a file using ifstream.
/*
Suppose the file has these values
inf1 inf2
*/
#include <iostream>
#include <fstream>
using namespace std;
int main () {
@leandrobmarinho
leandrobmarinho / fexists.cpp
Created March 6, 2019 21:20
Here is a simple program in C++ to verify if a file exists using ifstream.
#include <iostream>
#include <fstream>
using namespace std;
bool fexists(const char *filename)
{
ifstream ifile(filename);
return ifile;
}