Skip to content

Instantly share code, notes, and snippets.

🔒
busy

Dario Longobardi kashimAstro

🔒
busy
Block or report user

Report or block kashimAstro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kashimAstro
kashimAstro / floydSteinberg.h
Created Feb 19, 2016
C++ Floyd-Steinberg 24bit RGB color
View floydSteinberg.h
unsigned char * floydSteinberg(unsigned char * source, int w, int h){
unsigned char * newSource;
for(int i=0; i<(h*3); i++){
for(int j=0; j<w; j++) {
int ci = i*w+j;
int cc = source[ci];
int rc = (cc<128?0:255);
int err = cc-rc;
source[ci] = rc;
if(j+1<w) source[ci+1] += (err*7)>>4;
@kashimAstro
kashimAstro / pseudocode
Created Feb 19, 2016
pseudocode floyd steinberg
View pseudocode
per ogni y dall'alto in basso
per ogni x da sinistra a destra
vecchio_pixel := pixel[x][y]
nuovo_pixel := trova_il_colore_della_tavolozza_più_vicino(vecchio_pixel)
pixel[x][y] := nuovo_pixel
quant_errore := vecchio_pixel - nuovo_pixel
pixel[x+1][y] := pixel[x+1][y] + 7/16 * quant_errore
pixel[x-1][y+1] := pixel[x-1][y+1] + 3/16 * quant_errore
pixel[x][y+1] := pixel[x][y+1] + 5/16 * quant_errore
pixel[x+1][y+1] := pixel[x+1][y+1] + 1/16 * quant_errore
@kashimAstro
kashimAstro / i2cUDPMPU6050.py
Last active Feb 20, 2016
i2c UDP Demon Read MPU6050 data and write socket [ USAGE: python i2cUDPMPU6050.py '127.0.0.1' 5005 1 'N' ]
View i2cUDPMPU6050.py
#!/usr/bin/python
import smbus
import math
import socket
import sys
import time
if len(sys.argv) < 4:
sys.exit('Usage: %s IPADDRESS PORT ID_BUS_I2C' % sys.argv[0])
@kashimAstro
kashimAstro / IMUPosTracking.txt
Last active Mar 4, 2016
IMU positional tracking
View IMUPosTracking.txt
T = e' il tempo trascorso dall'ultimo calcolo della posizione
A = accelerazione singola asse IMU
S = vecchia velocita'
S1 = nuova velocita'
P = vecchia posizione
P1 = nuova posizione
calcoli:
S1 = S + A * T
P1 = P + S1 * T
@kashimAstro
kashimAstro / NoiseDithering.glsl
Last active Mar 4, 2016
Generated Noise pattern for dithering
View NoiseDithering.glsl
vec2 rand(vec2 coord, vec2 uv, float noiseamount, bool noise) {
float noiseX = ((fract(1.0-coord.s*(uv.x/2.0))*0.25)+(fract(coord.t*(uv.y/2.0))*0.75))*2.0-1.0;
float noiseY = ((fract(1.0-coord.s*(uv.x/2.0))*0.75)+(fract(coord.t*(uv.y/2.0))*0.25))*2.0-1.0;
if (noise) {
noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0;
noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0;
}
return vec2(noiseX,noiseY)*noiseamount;
}
@kashimAstro
kashimAstro / main.cpp
Created May 6, 2016
Menger sponge CPU ofMesh
View main.cpp
#include "ofMain.h"
class Menger : public ofBaseApp{
public:
ofEasyCam cam;
ofMesh mesh;
void setup() {
mesh = sponge(10,10,10,500,3,2);
}
@kashimAstro
kashimAstro / gstreamer-server-client.sh
Created Jun 2, 2016
Raspberry server and client RTP with gstreamer
View gstreamer-server-client.sh
#server
raspivid -t 999999 -w 800 -h 600 -fps 25 -hf -b 2000000 -o - | gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=192.168.0.100 port=5000
#client
gst-launch-1.0 -v tcpclientsrc host=192.168.0.100 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false
@kashimAstro
kashimAstro / HMC5883L.cpp
Last active Jun 3, 2016
ofxGPIO openframeworks example HMC5883L compass
View HMC5883L.cpp
#include "ofMain.h"
#include "ofAppNoWindow.h"
#include "ofxGPIO.h"
#include "ofxNetwork.h"
#define COMPASS 0x1e
class ofApp : public ofBaseApp{
public:
I2CBus * busCompass;
@kashimAstro
kashimAstro / BlenderSTLExport.py
Created Sep 16, 2016
Blender export .STL separate mesh fracture
View BlenderSTLExport.py
import bpy
import os
path = bpy.path.abspath('/tecnici/dario/teststl/')
if not os.path.exists(path):
os.makedirs(path)
for object in bpy.context.selected_objects:
bpy.ops.object.select_all(action='DESELECT')
object.select = True
@kashimAstro
kashimAstro / CVShape.h
Last active Oct 21, 2016
Class Opencv shape detection for openframeworks
View CVShape.h
#include "ofMain.h"
#include "ofxCv.h"
using namespace ofxCv;
using namespace cv;
class CVShape{
public:
Mat gray;
Mat bw;
You can’t perform that action at this time.