Wednesday, December 26, 2012

PCL on archlinux, VTK cmake error

When I compiled PCL on archlinux, I got this error
"
CMake Error at //lib/vtk-5.10/VTKTargets-debug.cmake:1281 (MESSAGE):
The imported target "vtkWrapTcl" references the file

"//bin/vtkWrapTcl"

but this file does not exist. Possible reasons include:

* The file was deleted, renamed, or moved to another location.

* An install or uninstall procedure did not complete successfully.

* The installation package was faulty and contained

"//lib/vtk-5.10/VTKTargets-debug.cmake"

but not all the files it references.
"

Some other AUR packages have similar problems, such as this, ginkgo-cadx.

I figured out cmake variable VTK_DIR is somehow undefined. I don't know it is a bug of cmake or vtk on arch. I found a workaround, export VTK_DIR=/where/is/vtk before calling cmake.

Saturday, December 22, 2012

kinect openni win8

  1. Uninstall openni, nite, and the kinect driver.
  2. Windows key + R to open the run prompt
  3. shutdown.exe /r /o /f /t 00
  4. select troubleshoot
  5. select advanced
  6. select windows startup and then restart
  7. enter the option for Disable Driver Signature
  8. reinstall openni, nite, and the kinect driver
According to "http://funccoder.blogspot.com/2012/11/openni-on-windows-8.html", this will work. I have not tested yet.


Thursday, December 20, 2012

archlinux 64 bit installation booting problem

I have this problem on my dell xps 630i desktop.
If I boot installation CD/usb to install 64 bit arch, it will crash and reboot. But 32 bit works fine. And 64 bit works on my other PCs.

I googled it and figured out it has something to do with the memory. 4G memory of the xps seems to bother arch 64bit kernel.

To solve this, I added "mem=2048M" to the boot script. Then the installation of 64 bit works.

The installed system works fine with any amount of memory.

Wednesday, December 19, 2012

MinGW64, openblas, suitesparse, and numpy under windows 64 bit

First of all, I failed.Numpy works only partially. IO crashed it for sure.I did not test it further. But, at least, compiling was fine.

Numpy depends on openblas and suitesparse(umfpack) for performance, suitesparse depends on intel-tbb and metis. I just use pre-built metis for mingw64 on the sourceforge.

Here is my openblas script
make -j4 BINARY=64 CC=x86_64-w64-mingw32-gcc FC=x86_64-w64-mingw32-gfortran NUM_THREADS=2
I used 2 threads due to my i5 cpu.

