Skip to content

Instantly share code, notes, and snippets.

@eloquentarduino
eloquentarduino / smaller_iris_classification.ino
Created February 9, 2020 18:26
Even smaller IRIS classification for microcontrollers
/**
* Do dot product between vectors
*/
double compute_kernel(double x[3], ...) {
va_list w;
double kernel = 0.0;
va_start(w, 3);
for (uint16_t i = 0; i < 3; i++)
kernel += x[i] * va_arg(w, double) ;
return kernel;
"""
Install the dependencies with
pip install matplotlib sklearn mlxtend
"""
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
from mlxtend.plotting import plot_decision_regions
dataset = '''
// 1
-10.00,-11.00,-14.31,-8.93,-15.84,-34.12,-45.63,-46.56,-66.47,-77.33,-89.85,-98.59,-107.57,-115.89,-120.41,-123.71,-123.71,-121.38,-115.89,-110.24,-100.23,-90.59,-79.95,-68.72,-57.38,-46.01,-36.19,-27.44,-19.98,-14.31,-10.91,-9.76
-10.00,-10.91,-14.19,-19.82,-27.22,-35.01,-44.49,-55.50,13.52,-79.29,-92.08,-101.87,-110.24,-2.83,-121.38,-29.93,-119.72,-123.34,21.67,-106.68,-102.70,-92.08,-81.26,-69.85,-58.79,-47.15,-36.49,-27.44,-20.14,-14.31,-6.35,-6.32
-9.44,-11.09,-14.54,-16.89,-26.99,-30.85,-30.04,-56.91,-22.53,-79.95,-18.56,-101.87,-90.68,-87.62,-115.51,-124.70,-122.71,30.35,-0.94,-110.24,-102.70,-92.82,-81.91,-69.85,-58.32,-47.15,-36.79,-27.66,-20.14,-14.43,-11.00,-9.84
-9.52,-11.18,-14.07,-19.82,-26.77,-34.41,-23.96,-30.57,-68.72,-82.57,-69.80,-98.59,-100.46,-8.48,-119.43,-119.72,-116.72,22.51,37.69,38.23,-8.22,-72.77,-78.64,-68.16,-54.56,-29.66,0.89,1.12,-12.02,-14.19,-10.91,-9.76
-10.00,-11.27,5.51,-20.31,-27.88,-37.08,-46.01,-59.26,-70.98,7.21,-92.08,-101.05,-112.02,32.98,-122.36,-
@eloquentarduino
eloquentarduino / README.md
Created March 8, 2020 10:36
ESP32 cam motion debug tool

ESP32 motion detection debug tool

This gist setups a simple debug tool for your pure ESP32 camera motion detection project. It lets you visualize the video streaming from the camera and highlights the differences from a frame to the previous.

To make it work you need to:

  1. upload the ESP32 naive motion detection sketch to your ESP32 camera
  2. put the two files below in a folder
@eloquentarduino
eloquentarduino / scan_wifi_for_indoor_positioning.py
Created March 3, 2021 12:57
Wifi indoor positioning for PC/Raspberry Pi
import json
from rssi import RSSI_Scan
from time import sleep
if __name__ == '__main__':
scanner = RSSI_Scan('wlp2s0')
lines = []
while True:
import numpy as np
from principalfft import PrincipalFFT
from numpy.fft import rfft
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_digits
from sklearn.ensemble import RandomForestClassifier
mnist = load_digits()
X, y = mnist.data, mnist.target
Xfft = PrincipalFFT(n_components=8).fit_transform(X)