1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Fixed Android samples; Fixed bugs in cmake (java module).

This commit is contained in:
Andrey Kamaev
2011-07-19 17:07:01 +00:00
parent fd4fe3ef5a
commit 930b2995eb
17 changed files with 183 additions and 81 deletions
@@ -2,7 +2,9 @@ package org.opencv.samples.puzzle15;
import java.util.List;
import org.opencv.*;
import org.opencv.core.Size;
import org.opencv.highgui.VideoCapture;
import org.opencv.highgui.Highgui;
import android.content.Context;
import android.graphics.Bitmap;
@@ -46,15 +48,15 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
}
}
mCamera.set(highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
mCamera.set(highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);
mCamera.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
mCamera.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);
}
}
}
public void surfaceCreated(SurfaceHolder holder) {
Log.i(TAG, "surfaceCreated");
mCamera = new VideoCapture(highgui.CV_CAP_ANDROID);
mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID);
if (mCamera.isOpened()) {
(new Thread(this)).start();
} else {
@@ -1,6 +1,13 @@
package org.opencv.samples.puzzle15;
import org.opencv.*;
import org.opencv.android;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
import android.content.Context;
import android.graphics.Bitmap;
@@ -30,7 +37,7 @@ public class puzzle15View extends SampleCvViewBase implements OnTouchListener {
mTextWidths = new int[gridArea];
mTextHeights = new int[gridArea];
for (int i = 0; i < gridArea; i++) {
Size s = core.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null);
Size s = Core.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null);
mTextHeights[i] = (int) s.height;
mTextWidths[i] = (int) s.width;
}
@@ -106,7 +113,7 @@ public class puzzle15View extends SampleCvViewBase implements OnTouchListener {
@Override
protected Bitmap processFrame(VideoCapture capture) {
capture.retrieve(mRgba, highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
int cols = mRgba.cols();
int rows = mRgba.rows();
@@ -121,7 +128,7 @@ public class puzzle15View extends SampleCvViewBase implements OnTouchListener {
else {
mCells[idx].copyTo(mCells15[i]);
if (mShowTileNumbers) {
core.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / gridSize - mTextWidths[idx]) / 2,
Core.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / gridSize - mTextWidths[idx]) / 2,
(rows / gridSize + mTextHeights[idx]) / 2), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, new Scalar(255, 0, 0, 255), 2);
}
}
@@ -139,8 +146,8 @@ public class puzzle15View extends SampleCvViewBase implements OnTouchListener {
private void drawGrid(int cols, int rows) {
for (int i = 1; i < gridSize; i++) {
core.line(mRgba15, new Point(0, i * rows / gridSize), new Point(cols, i * rows / gridSize), new Scalar(0, 255, 0, 255), 3);
core.line(mRgba15, new Point(i * cols / gridSize, 0), new Point(i * cols / gridSize, rows), new Scalar(0, 255, 0, 255), 3);
Core.line(mRgba15, new Point(0, i * rows / gridSize), new Point(cols, i * rows / gridSize), new Scalar(0, 255, 0, 255), 3);
Core.line(mRgba15, new Point(i * cols / gridSize, 0), new Point(i * cols / gridSize, rows), new Scalar(0, 255, 0, 255), 3);
}
}