Ask Your Question

Ankit's profile - activity

2018-01-27 06:16:51 -0600 received badge  Notable Question (source)
2015-11-08 03:06:12 -0600 received badge  Popular Question (source)
2014-10-11 02:55:35 -0600 received badge  Critic (source)
2013-06-17 00:57:29 -0600 asked a question Aligning Images after matching features

Using example code provided by OpenCV I am matching features of two images. Now, I want to align the second image according to first image.

image description

image description

These are example images from a Matlab example.

I need guidance for aligning the two images after matching features.

2013-06-04 05:13:31 -0600 asked a question camera not opening while using opencv

I am processing byte from onPreviewFrame() to create a bitmap and finally draw the bitmap using canvas. I'm attatching my code. Camera is showing black screen.

CameraDemo Class public class CameraDemo extends Activity {

public static final String TAG = "Camera-Activity";
private Preview preview;
private FrameLayout framelayout;
private int width = 1024;
private int height = 720;

//BaseLoaderCallBack
 private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                {
                    Log.i(TAG, "OpenCV loaded successfully");
                    System.loadLibrary("native_activity");
                    preview.mCamera = Camera.open();
                } break;
                default:
                {
                    super.onManagerConnected(status);
                } break;
            }
        }
    };


@Override
protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     //Set this APK Full screen
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
      //Set this APK no title
      requestWindowFeature(Window.FEATURE_NO_TITLE);  
      setContentView(R.layout.main);

      Log.i(TAG, "Trying to load OpenCV library");
        if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this,
                mLoaderCallback)) {
            Log.e(TAG, "Cannot connect to OpenCV Manager");
        }
        SurfaceView camView = new SurfaceView(this);
        SurfaceHolder camHolder = camView.getHolder();
        preview = new Preview(width,height);

        camHolder.addCallback(preview);

        framelayout = (FrameLayout) findViewById(R.id.frameLayout);
        framelayout.addView(camView, new LayoutParams(width, height));
}

}

PreviewClass

epublic class Preview implements SurfaceHolder.Callback,Camera.PreviewCallback

{//Class Starts public Camera mCamera; //Camera Object private int PreviewSizeWidth; //Width of preview size private int PreviewSizeHeight; //Height of Preview Size private static final String TAG = "Preview"; private SurfaceHolder mHolder;

//Constructor to set preview size width and height
public Preview(int width, int height)
{
    PreviewSizeWidth = width;
    PreviewSizeHeight = height;
    Log.i(TAG, "Instantiated new Preview");
}

//Override onpreviewFrame method of camera.previewcallback
@Override
public void onPreviewFrame(byte[] arg0, Camera arg1)
{
    Log.i(TAG, "Frame is Received");
    Bitmap bmp = processFrame(arg0);

    if (bmp != null) {
        draw(bmp);
    }
    bmp.recycle();
}

//Called when surface is changed
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) 
{
    Parameters parameters;

    parameters = mCamera.getParameters();
    // Set the camera preview size
    parameters.setPreviewSize(PreviewSizeWidth, PreviewSizeHeight);
    // Set the take picture size, you can set the large size of the camera supported
    mCamera.setParameters(parameters);
    mCamera.startPreview();
}

//Called when surface is created
@Override
public void surfaceCreated(SurfaceHolder arg0) {
    mCamera = Camera.open();
    try
    {
        // If did not set the SurfaceHolder, the preview area will be black.
        mCamera.setPreviewDisplay(arg0);
        mCamera.setPreviewCallback(this);
    } 
    catch (IOException e)
    {
        mCamera.release();
        mCamera = null;
    }

}

//Called when surface is destroyed
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
    mCamera.setPreviewCallback(null);
    mCamera.stopPreview();
    mCamera.release();
    mCamera = null;

}

//Process Frame Data
protected Bitmap processFrame(byte[] data)
{
    Log.i(TAG, "Frame is Processing");
    Mat mYUV = new Mat(PreviewSizeHeight + PreviewSizeHeight/2, PreviewSizeWidth, CvType.CV_8UC1);
    mYUV.put(0, 0, data);
    Mat mRgba = new Mat();
    Imgproc.cvtColor(mYUV, mRgba, Imgproc.COLOR_YUV2RGB_NV21, 3);
    Bitmap mBitmap = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
     try {
         Log.i(TAG, "Bitmap1");
            Utils.matToBitmap(mRgba, mBitmap);
        } catch(Exception e) {
            Log.e(TAG, "Utils.matToBitmap() throws an exception: " + e.getMessage());
            mBitmap.recycle();
            mBitmap = null;
        }
    return mBitmap;
}

//For drawing bitmap
public void draw(Bitmap bmp){
    Log.i(TAG, "Drawing Canvas");
    Canvas canvas = mHolder.lockCanvas();
    if (canvas != null) {
        canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2, (canvas.getHeight() - bmp.getHeight()) / 2, null);
       // mFps.draw(canvas, (canvas ...
(more)
2013-06-03 00:28:14 -0600 commented answer Viola jones Haar features

How does the algorithm know which Haar-feature it has to choose? Does the algorithm do all the permutations of these features in a scanning window and based on that detect an object?

2013-05-30 22:56:44 -0600 asked a question Viola jones Haar features

The three types of Haar like features are : Edge feature,line feature and four-rectangle.

1.) Why there are three type of haar features?

2.) What is the significance of each feature?

2013-05-30 07:49:15 -0600 commented question How to detect people with android phone camera(java only)

were you able to detect a human body on android phone? I tried to change classifier but it didn't work. I got following error at line InputStream is = getResources().openRawResource(R.raw.haarcascade_fullbody)

Error : haarcascade_fullbody cannot be resolved or is not a field

2013-05-30 05:22:19 -0600 asked a question Changing org.opencv library

For my project I am editing JavaCameraView class in org.opencv.android package. I am unable to call this method from FdActivity.java in the main project. Can someone point me in right direction?

2013-05-29 04:11:23 -0600 received badge  Supporter (source)
2013-05-29 01:50:52 -0600 received badge  Student (source)
2013-05-29 01:26:01 -0600 asked a question Native detector or java detector

What's the difference between these two trackers in opencv-face detection android project?

Does both of them use Viola-Jones face detection algorithm?

2013-05-29 01:19:42 -0600 commented question opencv 2.4.4 slow Java Camera on Android (bug)?

Were you able to set camera parameters for the project?

2013-05-29 00:38:16 -0600 received badge  Editor (source)
2013-05-28 05:35:32 -0600 asked a question Using face detection to focus on out of focus faces

I used OpenCV face-detection android project to detect faces. I am trying to focus the detected area in the camera view. For implementing this I used setFocusAreas() method in android.hardware.Camera.parameters.

rect = new android.graphics.Rect((int) facesArray[0].tl().x,(int)facesArray[0].br().y,(int)facesArray[facesArray.length].tl().x,(int)facesArray[facesArray.length].br().y);
area = new Camera.Area(rect, 1000);
ArrayList<Camera.Area> listarea = new ArrayList<Camera.Area>();
listarea.add(area);
if (parameter.getMaxNumFocusAreas() > 0) {
        parameter.setFocusAreas(listarea);
        camera.setParameters(parameter);
       }