Sony PS3 Eye webcam with v4l2
Finally got this working again.
- The two webcams worked perfectly on my old desktop computer with Linux kernel 2.6.30 (which has gspca 2.6.0 built in). I could send commands to them via v4l2 to change exposure etc.
- Then I ported the code to a new machine running 64-bit Ubuntu 10.04, kernel 2.6.32 (comes with gspca 2.7.0). The cam still worked, but I had no access to the controls, e.g. exposure, gain and flipping. I spent two days switching back to kernel 2.6.30/31, trying different patches posted on open source forums, modifying the kernels, making an identical OS from the old machine to the new one… no luck.
- But the solution turns out to be simple: check out the latest source code (2.9.0) from www.linuxtv.org, compile it and load it into the kernel. Bang. But I still don’t know why an identical OS with identical driver wouldn’t work on the new computer.
Well, at least problem solved, time to move forward.
Filed under Tech | Tags: coding, thesis | Comment (0)Getting ps3 camera working with OF in Ubuntu 9.10
Just spent a whole morning to get this done, here are some quick notes.
- Newly installed Ubuntu 9.10 as a virtual machine in Mac OS X.
- Download OF source code, run the scripts in the package to install code::blocks and all the dependencies.
- I chose movieGrabber for testing. Code::blocks will report missing libraries such as gstreamer. If you run pkg-config –list-all, it’ll likely end up with “libdrm is not found”. To solve, run apt-get install libdrm-dev
- We need a decoder as well: apt-get install gstreamer0.10-ffmpeg
- Re-launch Code::Blocks and compile, it should work at this step.
绑定子域名
国内很多主机都不支持绑定域名到子目录上,其实用一段javascript就能实现。
<script type=”text/javascript”>
var str = location.hostname
var domain1 = “domain1.com”
var domain2 = “domain2.com”
if (str.match(domain1) == domain1)
window.location = “new URL#1″
else if (str.match(domain2) == domain2)
window.location = “new URL#2″
</script>
对于Wordpress系统,这段代码最好扔到所用主题的header.php里<body>段的开头,如果直接放在index.php里可能会把WP的RSS弄坏掉,出现”XML declaration allowed only at the start of the document”(Safari下)之类的错误(我到今天才发现RSS已经挂掉一周了……)。
ps. 可以到Feed Validator验证RSS是否有效。
Filed under Tech | Tags: javascript, rss, 域名 | Comment (0)2眼
刚刚搞定了对reacTIVision的改造,实现了两个PS3 eye同时采集图像,分辨率翻倍~用现在的代码理论上还可以扩充到4个摄像头,只要USB总线不堵塞,CPU不烧掉。现在两个头就已经把macbook pro 2.4G的CPU跑满了,其中一个头的FPS还掉到了30以下。明天开始看看能不能做点优化。
还算高效,只花了6天。之间也走了不少弯路,比如尝试用UDP进行摄像头驱动和reacTIVision的通信,结果延迟严重,貌似还丢包。接下来就等老板出差回来批钱开工。
心情大好啊,可是天都黑了,没地方庆祝,郁闷。
Filed under Once in Canada, Tech | Comment (0)Vista小感
因为用实验室的本子调试tabletop的缘故,用了一个多月Vista,算是可以理解它为何销路不畅了。几个简单的例子:
1. 不时从右下角静悄悄的跳出来个窗口,提示重启以安装补丁,一边开始倒计时。哭笑不得:假设用户愿意重启,立刻就可以保存当前工作,重新启动,倒计时有p用;如果不愿意,你弄个倒计时干啥?要么把他正在用的文档和程序关个一干二净,等他回来给个惊喜,要么逼迫他停下手中的活儿取消倒计时。
2. 干活中,噗的一声,又是个气泡,愉快的邀请你查看windows为电脑问题找到的解决方案。不得不说,任务栏简直沦为一个藏污纳垢的所在,除了各种软件搭配着系统消息不断弹出气泡,不断热心打断你的工作之外,还有什么用。
3. 极其脆弱。那台笔记本上仅仅接了个1394口的摄像头,一个投影机,这两个设备就让vista蓝屏了两三次,还有几次自动重启不知是安装补丁还是崩溃所致了,还有一次甚至无法启动,磨蹭了半小时restore才活过来。
安上了幅漂亮皮囊,各种花哨功能也应有尽有,但UI不仅仅是美观,还需要有背后无数的细节支撑,适当的功能取舍。用户花钱是来使用系统的,而不是来当系统的维护员。Windows 7的消息也越来越多,又是个养眼的东西,不知道会有何改观。
Filed under Tech | Comment (0)Oh, China's first Artificial Brain
While looking for some papers this afternoon, I surprisingly find a professor Hugo de Garis who is carrying out the first Artificial Brain project in China, more amazingly, he’s granted by Xiamen Univ. with 3 Million RMB to work on the project during 2008-2011, said more millions will be given if needed. Here’s a piece of his speech:
The guy’s trying to evolve a neural network on hardware, to implement a brain to control hundreds of behaviors of robots. But what I cannot understand yet is, is XMU insane or just has too much money getting rot? Does it have enough kids to work on such kind of project? Alright, anyway, it can be a good news for me…
Filed under Tech | Tags: artificial, brain, Xiamen | Comment (0)OpenGL魔方一个
前一段边看OpenGL边练手,很早就在Mac下调通了(估计Linux也能跑吧),但Mac版发上来也没啥意义,于是今天移植到Windows下,姑且一发,有兴趣的同志试看看吧,自认为操作还是很友好的,鼠标左键拧它,右键控制视角,中键让它随机自拧。
这里下载。
Filed under OpenGL | Tags: OpenGL, 魔方 | Comment (0)OpenGL notes(5)
换到Glut上面,原先找到的cocoa那层都得重新写过。考虑到将来的移植问题,读取BMP的部分也就没用glaux(这玩意儿只有windows下能用……)和mac的库,自己弄了个读bmp的函数。写好之后测了半天,图片明明读进来了就是不显示纹理。折腾了一个下午,最后发现是个莫名其妙的问题导致bmp的头部读取不正常。
typedef struct tagBITMAPFILEHEADER
{
short int bfType; //specifies the file type
int bfSize; //specifies the size in bytes of the bitmap file
short int bfReserved1; //reserved; must be 0
short int bfReserved2; //reserved; must be 0
int bfOffBits; //species the offset in bytes from the bitmapfileheader to the bitmap bits
}BITMAPFILEHEADER;
很清楚的结构,short int长度2,int长度4,想当然的sizeof(BITMAPFILEHEADER)=14,试了一下,居然是16……搜了搜,发现这涉及结构体成员的对齐方式,把这段定义放进#pragma pack(1)和#pargma pack()之间即可。
原因是#pragma pack(n)指定了成员的对齐方式。对齐的时候,假设某个成员长度len,则取x=min(len, n),这个成员的起始地址就是x的整数倍。
据说intel和m$的面试题也考到这点,当然更深入。http://www.sf.org.cn/Article/base/200509/260.html
Filed under OpenGL | Tags: C++, OpenGL | Comment (0)ActionScript notes
OpenGL好几天没碰了,这些天扬在准备申请用的作品集,摄影专业的人自然是一堆照片要展示,然后就叫我帮着做个Flash的homepage。一开始打算javascript, html, flash混搭来着,后来实在排版不过来,全站flash了。扬对代码之类的东西不太熟悉,所以我就一直在打包,as3.0的好处真是体现得淋漓尽致。最后把读图、缩略图浏览、放大、滚动这些东西包好,他只要两行代码就能调用。
一些问题记录一下。
1. 判断Loader读取结束的时候,EventListener要加在Loader.contentLoaderInfo上面。
2. 做好的MC要在as里面建实例的话,先写个.as,做个flash.display.MovieClip子类出来(只要有个类定义就行),然后在Library里把MC链接到这个子类上面。用的时候建立那个子类的实例就可以得到MC了。当然,MC用到的Library里的东西得手动复制到新的fla里面。
3. 需要持续移动之类的效果最好还是弄个Timer来,在Timer的event handler里面做事。
4. 注册点要统一,不然一堆MC调来调去的,不断的算相对坐标,疯掉。
Filed under Tech | Tags: ActionScript, Flash | Comment (0)OpenGL notes(4)
这个有点CS的味道了,呵呵。从外部文件读取坐标作图,键盘控制视角的水平移动,也能抬头低头。
Filed under OpenGL | Comments (4)