Here is the intel-tbb script
mingw32-make.exe compiler=gcc arch=intel64 runtime=mingw
install -d ./pkg/usr/local/lib
install -m755 build/windows_*/*.dll* ./pkg/usr/local/lib
install -d ./pkg/usr/local/include
cp -a include/tbb ./pkg/usr/local/include
cd ./pkg
tar cvf tbb_4.1_msys64.tgz ./usr
tar -tf tbb_4.1_msys64.tgz > tbb_4.1_msys64.list

And my suitesparse script
export CFLAGS=" ${CFLAGS} -DNPARTITION"
mingw32-make CFLAGS="${CFLAGS} -fPIC -I/usr/local/include -L/usr/local/lib" METIS="-lmetis" SPQR_CONFIG="-DTIMING -DHAVE_TBB" TBB="-ltbb" BLAS="-lopenblas" LAPACK="-lopenblas" -C SuiteSparse_config/xerbla
mingw32-make CFLAGS="${CFLAGS} -fPIC -I/usr/local/include -L/usr/local/lib" METIS="-lmetis" SPQR_CONFIG="-DTIMING -DHAVE_TBB" TBB="-ltbb" BLAS="-lopenblas" LAPACK="-lopenblas" -C SuiteSparse_config
for _lib in AMD CAMD COLAMD BTF KLU CCOLAMD UMFPACK CHOLMOD CXSparse SPQR; do
mingw32-make CFLAGS="${CFLAGS} -fPIC -I/usr/local/include -L/usr/local/lib" METIS="-lmetis" SPQR_CONFIG="-DTIMING -DHAVE_TBB" TBB="-ltbb" BLAS="-lopenblas" LAPACK="-lopenblas" -C ${_lib} library
done
mkdir -p shared
gcc -shared -o shared/libsuitesparseconfig.dll -Wl,--out-implib,SuiteSparse_config/libsuitesparseconfig.a
gcc -shared -o shared/libamd.dll -Wl,--out-implib,AMD/Lib/libamd.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libcamd.dll -Wl,--out-implib,CAMD/Lib/libcamd.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libcolamd.dll -Wl,--out-implib,COLAMD/Lib/libcolamd.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libccolamd.dll -Wl,--out-implib,CCOLAMD/Lib/libccolamd.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libbtf.dll -Wl,--out-implib,BTF/Lib/libbtf.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libcholmod.dll -Wl,--out-implib,CHOLMOD/Lib/libcholmod.a -L/usr/local/lib -lopenblas -lmetis -L./shared -lamd -lcamd -lcolamd -lccolamd
gcc -shared -o shared/libspqr.dll -Wl,--out-implib,SPQR/Lib/libspqr.a -L/usr/local/lib -lopenblas -ltbb -L./shared -lcholmod
gcc -shared -o shared/libcxsparse.dll -Wl,--out-implib,CXSparse/Lib/libcxsparse.a -L./shared -lsuitesparseconfig
gcc -shared -o shared/libklu.dll -Wl,--out-implib,KLU/Lib/libklu.a -L./shared -lamd -lcolamd -lbtf
gcc -shared -o shared/libumfpack.dll -Wl,--out-implib,UMFPACK/Lib/libumfpack.a -L/usr/local/lib -lopenblas -L./shared -lamd
install -dm755 ${PWD}/pkg/usr/local/{lib,include}
#cp -d shared/*.so* $pkgdir/usr/lib
#install -m755 shared/*.so* $pkgdir/usr/lib

for _lib in SuiteSparse_config AMD CAMD COLAMD BTF KLU LDL CCOLAMD UMFPACK CHOLMOD CXSparse SPQR; do
mingw32-make CFLAGS="${CFLAGS} -fPIC -I/usr/local/include -L/usr/local/lib" METIS="-lmetis" SPQR_CONFIG="-DTIMING -DHAVE_TBB" TBB="-ltbb" BLAS="-lopenblas" LAPACK="-lopenblas" -C ${_lib} INSTALL_LIB=${PWD}/pkg/usr/local/lib INSTALL_INCLUDE=${PWD}/pkg/usr/local/include install
done

chmod 644 ${PWD}/pkg/usr/local/include/*.{h,hpp}
cp -d shared/*.dll* ${PWD}/pkg/usr/local/lib

cd ${PWD}/pkg
tar cvf suitesparse_4.0.2_mingw64.tgz ./usr
tar -tf suitesparse_4.0.2_mingw64.tgz > suitesparse_4.0.2_mingw64.list

Finally, numpy script
p:\\python27_64\\python.exe setup.py config_fc --fcompiler=gnu95 config --compiler="mingw32" config_fc --fcompiler=gnu95 build --compiler=p:\\MinGW\\bin\\g++.exe --compiler="mingw32" bdist_wininst

with this patch
diff -rup numpy-1.7.0b2/numpy/distutils/fcompiler/gnu.py numpy-1.7.0b2_patched/numpy/distutils/fcompiler/gnu.py
--- numpy-1.7.0b2/numpy/distutils/fcompiler/gnu.py 2012-09-19 21:16:52 -0400
+++ numpy-1.7.0b2_patched/numpy/distutils/fcompiler/gnu.py 2012-12-17 01:12:58 -0500
@@ -181,9 +181,9 @@ class GnuFCompiler(FCompiler):
# the following code is not needed (read: breaks) when using MinGW
# in case want to link F77 compiled code with MSVC
opt.append('gcc')
- runtime_lib = msvc_runtime_library()
- if runtime_lib:
- opt.append(runtime_lib)
+ #runtime_lib = msvc_runtime_library()
+ #if runtime_lib:
+ # opt.append(runtime_lib)
if sys.platform == 'darwin':
opt.append('cc_dynamic')
return opt
@@ -323,12 +323,12 @@ class Gnu95FCompiler(GnuFCompiler):
opt.insert(i+1, "mingwex")
opt.insert(i+1, "mingw32")
# XXX: fix this mess, does not work for mingw
- if is_win64():
- c_compiler = self.c_compiler
- if c_compiler and c_compiler.compiler_type == "msvc":
- return []
- else:
- raise NotImplementedError("Only MS compiler supported with gfortran on win64")
+ #if is_win64():
+ # c_compiler = self.c_compiler
+ # if c_compiler and c_compiler.compiler_type == "msvc":
+ # return []
+ # else:
+ # raise NotImplementedError("Only MS compiler supported with gfortran on win64")
return opt

def get_target(self):
diff -rup numpy-1.7.0b2/numpy/distutils/mingw32ccompiler.py numpy-1.7.0b2_patched/numpy/distutils/mingw32ccompiler.py
--- numpy-1.7.0b2/numpy/distutils/mingw32ccompiler.py 2012-09-04 17:31:31 -0400
+++ numpy-1.7.0b2_patched/numpy/distutils/mingw32ccompiler.py 2012-12-17 01:13:10 -0500
@@ -176,7 +176,8 @@ class Mingw32CCompiler(distutils.cygwinc
target_lang=None):
# Include the appropiate MSVC runtime library if Python was built
# with MSVC >= 7.0 (MinGW standard is msvcrt)
- runtime_library = msvc_runtime_library()
+ #runtime_library = msvc_runtime_library()
+ runtime_library = None
if runtime_library:
if not libraries:
libraries = []
diff -rup numpy-1.7.0b2/numpy/distutils/system_info.py numpy-1.7.0b2_patched/numpy/distutils/system_info.py
--- numpy-1.7.0b2/numpy/distutils/system_info.py 2012-09-04 17:31:31 -0400
+++ numpy-1.7.0b2_patched/numpy/distutils/system_info.py 2012-12-17 01:14:12 -0500
@@ -1340,10 +1340,16 @@ Make sure that -lgfortran is used for C+

class lapack_opt_info(system_info):

+ section = 'lapack_opt'
notfounderror = LapackNotFoundError

def calc_info(self):

+ info = self.calc_libraries_info()
+ if info:
+ self.set_info(**info)
+ return
+
if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
args = []
link_args = []
@@ -1429,10 +1435,16 @@ class lapack_opt_info(system_info):

class blas_opt_info(system_info):

+ section = 'blas_opt'
notfounderror = BlasNotFoundError

def calc_info(self):

+ info = self.calc_libraries_info()
+ if info:
+ self.set_info(**info)
+ return
+
if sys.platform == 'darwin' and not os.environ.get('ATLAS', None):
args = []
link_args = []

And site.cfg
[DEFAULT]
library_dirs = P:\\MinGW64\\msys64\\local\\lib
include_dirs = P:\\MinGW64\\msys64\\local\\include


[blas_opt]
#library_dirs = P:\\MinGW64\\msys64\\local\\lib
libraries = openblas_nehalemp-r0.2.5, gfortran
#libraries = openblas

[lapack_opt]
#library_dirs = P:\\MinGW64\\msys64\\local\\lib
libraries = openblas_nehalemp-r0.2.5, gfortran
#libraries = openblas

#[blas_opt]
#libraries = libopenblas_nehalemp-r0.2.5

#[lapack_opt]
#libraries = libopenblas_nehalemp-r0.2.5

#[blas_opt]
#libraries = f77blas, cblas, atlas
#
#[lapack_opt]
#libraries = lapack, f77blas, cblas, atlas
#
# If your ATLAS was compiled with pthreads, the names of the libraries might be
# different:
#
#[blas_opt]
#libraries = ptf77blas, ptcblas, atlas
#
#[lapack_opt]
#libraries = lapack, ptf77blas, ptcblas, atlas


[amd]
#library_dirs = P:\\MinGW64\\msys64\\local\\lib
amd_libs = amd

[umfpack]
#library_dirs = P:\\MinGW64\\msys64\\local\\lib
umfpack_libs = umfpack


Tuesday, November 20, 2012

speed up sparse eigen value computing

scipy, octave, R, matlab all call arpack backend.

I focus on scipy syntax here. Others should be similar.

If all the eigen values are non-negative, and smallest eigen values are desired. Use following code to speed up.

ev, ef = sparse.linalg.eigsh(A, k = 6, M, sigma=0.0, which = 'LM')


Here is the test result
>>> t = time.time();ev, ef = sparse.linalg.eigsh(W, 20, S, sigma=0.0, which = 'LM');print (time.time() - t)
0.0778040885925
>>> t = time.time();ev, ef = sparse.linalg.eigsh(W, 20, S, which = 'SM');print (time.time() - t)
0.231815099716
>>>
where W and M are 642 by 642 square matrices.

Customer covers Dell's failure

I purchased Dell xps L401x two years ago, in 2010. The laptop came with Nvidia optimus 420m. However, whenever I tried to load nvidia gpu, it went overheating in no more than 5 mins. The gpu just stopped working to protect itself from burnt. In these two years, I never used the nvidia graphics card.

Last week, I tried to do some internal cleaning and re-paste some high level thermal grease, as I heard these would help overheating problem. When I opened the heat sink, I was totally shocked. These is NO thermal grease on the nvidia clip. I attach the photo shot I took when I just removed the heat sink.
You can see that there are thermal grease on the intel cpu and the integrated gpu. Nvidia GPU is supper clean. Not a little grease on it. Originally, the GPU clip is directly attached to the heat sink. That is why the CPU went overheating so easily.

I re-pasted the CPU, added grease on GPU, then turned it back on. Problem solved. No more overheating. I loaded games, GPU computing. The temperature never went above 60C with GPU 100% loaded.

Dell sells defective products and lets customer fix it.

Friday, November 16, 2012

blender linux gpu

"CUDA device supported only with compute capability 1.3 or up, found 1.1"

I got this error, when I tried gpu rendering for cycles render. (I needed to check gpu on in the system setting first.) I was not sure how comes my 9800GT became an "old" device.

There is a way to walk around. In the render settings of cycles render. Choose experimental feature set, and GPU compute device. After a long time compiling, GPU works.

Wednesday, November 14, 2012

spyder and mayavi

It is not only about mayavi on spyder.

If u run mayavi via spyder, u might have "ValueError: API 'QString' has already been set to version 1". Spyder uses api 1 by default, while many other modules require api 2. U can can the console setting in spyder. Under the external modules. Change the api to api 2.

So far, it works fine for me.

Thursday, October 18, 2012

batch rename to lower case

for f in `find`; do mv -v $f `echo $f | tr '[A-Z]' '[a-z]'`; done

Sunday, September 9, 2012

archlinux fontconfig update

When I updated fontconfig, I got file existing conflicts. Force option works fine except bringing warning such as ""/etc/fonts/conf.d/44-wqy-microhei.conf", line 6: Having multiple values in <test> isn't supported and may not works as expected". Then I had to update

<test qual="any" name="family">
<string>WenQuanYi Micro Hei</string>
<string>文泉驿微米黑</string>
<string>文泉驛微米黑</string>
</test>

to

<test qual="any" name="family">
<string>WenQuanYi Micro Hei</string>
</test>
<test qual="any" name="family">
<string>文泉驿微米黑</string>
</test>
<test qual="any" name="family">
<string>文泉驛微米黑</string>
</test>

Monday, July 9, 2012

opencv ios file/device i/o

I found that imread is not working under ios. At least for png/jpg in the simulator. Maybe it is all about the license issue. Video capture is not working either according to some tutorials, which I did not test.

I have to use ios native api such as UIImage and then convert it to cv::Mat.

ios texture from UIImage

CGContextRef spriteContext = CGBitmapContextCreate(spriteData, width, height, 8, width*4, CGImageGetColorSpace(spriteImage), kCGImageAlphaPremultipliedLast);

This function is employed in many tutorials. There is trick with alpha channel. It seems to fill no zero alpha pixels only. spriteData here has to be set to zero first. Otherwise, the background will be random.

Wednesday, June 27, 2012

hackintosh on pc

I tried many ways to make hackintosh on my PCs. I will not talk about install process here as there are tons of guides online. I just wanna discuss what I can reach.

1. Desktop PC. This is the easiest part I have. I use iATKOS L2. Other source may also work. Everything is fine. Install, boot, config, running. Drivers are easy to find online as "http://tonymacx86.com/". Everything works. Graphics, network, usb. Sleep may not working, but I do not care as it is a desktop.

2. Laptop with nvidia optimus. This gives me most headaches. It's a dell xps l401x with intel HD + nvidia 420m. Even on windows, the driver the outdated. Nvidia refuse to write driver for it, and the lasted driver from dell is around 2010, which support only CUDA 3.1. I installed nvidia 296.10 anyway.It seems to works. Later drivers make my win7 unbootable. Linux got stable support by bumblebee around a year ago. Let's get back to our topic. No doubt, it will not go smoothly for hackintosh. I can install iATKOS, boot, and run mac. There is no driver for wireless. I got another usb wireless adapter. It works partially. But, I can never got Graphics to work. It won't boot by default. I have to delete all stock intel drivers from the system. And then install some patched drivers. So I can boot with GraphicsEnabler=Yes. There should be hardware acceleration. But resolution is stuck at 1024x768. Nvidia is also running for nth but consuming power. Some other model can disable nvidia in bois, but no luck with my dell. This is what I have now. 1024x768 for ever with nvidia running. I believe laptops with single video card will have less problems. But for my dell, I don't think it is usable right now.

3. VMs. I use virtualbox and vmware. virtualbox is ready for mac. Install following regular guide. Everything works as it is. The main problem is that virtual graphics can only recognize 3m or 4m vram. The overall performance is acceptable, with a little lag. vmware has some booting problems. I convert my virtualbox disk to vmware format with patched AppleSMC.kext. Then vmware version boots under workstation 8.0.4. By default, vmware's perform is much worse. However there is a mac graphics driver, SVGA II. With this driver, my vmware mac is more smoother. I will stay with vmware at this time.

In conclusion, With regular video card, no optimus, I will install mac directly on hardware. Otherwise, I will use vmware with SVGA II driver.

Tuesday, June 19, 2012

GLKViewController not in the "subclass of" list

Maybe it is a problem only happens on my machines, lion  with xcode 4.3.3 from app store.

I create an empty project and try to add a file to be the subclass of GLKViewController. But I can not find it in the drop list. I can paste it into the blank anyway. Then the new files are nearly blank, instead of being with some initial codes.

Here is my solution. #import <GLKit/GLKit.h> some where. Reload the the project to make it re-index. Then I will find GLKViewController in the list.

Sunday, June 10, 2012

naclports tutorial

NaCl Ports: http://code.google.com/p/naclports/
It is a project to port existing c/c++ projects to Chrome NaCl platform. There are already some projects like freetype and zlib ported. But there is nearly no doc in naclports. I just try to write what I have done to make it work and what problem I have meet.

1. Download NaCl sdk. I am on peper19 so far
2. export NACL_SDK_ROOT="the folder contains toolchains"
3. Download with depot_tools with "git clone https://git.chromium.org/chromium/tools/depot_tools.git /your/local/depot_path"
4. export PATH="$PATH":/your/local/depot_path
5. Download naclports with depot tools with "gclient config https://naclports.googlecode.com/svn/trunk/src" and "gclient sync"


So far, we have all the codes.

6. cd your naclports root folder which contains a Makefile.
7. NACL_PACKAGES_BITSIZE=32 make
8. NACL_PACKAGES_BITSIZE=64 make

If everything is fine, we should have all the projects setup in the NaCl sdk. It is said that you do not need extra -I/-L for the path. However for me it is never a sweet procedure. When I make, I have checksum fail issue. I re-check some sha1 in the folder. They match without any problem. I have to disable checksum by commenting out all the "exit -1" in the build scripts such as common.sh. There could be some problem, but it works so far.

I just have everything setup, have never tested and linked them.

Thursday, June 7, 2012

libRocket mingw32 win32

libRocket is a mit licensed gui lib, which works with ogre 3d. Under windows it support vc++ 2010 by default. I try to build it with mingw32.

I had these problems.
error: invalid suffix "fh" on integer constant and strcpy_s not declared. Those are vc++ related. And freetype2 directory should also be modified. I have to patch the source code.

Here is my patch:

Only in patched//Build: .E
Only in patched//Build: CMakeCache.txt
Only in patched//Build: CMakeFiles
diff -rup libRocket//Build/CMakeLists.txt patched//Build/CMakeLists.txt
--- libRocket//Build/CMakeLists.txt    2010-11-30 17:53:58 -0500
+++ patched//Build/CMakeLists.txt    2012-06-08 11:13:54 -0400
@@ -53,9 +53,9 @@ endif()

 # FreeType
 if(WIN32)
-    set(FREETYPE_INCLUDE_DIRS ../../support/freetype/include)
-    set(FREETYPE_LIBRARY freetype243MT.lib)
-    set(FREETYPE_LINK_DIRS ../../support/lib)
+    set(FREETYPE_INCLUDE_DIRS ../../freetype-2.4.9/include)
+    set(FREETYPE_LIBRARY libfreetype-6.dll)
+    set(FREETYPE_LINK_DIRS ../../freetype-2.4.9/objs/.libs)
     set(FREETYPE_FOUND TRUE)
 else()
     find_package(Freetype REQUIRED)   
Only in patched//Build: Makefile
Only in patched//Build: cmake_install.cmake
Only in patched//Build: libRocketControls.dll
Only in patched//Build: libRocketControls.dll.a
Only in patched//Build: libRocketCore.dll
Only in patched//Build: libRocketCore.dll.a
Only in patched//Build: libRocketDebugger.dll
Only in patched//Build: libRocketDebugger.dll.a
diff -rup libRocket//Source/Controls/Clipboard.cpp patched//Source/Controls/Clipboard.cpp
--- libRocket//Source/Controls/Clipboard.cpp    2010-11-30 19:48:44 -0500
+++ patched//Source/Controls/Clipboard.cpp    2012-06-08 11:36:01 -0400
@@ -107,8 +107,11 @@ void Clipboard::Set(const Core::WString&
         _content.ToUTF8(win32_content);

         HGLOBAL clipboard_data = GlobalAlloc(GMEM_FIXED, win32_content.Length() + 1);
+#if defined (__MINGW32__)       
+        strncpy((char*) clipboard_data, win32_content.CString(), win32_content.Length() + 1);
+#else
         strcpy_s((char*) clipboard_data, win32_content.Length() + 1, win32_content.CString());
-
+#endif
         if (SetClipboardData(CF_TEXT, clipboard_data) == NULL)
         {
             CloseClipboard();
diff -rup libRocket//Source/Core/Math.cpp patched//Source/Core/Math.cpp
--- libRocket//Source/Core/Math.cpp    2010-11-30 19:48:44 -0500
+++ patched//Source/Core/Math.cpp    2012-06-08 11:25:17 -0400
@@ -144,7 +144,7 @@ ROCKETCORE_API int RoundDown(float value
 // Efficiently truncates a floating-point value into an integer.
 ROCKETCORE_API int RealToInteger(float value)
 {
-#if defined ROCKET_PLATFORM_WIN32
+#if defined (ROCKET_PLATFORM_WIN32) && !defined (__MINGW32__)
     int i;
     _asm
     {

Friday, June 1, 2012

SDL 2.0 with vc 2010

SDL 2.0 goes to zib instead lgpl in SDL 1.x. It is still in developing stage, I am not sure how stable it is.

I want to give it a try with my ogre project. But it won't compile with vc 2010. I found that 2 files are not added into the solution.

I added SDL_rotate.c/SDL_rotate.h back and the SDL lib compiled. But the tests still did not.

I tried report this on SDL forums, but I can not start a new post.

Ogre 3d linux gcc4.7

I have some issue with ogre 3d on my archlinux with gcc4.7.

I filed a bug report in arch, but I think it is an upstream bug and arch won't do anything about it. I still post my work around there. It works for me.

Details

Description:
Skeletal animation makes ogre crash.

Additional info:
* package version(s)
1.8.0
* config and/or log files etc.
ABS config

Steps to reproduce:
1. Runs /opt/OGRE/samples/SampleBrowser
2. Choose any sample using skeletal animation, such as Character, Dynamic Texturing, New Instancing or Skeletal Animation.
3. See the crash immediately.

Or, make you own ogre code using skeletal animation like official tutorial on ogre wiki. It will also crash.

It seems a historical bug back to 1.7 or more. It effects linux at least arch. It works fine on my win7.

It is a upstream bug not arch. But I have found a way to make work here. It is all about OgreOptimisedUtilSSE.cpp which can not be optimized more than -O1 with gcc 4.7. So I hardcoded with following steps:

cd ogre_src_v1-8-0
cd OgreMain/src/
g++ -c -O1 -march=native -msse -fPIC OgreOptimisedUtilSSE.cpp -I ../include/ -I ../../build/include/
cp OgreOptimisedUtilSSE.o ../../build/OgreMain/CMakeFiles/OgreMain.dir/src/OgreOptimisedUtilSSE.cpp.o
cd ../../build
make

Then, there is no crash any more.

I can put those into PKGBUILD to make it work. And there should be other better way than hardcoding. I found "set_source_files_properties" of cmake can set CFLAGS individually for source files. It might be better to patch CMakeLists.txt.

Tuesday, May 15, 2012

blender game engine and unity 3D

Blender and unity 3D are 2 game engines I am playing with. It is unfair to compare these two as one is open source and the other is commercial. I just wanna talk about how I feel.

BGE is great and handy. It is very intuitive. There is not any problem to develop a game with BGE. There is a quite wonderful game on it, http://www.yofrankie.org/. With gamekit, ,https://code.google.com/p/gamekit/, you can export your blender game to android and iphone. I have tested. It works. Audio on android is not supported yet. Maybe, iphone either. The whole pipeline is clear here. Modeling + game logic = game. The only concern is performance. Correct me if I am wrong. I feel BGE is not optimized enough. I felt a little laggy while playing mono example from gamekit on my i5 laptop, and more laggy on my moto xoom. I would like remain blender as mainly a modeling and animation tool.

unity 3D is a more professional game engine. Everything is ready for game dev. In terms of UI, I do not think there could any major pros or cons. Both BGE and unity and do good job. Like different programming language, it depends on which is more convenient for u. I guess unity 3D is more optimized on performance as an commercial software which is pricing thousand dollars on its pro version. The angrybot example can run smoothly on my phones and tablet.

In stead of comparing them, I would like to combine them. I use blender for modeling as I am used to blender way while publish games with unity 3D because of its performance and cross-platform.

ICS is not working perfect on my evo3d so far

Stock kernel is not working, causing boot loop. The only working kernel is AnthraX-htcleak-rls1. However it is buggy. 3D is broken, and it drains battery. I just switch back to mean GB.

4ext touch recovery does work on s-on. It will pend boot section and flash it next reboot.

Friday, May 11, 2012

flash any roms with s-on

I have 1.5 hboot s-on on my evo 3d cdma.

(It is said that 4ext can flash with s-on, but I did have it at that time. Will try it later.)

I just flash with recovery-clockwork-touch-5.8.0.2-shooter.img in my boot section.

1. fastboot flash boot recovery-clockwork-touch-5.8.0.2-shooter.img
2. reboot
3. You should in recovery mode now. Flash any rom/patch/kernel from your sdcard, before you reboot.
4. reboot
5. enjoy

Note: It is only one time job. After step 4, your boot section is locked again because s-on.

I tested Mean rom and Newts One S ICS roms with AnthraX-htcleak-rls1 kernel. Now I am on Mean. Everything is fine so far.

Monday, May 7, 2012

gamekit blender windows file path

It seems that blender uses relative path under windows (win7 in my case) for external files such as image texture. Then gamekit engine will fail to find those files. Make those paths absolute will solve the problem.

blender gamekit gcc4.7

OIS in gamekit is not compiling with gcc 4.7.  "write" is not declared.
Add #include <unistd.h> where write is called.

blender 2.63 stereo game engine

blender stereo works fine under win7 without any problems so far. However, under linux (arch in my case) side-by-side stereo or similar cases will fail with "X11 glXQueryVersion() failes, verify working openGL system! initial window could not find GLX extension, exit!"

I patch intern/ghost/intern/GHOST_WindowX11.cpp anyway. It might cause other problems, but side-by-side stereo works for me so far.

PS: patch file

Only in blender-2.63: build
diff -rup blender-2.63/intern/ghost/intern/GHOST_WindowX11.cpp patched/intern/ghost/intern/GHOST_WindowX11.cpp
--- blender-2.63/intern/ghost/intern/GHOST_WindowX11.cpp    2012-04-26 16:41:12.000000000 -0400
+++ patched/intern/ghost/intern/GHOST_WindowX11.cpp    2012-05-07 16:16:50.000000000 -0400
@@ -209,8 +209,8 @@ GHOST_WindowX11(
     for (samples = m_numOfAASamples; samples >= 0; samples--) {
         i = 0; /* Reusing attributes array, so reset counter */

