Merge release 2.4.3

This commit is contained in:
Andrey Kamaev
2012-11-02 17:45:58 +04:00
126 changed files with 61518 additions and 51142 deletions

View File

@@ -84,11 +84,11 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.066820f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 0, 0, 1.141826f),
new DMatch(4, 0, 0, 1.084099f)
new DMatch(0, 0, 0, 1.0496940f),
new DMatch(1, 0, 0, 1.0984558f),
new DMatch(2, 1, 0, 0.4945875f),
new DMatch(3, 1, 0, 0.48435235f),
new DMatch(4, 0, 0, 1.0836693f)
};
super.setUp();
@@ -206,6 +206,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@@ -84,11 +84,11 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 1, 0, 6.9202332f),
new DMatch(1, 0, 0, 6.0567350f),
new DMatch(2, 1, 0, 2.6798587f),
new DMatch(3, 0, 0, 5.8991642f),
new DMatch(4, 0, 0, 6.1321812f)
new DMatch(0, 1, 0, 6.9202340f),
new DMatch(1, 1, 0, 6.1675916f),
new DMatch(2, 1, 0, 2.6798590f),
new DMatch(3, 1, 0, 2.6545324f),
new DMatch(4, 0, 0, 6.1294870f)
};
super.setUp();
}
@@ -183,6 +183,7 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@@ -89,11 +89,11 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.1018578f),
new DMatch(1, 0, 0, 1.1381058f),
new DMatch(0, 0, 0, 1.1018573f),
new DMatch(1, 0, 0, 1.2066052f),
new DMatch(2, 1, 0, 0.2446168f),
new DMatch(3, 0, 0, 1.3037685f),
new DMatch(4, 0, 0, 1.1752719f)
new DMatch(3, 1, 0, 0.23459719f),
new DMatch(4, 0, 0, 1.174339f)
};
super.setUp();
@@ -189,9 +189,10 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@@ -128,7 +128,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n</opencv_storage>\n";
assertEquals(truth, readFile(filename));
String data = readFile(filename);
assertEquals(truth, data);
}
public void testWriteYml() {
@@ -137,7 +139,8 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
detector.write(filename);
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n";
assertEquals(truth, readFile(filename));
}
String data = readFile(filename);
assertEquals(truth, data);
}
}

View File

@@ -159,10 +159,10 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.066820f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 0, 0, 1.141826f),
new DMatch(4, 0, 0, 1.084099f)
new DMatch(1, 0, 0, 1.0984558f),
new DMatch(2, 1, 0, 0.4945875f),
new DMatch(3, 1, 0, 0.48435235f),
new DMatch(4, 0, 0, 1.0836693f)
};
super.setUp();

View File

