Skip to content

Instantly share code, notes, and snippets.

@satoruhiga
satoruhiga / utf8string2wstring.cpp
Created September 6, 2011 10:13
utf8string2wstring.cpp
#include <iconv.h>
#include <string>
int convert(string input, wstring &output)
{
char *inbuf, *iptr, *outbuf, *wptr;
iconv_t cd;
size_t nconv, inlen, avail;
@satoruhiga
satoruhiga / ofxRecordableOscReceiver.h
Created September 23, 2011 00:32
ofxRecordableOscReceiver
#pragma once
#include "ofMain.h"
#include "ofxOsc.h"
#define OFX_RECOSC_SAVE_XML
#ifdef OFX_RECOSC_SAVE_XML
#include "ofxXmlSettings.h"
#endif
@satoruhiga
satoruhiga / ofxSimpleParticleSystem.h
Created September 29, 2011 14:06
ofxSimpleParticleSystem
#pragma once
#include "ofMain.h"
#include <tr1/array>
/*
// EXAMPLE
#include "testApp.h"
#include "ofxSimpleParticleSystem.h"
@satoruhiga
satoruhiga / testApp.cpp
Created October 19, 2011 16:58
Multithreaded image loading
#include "testApp.h"
static CGLContextObj ctx;
static CGLPixelFormatObj pixStuff;
class MyThread : public ofThread
{
public:
ofImage image;
@satoruhiga
satoruhiga / homography2glModelViewMatrix.h
Created December 5, 2011 08:45
homography2glModelViewMatrix
inline ofMatrix4x4 homography2glModelViewMatrix(const cv::Mat &homography)
{
ofMatrix4x4 matrix;
matrix(0, 0) = homography.at<double>(0, 0);
matrix(0, 1) = homography.at<double>(1, 0);
matrix(0, 2) = 0;
matrix(0, 3) = homography.at<double>(2, 0);
matrix(1, 0) = homography.at<double>(0, 1);
@satoruhiga
satoruhiga / readDepthPixelsToImage.h
Created December 11, 2011 12:38
readDepthPixelsToImage
void readDepthPixelsToImage(ofFloatImage &image)
{
glPopAttrib();
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, image.getWidth(), image.getHeight(), GL_DEPTH_COMPONENT, GL_FLOAT, image.getPixels());
glPopClientAttrib();
image.update();
}
@satoruhiga
satoruhiga / cstringify.py
Created December 15, 2011 06:50
cstringify.py
#/usr/bin/env python
import sys, os
if len(sys.argv) is not 2:
print 'usage: ./cstringify.py [FILENAME]'
sys.exit(-1)
filename = sys.argv[1]
@satoruhiga
satoruhiga / cvFlannTest.cpp
Created December 26, 2011 07:45
cvFlannTest.cpp
#include "testApp.h"
#include "ofxCv.h"
using namespace ofxCv;
using namespace cv;
#include <opencv2/flann/flann.hpp>
ofMesh mesh;
@satoruhiga
satoruhiga / loadObj.h
Created January 10, 2012 11:19
load .obj file
#pragma once
#include "ofMain.h"
bool loadObj(string path, ofMesh &mesh, ofImage *tex = NULL)
{
path = ofToDataPath(path);
if (!ofFile::doesFileExist(path)) return false;
ifstream ifs(path.c_str());
@satoruhiga
satoruhiga / zcompress.cpp
Created January 21, 2012 16:43
compress with zlib
#include <zlib.h>
bool zcompress(const string& input, string& output)
{
z_stream z;
z.zalloc = Z_NULL;
z.zfree = Z_NULL;
z.opaque = Z_NULL;