Huixuan's wlog

on computational photography and others

Archive for the ‘tools’ Category

Matlab+X11的诡异问题

leave a comment »

我的设置肯定没有问题,因为xclock确实显示在本地。但是开matlab,一模一样的display设置,窗口每次都是显示在remotehost端,无法理解⋯⋯
算了,在大屏上看figure也挺好的⋯⋯

好吧⋯⋯最后解决了⋯⋯打开matlab的时候用
matlab -noawt

原来用了
matlab -nodesktop

所以figure不是用X11的…

Written by hxtang

March 12, 2011 at 7:14 am

Posted in tools

g++和vnl_matrix_inverse的兼容问题

with 2 comments

今天终于完全figure out了TA的过程当中遇到的vnl_matrix_inverse在我机器上报private copy constructor错误的问题。看起来似乎是个语法问题,但vxl的文档写明了
x = vnl_matrix_inverse(A)*b;

x = vnl_svd(A).solve(b);
是等价的。

后来发现是因为我的g++编译器版本是4.2.1,把g++版本换到4.3.5以后就能通过编译了。

Written by hxtang

March 9, 2011 at 12:27 pm

Posted in tools

matlab in textmate + iterm + applescript

with one comment

不知道什么时候生出来的变态想法,不想好好地用matlab自带的desktop+editor,而想用textmate+iterm的组合。我觉得一定程度上是因为感觉上一个文本编辑器+terminal的组合很lightweight,也许就是纯粹洁癖而已。如果一定要使用的原因,那么就是textmate有bundles,啥重复性的任务基本都可以(在写了script后)快捷键一把。
现在还没有100%地搞定,先写一下大致的思想,以后慢慢补全吧。

俺需要的功能,主要就是textmate和iterm的交互了。
- 打开matlab并进入项目主目录。
这个用applescript就能做,其实手动也可以的。唯一的trick是iterm打开的时候要开好x11,否则matlab的graphics没法显示。
补充一下网上可以搜到一个叫pos的utility,可以从finder打开terminal,并cd到当前目录。这个很好用的说。
- 从textmate上进行断点调试,并用bookmark来标记/取消断点。
这个地方有点tricky。俺的想法是从textmate给iterm window 发送dbstop/dbclear等命令,并同时trigger bookmark当前行的快捷键。嗯,很dirty…
比较郁闷的是textmate添加和取消bookmark是一个命令,但是matlab添加和取消断点是不同命令。现在想到个很土的hack是写个函数来读断点状态以确定call哪个函数…
还没有想到怎么清除一个project里面所有的bookmark…
- 看workspace。
这个不知道怎么弄。

Written by hxtang

March 4, 2011 at 12:09 pm

Posted in tools

camera control的几个trick

with one comment

在拍照前要确保写进去的新文件原来不存在,也就是不能overwrite
因为overwrite速度会偏慢,然后程序又送新的命令进去,camera太busy了整个控制程序就崩溃了…

单纯refocus不拍照需要打开liveview,否则不work…

用的program基本和canon sdk给的那个例子一样

Written by hxtang

February 22, 2011 at 8:30 am

Posted in experiment, tools, wlog

libexiv2

with 2 comments

读exif的工具其实还挺多的,今天试了试exiv2这个c++的库。
贴一小段代码吧

#include <string>
#include <exiv2/image.hpp>;
#include <exiv2/exif.hpp>;
using namespace Exiv2;
...
struct ExifInfo 
	{
		float focal_length;
		float exposure;
		float aperture;
		long int iso;
		std::string model;
	}exif;
...
// get exif data
Image::AutoPtr img_temp = ImageFactory::open(image_name);
img_temp->readMetadata();
ExifData exif_data = img_temp->exifData();
// read data to structure
exif.focal_length = exif_data["Exif.Photo.FocalLengthIn35mmFilm"].toFloat();
exif.exposure = exif_data["Exif.Photo.ExposureTime"].toFloat();
exif.aperture = exif_data["Exif.Photo.FNumber"].toFloat();
exif.iso = exif_data["Exif.Photo.ISOSpeedRatings"].toLong();
exif.model = exif_data["Exif.Image.Model"].toString();

Written by hxtang

December 14, 2010 at 8:19 am

Posted in tools

opencv: features2d

with 3 comments

封装得非常好,detector, descriptor, matcher的界面都非常好用。几年前我曾经试图自己写一个这样的界面,后来写起来实在太累,加上我的因为编程能力太弱屈服于matlab,最后就放弃了。
这里就写一下opencv的detector先吧,descriptor和matcher的用法类似。

如果咬死了要用sift之类,可以直接用cv::SIFT(),但是如果像我不想把detector一开始定死,还有一种很灵活的用法。特别周全的是opencv连keypoint的显示都做进去了,甚至对有些detector,还配置了挑参数的类。
相对于matlab下顶多用用vlfeat,features2d提供的选择太丰富了。
下面是一个简单的使用例子:

#include <opencv2/opencv.hpp>
using namespace cv;
...
//detect SURF keypoints in the interested region in image, specified by mask
Ptr<FeatureDectector> detector = FeatureDetector::create("SURF");
detector->detect(image, keypoints, mask);
...
//draw in out_image keypoints overlaid on input image, with specified color
drawKeyPoints(image, keypoints, out_image, mark_color, DrawMatchesFlags::DRAW_OVER_OUTIMG);

Written by hxtang

December 14, 2010 at 7:49 am

Posted in tools

add command-line arguments for debug in xcode

with 2 comments

left panel->executables->Get Info->Arguments

Written by hxtang

December 14, 2010 at 4:17 am

Posted in tools

take advantage of opencv functionality in matlab’s mex function

with 3 comments

  1. install opencv using macport
  2. in mex file:
    • include “cv.h”, “highgui.h”, etc. as in any .cpp file
    • use namespace cv for convenience
    • when converting from mxArray * in mex to Mat in opencv, be careful with datatype
  3. compile example
    • mex face_detect.cpp -I/opt/local/include/opencv -L/opt/local/lib -lcv -lhighgui -lcvaux

Written by hxtang

December 5, 2010 at 11:34 am

Posted in tools

Follow

Get every new post delivered to your Inbox.