@@ -34,11 +34,14 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
truth = new Mat(1, 128, CvType.CV_32FC1) {
{
put(0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 12, 17, 28, 26, 0, 0, 2, 23, 14, 12, 9, 6, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14, 88, 23, 17, 24, 29, 0, 117, 54, 117, 116, 117, 22, 29, 27, 117, 59, 76, 19, 30, 2, 9, 26, 2, 7, 6, 0, 0,
0, 0, 0, 0, 8, 50, 16, 30, 58, 89, 0, 117, 49, 95, 75, 117, 112, 117, 93, 81, 86, 117, 5, 5, 39, 117, 71, 20,
20, 12, 0, 0, 1, 20, 19, 0, 0, 0, 2, 14, 4, 1, 0, 69, 0, 0, 14, 90, 31, 35, 56, 25, 0, 0, 0, 0, 2, 12, 16, 0,
0, 0, 0, 0, 0, 2, 1);
0, 0, 0, 1, 3, 0, 0, 0, 15, 23, 22, 20, 24, 2, 0, 0, 7, 8, 2, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 16, 13, 2, 0, 0, 117,
86, 79, 68, 117, 42, 5, 5, 79, 60, 117, 25, 9, 2, 28, 19, 11, 13,
20, 2, 0, 0, 5, 8, 0, 0, 76, 58, 34, 31, 97, 16, 95, 49, 117, 92,
117, 112, 117, 76, 117, 54, 117, 25, 29, 22, 117, 117, 16, 11, 14,
1, 0, 0, 22, 26, 0, 0, 0, 0, 1, 4, 15, 2, 47, 8, 0, 0, 82, 56, 31,
17, 81, 12, 0, 0, 26, 23, 18, 23, 0, 0, 0, 0, 0, 0, 0, 0
);
}
};
@@ -76,18 +79,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
}
public void testRead() {
MatOfKeyPoint keypoints =new MatOfKeyPoint(keypoint);
Mat img = getTestImg();
Mat descriptors = new Mat();
String filename = OpenCVTestRunner.getTempFileName("yml");
writeFile(filename,
"%YAML:1.0\nmagnification: 3.\nisNormalize: 1\nrecalculateAngles: 1\nnOctaves: 6\nnOctaveLayers: 4\nfirstOctave: -1\nangleMode: 0\n");
extractor.read(filename);
extractor.compute(img, keypoints, descriptors);
assertMatNotEqual(truth, descriptors, EPS);
fail("Not yet implemented");
}
public void testWrite() {

View File

@@ -47,19 +47,20 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
Mat truth = new Mat(1, 128, CvType.CV_32FC1) {
{
put(0, 0,
-0.0041138371, 0.0041138371, 0, 0, 0, 0, 0.0014427509, 0.0014427509, -0.0081971241, 0.034624498, 0.032569118,
0.032569118, -0.007222258, 0.0076424959, 0.0033254174, 0.0033254174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.10815519, 0.38033518, 0.24314292, 0.24314292, -0.068393648, 0.068393648,
0.039715949, 0.039715949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8.7263528e-05, 8.7263528e-05, -6.0081031e-05,
6.0081031e-05, -0.00012158759, 0.00012158759, 0.0033254174, 0.0033254174, -0.007222258, 0.0076424964,
0.0081971241, 0.034624498, -0.032569118, 0.032569118, -0.077379324, 0.27552885, 0.14366581, 0.31175563,
-0.013609707, 0.24329227, -0.091054246, 0.17476201, 0.022970313, 0.022970313, -0.035123408, 0.035771687,
0.1907353, 0.3838968, -0.31571922, 0.31571922, 0.0092833797, 0.0092833797, -0.012892088, 0.012957365,
0.029558292, 0.073337689, -0.043703932, 0.043703932, 0.0014427509, 0.0014427509, 0, 0, 0.0041138371,
0.0041138371, 0, 0, -0.02955829, 0.073337704, 0.043703932, 0.043703932, -0.012892087, 0.012957364,
0.0092833797,0.0092833797, 6.0081031e-05, 6.0081031e-05, 0.00012158759, 0.00012158759, -8.7263528e-05,
8.7263528e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
);
0, 0, 0, 0, 0, 0, 0, 0, 0.045382127, 0.075976953, -0.031969212, 0.035002094, 0.012224297,
0.012286193, -0.0088025155, 0.0088025155, 0.00017225844, 0.00017225844, 0, 0, 8.2743405e-05,
8.2743405e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8.2743405e-05, 8.2743405e-05, -0.00017225844,
0.00017225844, 0, 0, 0.31723264, 0.42715758, -0.19872268, 0.23621935, 0.033304065, 0.033918764,
-0.021780485, 0.021780485, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0088025145,
0.0088025145, 0.012224296, 0.012286192, -0.045382123, 0.075976953, 0.031969212, 0.035002094,
0.10047197, 0.21463872, -0.0012294546, 0.18176091, -0.075555265, 0.35627601, 0.01270232,
0.20058797, -0.037658721, 0.037658721, 0.064850949, 0.064850949, -0.27688536, 0.44229308,
0.14888979, 0.14888979, -0.0031531656, 0.0031531656, 0.0068481555, 0.0072466261, -0.034193151,
0.040314503, 0.01108359, 0.023398584, -0.00071876607, 0.00071876607, -0.0031819802,
0.0031819802, 0, 0, -0.0013680183, 0.0013680183, 0.034193147, 0.040314503, -0.01108359,
0.023398584, 0.006848156, 0.0072466265, -0.0031531656, 0.0031531656, 0, 0, 0, 0, 0, 0, 0, 0,
-0.0013680183, 0.0013680183, 0, 0, 0.00071876607, 0.00071876607, 0.0031819802, 0.0031819802
);
}
};

View File

@@ -41,7 +41,7 @@ class AsyncServiceHelper
}
protected static final String TAG = "OpenCVManager/Helper";
protected static final int MINIMUM_ENGINE_VERSION = 1;
protected static final int MINIMUM_ENGINE_VERSION = 2;
protected OpenCVEngineInterface mEngineService;
protected LoaderCallbackInterface mUserAppCallback;
protected String mOpenCVersion;

View File