-        if(m_stereoVisual)
-            attributes[i++] = GLX_STEREO;
+        //if(m_stereoVisual)
+        //    attributes[i++] = GLX_STEREO;

         attributes[i++] = GLX_RGBA;
         attributes[i++] = GLX_DOUBLEBUFFER;

Wednesday, May 2, 2012

reverse video clip with ffmpeg

Dump all video frames

$ ffmpeg -i input.mkv -an -qscale 1 %06d.jpg

Dump audio

$ ffmpeg -i input.mkv -vn -ac 2 audio.wav

Reverse audio

$ sox -V audio.wav backwards.wav reverse

Cat video frames in reverse order to FFmpeg as input

$ cat $(ls -rv *jpg) | ffmpeg -f image2pipe -vcodec mjpeg -r 25 -i - -i backwards.wav -vcodec libx264 -vpre slow -crf 20 -threads 0 -acodec flac output.mkv

Use mencoder to deinterlace PAL dv and double the frame rate from 25 to 50, then pipe to FFmpeg.

$ mencoder input.dv -of rawvideo -ofps 50 -ovc raw -vf yadif=3,format=i420 -nosound

If there is no audio, this command works for me.
cat $(ls -rv *jpg) | ffmpeg -f image2pipe -vcodec mjpeg -i - -vcodec mpeg4 -sameq -r 24 output.avi

