Thursday, April 11, 2013

OpenCV perforamce (效能測試) FPS 小的原因


+ it cost 200ms
--> (context switch + access the pixel 50x384=19200 pixel)


 
    // gray debug
    // 2013/4/12: performance low
	public void RunDebug_1(Mat image)
	{
		Log.i(TAG,"+++RunDebug_1");
		
		int rows = image.rows();
		int cols = image.cols();
		
		//Log.i(TAG,"row:"+rows+"cols:"+cols);
		
		double [] d;
		int r,c;
		double g;
		
		//Log.i(TAG,"+++sslake check 1");
		for(r=0;r<rows;r++)
		{
			for(c=0;c<cols;c++)
			{
				d= image.get(r, c);
				//gray= 0.299*R+ 0.587*G + 0.114*B
				g = 0.299* d[0]+0.587*d[1] + 0.114*d[2];
				
				image.put(r,c,g,g,g,255);
				
			}
			//if(r %50 ==0)
			//	Log.i(TAG,"+++sslake check 1 r:->"+r);
		}
		
	
	}
Result: the Performance is bad, FPS is 0.56 .
    
// Case 2: sslake : use the OpenCV Lib:
// Code:
Imgproc.cvtColor(image, image, Imgproc.COLOR_RGB2GRAY);

Result: The FPS is around 14.  (14/0.56=25倍的差異)

org.opencv.android.JavaCameraView



+ Camera.open(camIdx);
+Camera.release();


+connectCamera()
++open -->
++ create thread()? --->


+mCamera.getParameters();


+
http://playandworkandroid.blogspot.tw/2011/12/setpreviewfpsrange.html


+deliverAndDrawFrame


Wednesday, April 10, 2013

How to setup the build environment for OpenCV on Android?


@step 1: build the CV lib okay first.




@Step 2:
need to uninstall previous version which download from google play if you have.

@Step 3: test result as below.










CDT setting


@

Note
 
It’s also possible to define the NDKROOT environment variable within Eclipse IDE, but it should be done for every new workspace you create. If you prefer this option better than setting system environment variable, open Eclipse menu Window -> Preferences -> C/C++ -> Build -> Environment, press theAdd... button and set variable name to NDKROOT and value to local Android NDK path.





@



where is C code in NDK sample


@Jni folder

@Jni:

build.xml



http://stackoverflow.com/questions/4185921/any-way-to-generate-ant-build-xml-file-automatically-from-eclipse

ADB Shell


-adb shell
-adb version

OpenCV 教學 (NDK setup)

http://opencv.org/platforms/android.html



@

Android NDK