Ubuntu 11.10相关

October 14, 2011 Leave a comment
Categories: Linux

Ubuntu里的经典软件

October 14, 2011 Leave a comment

Beryl:

sudo apt-get install beryl-manager beryl emerald-manager emerald

Checkgmail:

sudo apt-get install checkgmail

GParted:

sudo apt-get install gparted
Categories: Linux

Python调用外部命令zz

October 14, 2011 Leave a comment

在Python/wxPython环境下,执行外部命令或者说在Python程序中启动另一个程序的方法一般有这么几个:

1、os.system(command)

2、wx.Execute(command, syn=wx.EXEC_ASYNC, callback=None)
若置syn为wx.EXEC_ASYNC则wx.Excute函数立即返回,若syn=wx.EXEC_SYNC则等待调用的程序结束后再返回。
callback是一个wx.Process变量,如果callback不为None且syn=wx.EXEC_ASYNC,则程序结束后将调用wx.Process.OnTerminate()函数。

os.system()和wx.Execute()都利用系统的shell,执行时会出现shell窗口。如在Windows下会弹出控制台窗口,不美观。下面的两种方法则没有这个缺点。

3、class subprocess.Popen
最简单的用法是:

import subprocess
subprocess.Popen(command, shell=True)

如果command不是一个可执行文件,shell=True不可省。

前面三个方法只能用于执行程序和打开文件,不能处理URL,打开URL地址可用webbrowser模块提供的功能。

4、webbrowser.open(url)

