This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| displayDebug = .... | |
| // turn black pixels into alpha 0 | |
| if(displayDebug.channels()==1) | |
| cv::cvtColor(displayDebug, displayDebug, CV_GRAY2BGR); | |
| cv::cvtColor(displayDebug, displayDebug, CV_BGR2BGRA); | |
| for (cv::Mat4b::iterator it = displayDebug.begin<cv::Vec4b>(); it != displayDebug.end<cv::Vec4b>(); it++) { | |
| if (*it == cv::Vec4b(0, 0, 0, 255)) { | |
| *it = cv::Vec4b(0, 0, 0, 0); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv::Rect roi( cv::Point( originX, originY ), smallImage.size() ); | |
| smallImage.copyTo( bigImage( roi ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i=1 | |
| for avi in *.mp4; do | |
| name=`echo $avi | cut -f1 -d'.'` | |
| jpg_ext='.jpg' | |
| echo "$i": extracting the first frame of the video "$avi" into "$name$jpg_ext" | |
| ffmpeg -loglevel panic -i $avi -vframes 1 -f image2 "$name$jpg_ext" | |
| i=$((i+1)) | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| import os | |
| # this two lines are for loading the videos. | |
| # in this case the video are named as: cut1.mp4, cut2.mp4, ..., cut15.mp4 | |
| videofiles = [n for n in os.listdir('.') if n[0]=='c' and n[-4:]=='.mp4'] | |
| videofiles = sorted(videofiles, key=lambda item: int( item.partition('.')[0][3:])) | |
| video_index = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void displayText(const QString &text, const QColor &backgroundColor, const QColor &textColor, const Vec3D &pos) | |
| { | |
| // some magic number (margin, spacing, font size, etc..) | |
| int fontSize = 15; | |
| int text_width=text.size()*(fontSize/1.5)+5, text_height=fontSize+20; | |
| // create the QImage and draw txt into it | |
| QImage textimg(text_width, text_height, QImage::Format_RGB888); | |
| { | |
| QPainter painter(&textimg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| find `pwd` |
OlderNewer