Sunday, April 22, 2012

watch out cuda - gcc compatibility

Here is the doc of cuda 4.2 release node. I tried Fedora14 version with gcc 4.4, and got GLIBCXX linking error. When I switched back to ubuntu 10.04 version, everything is fine so far.
 
  Distro            32 64  Kernel             GCC         GLIBC         
  ------            -- --  ------             ---         -----         
  Fedora14          X  X   2.6.35.6-45        4.5.1       2.12.90  
  ICC Compiler 11.1 X  X
  OpenSUSE-11.2     X  X   2.6.31.5-0.1       4.4.1       2.10.1      
  RHEL-5.>=5        X  X   2.6.18-238.el5     4.1.2       2.5 
  (5.5, 5.6, 5.7)   
  RHEL-6.X             X   2.6.32-            4.4.5       2.12 
  (6.0, 6.1)               131.0.15.el6
  SLES 11.1         X  X   2.6.32.12-0.7-pae  4.3-62.198  2.11.1-0.17.4
  Ubuntu-10.04      X  X   2.6.35-23-generic  4.4.5       2.12.1 
  Ubuntu-11.04      X  X   2.6.38-8-generic   4.5.2       2.13 

Monday, April 16, 2012

vtk conflicts with openjdk7 on my archlinux

cmake produced error with openjdk7. After replacing it with openjdk6 everything is fine.

