Skip to content

Instantly share code, notes, and snippets.

@nkint
nkint / gist:7790728
Created December 4, 2013 16:35
python as sh: print all the directory recursively
import os, sys
rootdir = sys.argv[1]
for root, subfolders, files in os.walk(rootdir):
dirs = [ os.path.abspath(rootdir)+ root[1:] + "/" + s for s in subfolders ]
for d in dirs: print d
@nkint
nkint / gist:7695359
Created November 28, 2013 17:21
openc2qimage2gltexture
cv::Mat original = //...
QImage qtFrame(original.data, original.size().width, original.size().height, original.step, QImage::Format_RGB888);
qtFrame = qtFrame.rgbSwapped();
m_GLFrame = QGLWidget::convertToGLFormat(qtFrame);
glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@nkint
nkint / opencv2qt
Last active March 6, 2017 08:42
cv::Mat to QPixmap
cv::Mat n = ...
QPixmap p = QPixmap::fromImage(QImage((unsigned char*) n.data,
n.cols,
n.rows,
QImage::Format_RGB888));
p = p.scaledToWidth(500);
label->setPixmap( p );
@nkint
nkint / lazy_set.py
Created February 9, 2011 18:26 — forked from rik0/lazy_set.py
import itertools as it
def setness(f):
        setness.calls = dict()
        def decorator(arg):
                seen = setness.calls.get( arg, set() )
                for i in seen: yield i
                for i in f(arg):
                        if i not in seen:
                                seen.add(i)