调用系统缺省浏览器打开URL地址,如 webbrowser.open(‘http://www.google.com’),也可以利用
webbrowser.open(‘h:\python.zip’)来执行程序。这样可以不必区分是文件名还是URL,不知道在Linux下是否可行。

以上在Windows2000,Python2.4a1,wxPython 2.5.1运行。

modify:还有一种方式:subprocess.call(*args, **kwargs)

Categories: Linux, Python

Collection of Tutorials on Parallel Computing

October 14, 2011 Leave a comment
Categories: Linux, Parallelization

SSH远程运行Matlab脚本

October 11, 2011 Leave a comment

使用命令:

nohup matlab -nojvm -nodisplay -nosplash -nodesktop < matlabscript.m 1>running.log 2>running.err &

nohup matlab -nojvm -nodisplay -nosplash < matlabscript.m 1>running.log 2>running.err &

或:

nohup matlab -nojvm -nodisplay < matlabscript.m 1>running.log 2>running.err &

其中:
matlabscript.m是将要运行的脚本文件,存在于服务器上;
running.log是matlab标准屏幕输出的重定向文件,将建立于服务器上;
running.err是matlab运行时的错误重定向文件,将建立于服务器上。

(1) 如果你想中断正在运行的matlab请使用
kill -9 进程号 或 fg %n; Ctrl+C
(2) 如果你想在字符环境的matlab中运行脚本,请使用
run 脚本文件名 ( 不含.m扩展名 )
(3) 如果你想用ssh运行有X界面的matlab,登陆时请使用
ssh 主机名 -l 用户名 -X

Categories: Matlab

HOWTO: Install and use the latest FFmpeg and x264

October 5, 2011 Leave a comment

see the link: http://ubuntuforums.org/showthread.php?t=786095

add –enable-shared to ffmpeg configuration arguments

Categories: Linux, Vision

Tips and Tricks: A Comprehensive OpenCV Installation Troubleshooting Guide

October 2, 2011 Leave a comment

From: http://ozbots.org/opencv-install-troubleshooting/

[Revised 2011-08-29. See Change Log section for revision information.]

This guide lists solutions for problems you might encounter when installing OpenCV and its dependencies. Many of the problems are related to using webcams. This guide is a companion guide to “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu,” which can be found on ozbots.org.The problems are listed in the sequence that they might occur during a typical OpenCV install. If the problem is accompanied by an error message, the relevant part of the message is highlighted in yellow.

Here is a list of error messages that are addressed by this guide:

  • ERROR: libx264 not found
  • undefined reference to ‘x264_encoder_open_116′
  • libv4lconvert-priv.h:25:21: fatal error: jpeglib.h: No such file or directory
  • libv4l1.c:53:28: fatal error: linux/videodev.h: No such file or directory
  • /home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:492:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
  • libv4lconvert: warning more framesizes then I can handle!
  • [swscaler @ 0x89c3e30]No accelerated colorspace conversion found from yuv420p to bgr24.
  • error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory
  • VIDIOC_DQBUF: Input/output error
  • VIDIOC_QUERYMENU: Invalid argument

 

Problems Building ffmpeg

Problem
<84> .../ffmpeg$ ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
ERROR: libx264 not found

Solution
Use ffmpeg version 0.7.x. This error occurs if you configure ffmpeg version 0.6.x with the options shown above.

 

Problem
<84> .../ffmpeg$ make
LD ffmpeg_g
libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/home/osman/src/ffmpeg/ffmpeg-0.7.3/libavcodec/libx264.c:395: undefined reference to 'x264_encoder_open_116'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
Solution
Rebuild x264 and ffmpeg with the shared library option. To rebuild x264, change to the directory where you untared the x264 source files, and enter the following commands:
./configure --enable-shared --enable-pic
make
sudo make install

To rebuild ffmpeg, change to the directory where you untared the ffmpeg source files, and enter the following commands:

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
make
sudo make install

This solution comes from http://www.linuxquestions.org/questions/linux-newbie-8/problem-with-enable-libx264-option-in-ffmpeg-822156/page2.html.

 

Problems Building v4l

Problem
<37> .../v4l-utils-0.8.4 $ make
make -C lib all
make[1]: Entering directory `/home/osman/src/v4l/v4l-utils-0.8.4/lib'
make -C libv4lconvert all
make[2]: Entering directory `/home/osman/src/v4l/v4l-utils-0.8.4/lib/libv4lconvert'
cc -Wp,-MMD,"libv4lconvert.d",-MQ,"libv4lconvert.o",-MP -c -I../include -fvisibility=hidden -fPIC -DLIBDIR=\"/usr/local/lib\" -DLIBSUBDIR=\"libv4l\" -I../../include -I../../lib/include -D_GNU_SOURCE -DV4L_UTILS_VERSION='"0.8.4"' -g -O1 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -o libv4lconvert.o libv4lconvert.c
In file included from libv4lconvert.c:26:0:
libv4lconvert-priv.h:25:21: fatal error: jpeglib.h: No such file or directory compilation terminated.
make[2]: *** [libv4lconvert.o] Error 1
Solution
Install libjpeg. See “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu.”

 

Problem
<37> .../v4l-utils-0.8.4 $ make
...
cc -Wp,-MMD,"libv4l1.d",-MQ,"libv4l1.o",-MP -c -I../include -fvisibility=hidden -fPIC -I../../include -D_GNU_SOURCE -g -O1 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -o libv4l1.o libv4l1.c
libv4l1.c:53:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
make[2]: *** [libv4l1.o] Error 1

Solution
Use v4l-utils-0.8.4 or later. This problem occurs when trying to compile an old version of v4l in Ubuntu 11.x. I have not seen this problem on Ubuntu 10.x.

 

Problems Building OpenCV

Problem
Make fails at around 30% with an error building cap_ffmeg.o. This error might look like this:
[ 29%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o
In file included from /home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::reopen()’:

/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:492:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
...
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:828:10: error: ‘AVERROR_NUMEXPECTED’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:832:10: error: ‘AVERROR_NOFMT’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:834:10: error: ‘AVERROR_IO’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:836:10: error: ‘AVERROR_NOMEM’ was not declared in this scope

Solution
Install ffmpeg version 0.7.x. You are probably have version 0.8.x installed, which is not compatible with OpenCV 2.3.

 

Problems running a program using OpenCV libraries

Problem
$ ./my_webcam_program
libv4lconvert: warning more framesizes then I can handle!

Solution
Install v4l version 0.8.4 or later, and then run sudo ldconfig. Rerun your program; the message should go away. Note: I don’t really know in what version of v4l this was fixed, but I do know that it is fixed in version 0.8.4.

 

Problem
$ ./my_webcam_program
[swscaler @ 0x89c3e30]No accelerated colorspace conversion found from yuv420p to bgr24.
[swscaler @ 0x8893810]No accelerated colorspace conversion found from yuv420p to bgr24.
[swscaler @ 0x889c5b0]No accelerated colorspace conversion found from yuv420p to bgr24.
Last message repeated 1 times

Solution
The “accepted” solution is to rebuild x264 and ffmpeg with the shared library option. To rebuild x264, change to the directory where you untared the x264 source files, and enter the following commands:
./configure --enable-shared --enable-pic
make
sudo make install

To rebuild ffmpeg, change to the directory where you untared the ffmpeg source files, and enter the following commands:./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
make
sudo make install

After rebuilding x264 and ffmpeg, you do not need to rebuild OpenCV. If the swscaler message still occurs when you run your program, run sudo ldconfig, and run your program again.

This solution comes from the following thread on ubuntuforums.org: http://ubuntuforums.org/showthread.php?t=1471616

Unfortunately for me, configuring and recompiling x264 and ffmpeg does not make the warning meesage go away. If try the solution above, please let me know in the comments if it works for you.

 

Problem
$ ./my_webcam_program
error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory

Solutions (choose one)
1. Complete the “Configure Linux” step of the guide “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu.”
2. Set your LD_LIBRARY_PATHenvironment variable, as shown in the following example:export LD_LIBRARY_PATH=/usr/local/libReplace /usr/local/lib with the path where the OpenCV libraries are installed on your system.

 

Problem
VIDIOC_DQBUF: Input/output error
libv4l2: error converting / decoding frame data: v4l-convert: libjpeg error: Start Of Frame 0xc0: width=640, height=480, components=175
VIDIOC_DQBUF: Input/output error
libv4l2: error converting / decoding frame data: v4l-convert: libjpeg error: End Of Image

Solution
Make sure that your webcam is connected to a high-speed USB 2.0 port. I have seen this problem occur when my webcam was connected to a slower full-speed USB port.

 

Problem
<19> .../test1 $ ./my_webcam_program
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument

Solution
I have not found a solution to this problem. If you know a solution, please let me know! The message is coming from v4l. The message occurs when a webcam is initialized. I think that my webcam, a Logitech C910, does not conform to the UVC specification, and v4l has trouble querying the parameters of the webcam. I can still get frames from the webcam, so I just ignore the message.

 

Change Log

  • 2011-08-29 Added solution for ffmpeg make error undefined reference to 'x264_encoder_open_116'
Categories: Linux, Vision