Saturday, April 14, 2012

merge pdf with

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf

Sunday, March 11, 2012

google censorship

google "win 8 consumer preview virtualbox network connectivity limited". Then I got
"In response to a complaint we received under the US Digital Millennium Copyright Act, we have removed 1 result(s) from this page. If you wish, you may read the DMCA complaint that caused the removal(s) at ChillingEffects.org."

virtualbox disables host network on win 8 consumer preview

It is NOT about installing win 8 on virtualbox as a guest OS.

I installed VB on win8 host. Win8 lost its network connection right after reboot/sleep/hibernate. It seems that win8 recognizes only VB Host-Only adapter. The problem was gone when I uninstall VB.

I googled it. It could be solved on win7/vista by changing *NdisDeviceType to 1 in reg. But I got no luck on win8 cp. I found a work around, unchecking virtualbox bridged networking driver in adapter properties. It works so far after waking from sleep. As win8 is still cp, I hope this will be fix in new version of VB and win8.


Tuesday, February 28, 2012

一些 android 游戏引擎

WiEngine.....

详情请登录微云:http://www.wiyun.com/web/wiengine

WiEngine -- 微云游戏引擎 Android版是一个适用于Android系统的2D游戏引擎。
WiEngine参考吸取了iPhone平台著名引擎cocos2d的设计理念,针对Android系统结构的
特点进行了大量的适配开发,设计修改和性能增强工作。