@@ -52,7 +52,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!");
AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create();
IncomatibilityMessage.setTitle("OpenCV Manager");
IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Update it!");
IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.");
IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button
IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -60,7 +60,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
}
});
IncomatibilityMessage.show();
}
} break;
/** Other status, i.e. INIT_FAILED. **/
default:
{
@@ -113,7 +113,7 @@ public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
{
AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create();
WaitMessage.setTitle("OpenCV is not ready");
WaitMessage.setMessage("Installation is in progeress. Wait or exit?");
WaitMessage.setMessage("Installation is in progress. Wait or exit?");
WaitMessage.setCancelable(false); // This blocks the 'BACK' button
WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {

View File

@@ -23,10 +23,10 @@ import android.view.SurfaceView;
* The main responsibility of it - is to control when camera can be enabled, process the frame,
* call external listener to make any adjustments to the frame and then draw the resulting
* frame to the screen.
* The clients shall implement CvCameraViewListener
* TODO: add method to control the format in which the frames will be delivered to CvCameraViewListener
* The clients shall implement CvCameraViewListener.
*/
public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback {
//TODO: add method to control the format in which the frames will be delivered to CvCameraViewListener
private static final int MAX_UNSPECIFIED = -1;

View File

@@ -1,6 +1,5 @@
package org.opencv.android;
import java.io.IOException;
import java.util.List;
import android.annotation.TargetApi;
@@ -21,7 +20,7 @@ import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;
/**
* This class is an implementation of the Bridge View between OpenCv and JAVA Camera.
* This class is an implementation of the Bridge View between OpenCV and Java Camera.
* This class relays on the functionality available in base class and only implements
* required functions:
* connectCamera - opens Java camera and sets the PreviewCallback to be delivered.
@@ -36,7 +35,8 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
private Mat mBaseMat;
private byte mBuffer[];
private Mat[] mFrameChain;
private int mChainIdx = 0;
private Thread mThread;
private boolean mStopThread;
@@ -65,6 +65,7 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
@TargetApi(11)
protected boolean initializeCamera(int width, int height) {
Log.d(TAG, "Initialize java camera");
boolean result = true;
synchronized (this) {
mCamera = null;
@@ -99,59 +100,76 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
Log.d(TAG, "getSupportedPreviewSizes()");
List<android.hardware.Camera.Size> sizes = params.getSupportedPreviewSizes();
/* Select the size that fits surface considering maximum size allowed */
Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);
if (sizes != null) {
/* Select the size that fits surface considering maximum size allowed */
Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);
params.setPreviewFormat(ImageFormat.NV21);
Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
params.setPreviewSize((int)frameSize.width, (int)frameSize.height);
params.setPreviewFormat(ImageFormat.NV21);
Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
params.setPreviewSize((int)frameSize.width, (int)frameSize.height);
List<String> FocusModes = params.getSupportedFocusModes();
if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
{
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
List<String> FocusModes = params.getSupportedFocusModes();
if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
{
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
mCamera.setParameters(params);
params = mCamera.getParameters();
mFrameWidth = params.getPreviewSize().width;
mFrameHeight = params.getPreviewSize().height;
int size = mFrameWidth * mFrameHeight;
size = size * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8;
mBuffer = new byte[size];
mCamera.addCallbackBuffer(mBuffer);
mCamera.setPreviewCallbackWithBuffer(this);
mBaseMat = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1);
mFrameChain = new Mat[2];
mFrameChain[0] = new Mat();
mFrameChain[1] = new Mat();
AllocateCache();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID);
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setPreviewTexture(mSurfaceTexture);
} else
mCamera.setPreviewDisplay(null);
/* Finally we are ready to start the preview */
Log.d(TAG, "startPreview");
mCamera.startPreview();
}
mCamera.setParameters(params);
params = mCamera.getParameters();
mFrameWidth = params.getPreviewSize().width;
mFrameHeight = params.getPreviewSize().height;
int size = mFrameWidth * mFrameHeight;
size = size * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8;
mBuffer = new byte[size];
mCamera.addCallbackBuffer(mBuffer);
mCamera.setPreviewCallbackWithBuffer(this);
mBaseMat = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1);
AllocateCache();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID);
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mCamera.setPreviewTexture(mSurfaceTexture);
} else
mCamera.setPreviewDisplay(null);
} catch (IOException e) {
else
result = false;
} catch (Exception e) {
result = false;
e.printStackTrace();
}
/* Finally we are ready to start the preview */
Log.d(TAG, "startPreview");
mCamera.startPreview();
}
return true;
return result;
}
protected void releaseCamera() {
synchronized (this) {
mCamera.stopPreview();
mCamera.release();
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
}
mCamera = null;
if (mBaseMat != null)
mBaseMat.release();
if (mFrameChain != null) {
mFrameChain[0].release();
mFrameChain[1].release();
}
}
}
@@ -187,7 +205,8 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
this.notify();
}
Log.d(TAG, "Wating for thread");
mThread.join();
if (mThread != null)
mThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
@@ -224,19 +243,19 @@ public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallb
}
if (!mStopThread) {
Mat frameMat = new Mat();
switch (mPreviewFormat) {
case Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA:
Imgproc.cvtColor(mBaseMat, frameMat, Imgproc.COLOR_YUV2RGBA_NV21, 4);
Imgproc.cvtColor(mBaseMat, mFrameChain[mChainIdx], Imgproc.COLOR_YUV2RGBA_NV21, 4);
break;
case Highgui.CV_CAP_ANDROID_GREY_FRAME:
frameMat = mBaseMat.submat(0, mFrameHeight, 0, mFrameWidth);
mFrameChain[mChainIdx] = mBaseMat.submat(0, mFrameHeight, 0, mFrameWidth);
break;
default:
Log.e(TAG, "Invalid frame format! Only RGBA and Gray Scale are supported!");
};
deliverAndDrawFrame(frameMat);
frameMat.release();
if (!mFrameChain[mChainIdx].empty())
deliverAndDrawFrame(mFrameChain[mChainIdx]);
mChainIdx = 1 - mChainIdx;
}
} while (!mStopThread);
Log.d(TAG, "Finish processing thread");