http://blog.csdn.net/cping1982/article/details/5788921 
或许您还不知道的八款Android开源游戏引擎 
很多初学Android游戏开发的朋友,往往会显得有些无所适从,他们常常不知道该从何处入手,每当遇到自己无法解决的难题时,又往往会一边羡慕于iPhone下有诸如Cocos2d-iphone之类的免费游戏引擎可供使用,一边自暴自弃的抱怨Android平台游戏开发难度太高,又连个像样的游戏引擎也没有,甚至误以为使用Java语言开发游戏是一件费力不讨好且没有出路的事情。

事实上,这种想法完全是没有必要且不符合实际的,作为能和苹果iOS分庭抗礼的Android(各种意义上),当然也会有相当数量的游戏引擎存在。仅仅因为我们处于这个狭小的天地间,与外界接触不够,所以对它们的存在茫然不知罢了。

下面我就罗列出八款常见的Android游戏引擎,以供有需要者参考(收费,下载量过小,不公布源码,以及鄙人不知道(-_-)的引擎不在此列)。


1、Angle 


Angle是一款专为Android平台设计的,敏捷且适合快速开发的2D游戏引擎,基于OpenGL ES技术开发。该引擎全部用Java代码编写,并且可以根据自己的需要替换里面的实现,缺陷在于文档不足,而且下载的代码中仅仅包含有少量的示例教程。

最低运行环境要求不详。

项目地址:http://code.google.com/p/angle/ 

2、Rokon
 


rokon是一款Android 2D游戏引擎,基于OpenGL ES技术开发,物理引擎为Box2D,因此能够实现一些较为复杂的物理效果,该项目最新版本为 2.0.3 (09/07/10)。总体来说,此引擎最大的优点在于其开发文档相当之完备,并且项目作者对反馈Bug的修正非常之神速,所以该框架的使用在目前也最为广泛,有人干脆将它称为Cocos2d-iPhone引擎的Android版(业务逻辑和编码风格上也确实很像)。附带一提,国内某个需要注册会员才能下载的Android游戏框架衍生于此框架,所以大家也不要刻板的认为收费便一定是好的,免费就一定不好。

最低运行环境要求为Android 1.5。

项目地址:http://code.google.com/p/rokon/ 

3、LGame
 


LGame是一款国人开发的Java游戏引擎,有Android及PC(J2SE)两个开发版本,目前最高版本同为0.2.6(31/07/10)。其底层绘图器LGrpaphics封装有J2SE以及J2ME提供的全部Graphics API(PC版采用Graphics2D封装,Android版采用Canvas模拟实现),所以能够将J2SE或J2ME开发经验直接套用其中,两版本间主要代码能够相互移植。Android版内置有Admob接口,可以不必配置XML直接硬编码Admob广告信息。

该引擎除了基本的音效、图形、物理、精灵等常用组件以外,也内置有Ioc、xml、http等常用Java组件的封装,代价是jar体积较为庞大,PC版已突破1.2MB,Android版有所简化也在500KB左右。此外,该引擎还内置有按照1:1实现的J2ME精灵类及相关组件,可以将绝大多数J2ME游戏平移到Android或PC版中。唯一遗憾的是,该项目作者是个极其懒惰的家伙,开发文档从去年说到今年依旧没有提供,只有游戏示例可供下载。

最低运行环境要求为Android 1.1。

项目地址:http://code.google.com/p/loon-simple/ 

4、AndEngine
 

andengine同样是一款基于OpenGL ES技术的Android游戏引擎,物理引擎同样为Box2D(标配|||)。该框架性能普通,文档缺乏,但示例较为丰富。

最低运行环境要求不详。

项目地址(未直接提供jar下载,源码可通过svn提取):http://code.google.com/p/andengine/ 


5、libgdx
 


libgdx是一款基于OpenGL ES技术开发的Android游戏引擎,支持Android平台下的2D游戏开发,物理引擎采用Box2D实现。单就性能角度来说,堪称是一款非常强大的Android游戏引擎,但缺陷在于精灵类等相关组件在使用上不够简化,而且文档也较为匮乏。

最低运行环境要求不详。

项目地址:http://code.google.com/p/libgdx/ 

6、jPCT
 


jPCT是一款基于OpenGL技术开发的3D图形引擎(PC环境为标准OpenGL,Android为OpenGL ES), 以Java语言为基础的,拥有功能强大的Java 3D解决方案。该引擎与LGame(此为2D游戏引擎)相类似,目前拥有PC(J2SE)以及Android两个开发版本。

jPCT的最大优势之一,就在于它惊人的向下兼容性。在PC环境中,jPCT甚至可以运行在JVM1.1环境之中,因为jPCT内部提供的图形渲染接口完全符合所有的Java 1.1规范(就连已经消失的Microsoft VM乃至更古老的Netscape 4 VM也不例外)。

最低运行环境要求为Android 1.5。

项目地址:http://www.jpct.net/jpct-ae/ 

7、Alien3d
 

Alien3d是一款体积非常之小的Android 3D游戏引擎,基于OpenGL ES技术开发。为了压缩体积,它根据不同功能采用多jar方式发布(包括alien3d-engine.jar,alien3d-tiled.jar,alien3d-sprites.jar,alien3d-shapes.jar,alien3d-particles2d.jar,),事实上它的核心文件大约只有40KB,所有相关jar的总和也不足150KB。

最低运行环境要求为Android 1.5。

项目地址:http://code.google.com/p/alien3d/ 

8、Catcake
 


Catcake是一款跨平台的Java 3D图形引擎,目前支持PC(J2SE)及Android环境运行(已有iPhone版规划)。该引擎在易用性和运行性能上皆有出色的表现,支持常见的游戏开发功能,诸如精灵动画,音频处理和视频播放等。

最低运行环境要求为Android 1.6。

项目地址:http://code.google.com/p/catcake/ 

Thursday, February 23, 2012

git over ssh workflow

source1. cd the project directory
2. git init
3. git add .
4. git commit -m "comments"

target1. git clone ssh://username@domain:port/home/username/path_to_project local_project

done.

Monday, February 20, 2012

volume render tetrahedral mesh with VTK/python


import vtk
import numpy as np

# create source
points = vtk.vtkPoints()
h = 1.0;
points.InsertNextPoint(0.0, 0.0, 0.0)
points.InsertNextPoint(0.0, h, 0.0)
n = 6;
angle_step = 2.0 * np.pi / n;
r = 0.5 * h;

for i in range(n):
points.InsertNextPoint(r * np.cos(i * angle_step), h * 0.5, r * np.sin(i * angle_step))

scalars = vtk.vtkDoubleArray()
for i in range(n + 2):
scalars.InsertTuple1(i, i * 255.0 / (n + 2))


tetra = vtk.vtkTetra()
cellArray = vtk.vtkCellArray()

trangle = vtk.vtkTriangle()


for i in range(n):
tetra.GetPointIds().SetId(0, 0)
tetra.GetPointIds().SetId(1, 1)
tetra.GetPointIds().SetId(3, i + 2)
tetra.GetPointIds().SetId(2, (i + 1) % n + 2)
cellArray.InsertNextCell(tetra)
#
# trangle.GetPointIds().SetId(0, 0)
# trangle.GetPointIds().SetId(1, 1)
# trangle.GetPointIds().SetId(2, i + 2)
# cellArray.InsertNextCell(trangle)
ug = vtk.vtkUnstructuredGrid()
ug.SetPoints(points)
ug.GetPointData().SetScalars(scalars);

ug.SetCells(vtk.VTK_TETRA, cellArray)

trianglePolyData = vtk.vtkPolyData()
trianglePolyData.SetPoints( points )
trianglePolyData.SetPolys( cellArray )

writer = vtk.vtkUnstructuredGridWriter();
#writer.SetFileName("Triangle.vtp");
writer.SetFileName("test.vtk");
writer.SetInput(ug);
writer.Write();


source = vtk.vtkConeSource()
source.SetCenter(0,0,0)
source.SetResolution(100)

# mapper
mapper = vtk.vtkDataSetMapper()
mapper.SetInput(ug)
#mapper.SetInput(trianglePolyData)

## volume mapper
volumeMapper = vtk.vtkUnstructuredGridVolumeRayCastMapper()
#volumeMapper = vtk.vtkSmartVolumeMapper()
tri = vtk.vtkDataSetTriangleFilter()
tri.SetInput(ug)
volumeMapper.SetInput(tri.GetOutput())

##create the volumeproperty object to define how our volume looks
colorTF = vtk.vtkColorTransferFunction()
colorTF.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
colorTF.AddRGBPoint(64.0, 1.0, 0.0, 0.0)
colorTF.AddRGBPoint(128.0, 0.0, 0.0, 1.0)
colorTF.AddRGBPoint(192.0, 0.0, 0.5, 0.0)
colorTF.AddRGBPoint(255.0, 0.0, 1.0, 0.0)

opacityTF = vtk.vtkPiecewiseFunction()
opacityTF.AddPoint(0.0, 0.8)
opacityTF.AddPoint(255.0, 1.0)

volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(colorTF)
volumeProperty.SetScalarOpacity(opacityTF)
volumeProperty.ShadeOff();
volumeProperty.SetInterpolationTypeToLinear()

##create a volume to render
theVolume = vtk.vtkVolume()
theVolume.SetMapper(volumeMapper)
theVolume.SetProperty(volumeProperty)

# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetRepresentationToWireframe()

#===================================================

# create a rendering window and renderer
ren = vtk.vtkRenderer()
ren.SetBackground(.3, .6, .3); # Background color green
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)

# create a renderwindowinteractor
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

istyle = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(istyle)

# assign actor to the renderer
ren.AddViewProp(theVolume)
#ren.AddActor(actor)
#ren.AddActor(actor2)

# enable user interface interactor
iren.Initialize()
renWin.Render()
iren.Start()

Sunday, February 19, 2012

python VTK tricks

python 2.7.2 VTK 5.8
In python, vtkUnstructuredGrid.GetCell(n) always return a global static object. Assume that we have an unstructured grid object "ug". [ug.GetCell(i) for i in range(ug.GetNumberOfCells())] gives you a list of copies of the same, maybe global, cell object, which should be the copy of the last cell. If you wanna do sth with each single cell, do it before the return cell get override. Ex. [ map(ug.GetCell(i).GetPointId, range(4)) for i in range(ug.GetNumberOfCells())]

I did not test any other function such as GetFace.


su under windows(maybe win7+)

runas [{/profile|/noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserAccountName program
 
Example: 
runas /noprofile /user:Administrator cmd 

Wednesday, February 8, 2012

cmake find module -> CmakeLists.txt -> your project

1. Find modules. CMake provides a lot of find modules by default such as vtk. However you might still need to write your own ones. You need to get those include dirs and libs. Here is a tiny example for voro++.


# - Try to find voro++
# Once done this will define
#  VORO++_FOUND - System has voro++
#  VORO++_INCLUDE_DIRS - The voro++ include directories
#  VORO++_LIBRARIES - The libraries needed to use voro++
#  VORO++_DEFINITIONS - Compiler switches required for using voro++

find_package(PkgConfig)
pkg_check_modules(PC_VORO++ QUIET voro++)
set(VORO++_DEFINITIONS ${PC_VORO++_CFLAGS_OTHER})

find_path(VORO++_INCLUDE_DIR voro++.hh
          HINTS ${PC_VORO++_INCLUDEDIR} ${PC_VORO++_INCLUDE_DIRS}
          PATH_SUFFIXES voro++ )

find_library(VORO++_LIBRARY NAMES voro++
             HINTS ${PC_VORO++_LIBDIR} ${PC_VORO++_LIBRARY_DIRS} )

set(VORO++_LIBRARIES ${VORO++_LIBRARY} )
set(VORO++_INCLUDE_DIRS ${VORO++_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set VORO++_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(voro++  DEFAULT_MSG
                                  VORO++_LIBRARY VORO++_INCLUDE_DIR)

mark_as_advanced(VORO++_INCLUDE_DIR VORO++_LIBRARY )

2. Then you are going to add the modules above in your CMakeLists.txt.


cmake_minimum_required(VERSION 2.6.2)

PROJECT(vtk_tetrahedron)

if(NOT CMAKE_MODULE_PATH)
  set(CMAKE_MODULE_PATH)
endif()
list(APPEND CMAKE_MODULE_PATH /home/jesse/Jesse_Studio/cmake_find)
#        set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})

find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})

find_package(Voro++ REQUIRED)
include_directories(${VORO++_INCLUDE_DIR})

add_executable(Tetrahedron Tetrahedron.cxx)

if(VTK_LIBRARIES)
    target_link_libraries(Tetrahedron ${VTK_LIBRARIES})
else()
    target_link_libraries(Tetrahedron vtkHybrid )
endif()

if(VORO++_LIBRARIES)
    target_link_libraries(Tetrahedron ${VORO++_LIBRARIES})
endif()

3. That's it. Use you cmake normally.

Saturday, January 7, 2012

OpenNI + linux

Under my linux I have to rm the module gspca_kinect to make openni to find the device.

It should be better to blacklist it in the init script.