Ask Your Question

Dangthrimble's profile - activity

2018-09-06 10:19:56 -0600 received badge  Notable Question (source)
2017-01-31 19:49:13 -0600 received badge  Popular Question (source)
2015-11-04 15:24:19 -0600 received badge  Popular Question (source)
2013-05-16 08:25:16 -0600 received badge  Enlightened (source)
2013-05-16 08:25:16 -0600 received badge  Good Answer (source)
2013-03-30 06:52:14 -0600 answered a question How do I achieve cloudy white balance (~6,000K)

Using the OpenCV Tutorial 3 code (Camera Control) (see OpenCV4Android samples) I modified the colour effects methods to allow the setting of white balance:

public List<String> getWhiteBalanceList() {
    return mCamera.getParameters().getSupportedWhiteBalance();
}

public boolean isWhiteBalanceSupported() {
    return (mCamera.getParameters().getWhiteBalance() != null);
}

public String getWhiteBalance() {
    return mCamera.getParameters().getWhiteBalance();
}

public void setWhiteBalance(String whiteBalance) {
    Camera.Parameters params = mCamera.getParameters();
    params.setWhiteBalance(whiteBalance);
    mCamera.setParameters(params);
}

Once I knew that worked I was able to add a call to my main thread to set the correct white balance:

mOpenCvCameraView.setWhiteBalance(Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
2013-03-30 06:41:50 -0600 asked a question With Android, how do I pass control back to the main thread?

I am using the OpenCV Tutorial 3 code (Camera Control) (see OpenCV4Android samples) as the basis for my code and need to be able to open and manipulate an image once it has been saved in the onPictureTaken() method. During the manipulation I want to be able to display the changes to the image and post messages using Toast, both of which require me to be in the main thread.

Based on advice received to date, I am trying to use a BroadcastReceiver in the Activity which is triggered by a sendBroadcast() in the JavaCameraView.

I have updated the Activity to include the BroadcastReceiver, and register and unregister it as follows:

public class Tutorial3Activity extends Activity implements CvCameraViewListener2, OnTouchListener {
    :
    private ActivityReceiver activityReceiver;
    :
    @Override
    public void onCreate(Bundle savedInstanceState) {
        :
        IntentFilter intentFilter = new IntentFilter();
        this.registerReceiver(activityReceiver, intentFilter);
        :
    }
    :
    public void onDestroy() {
        :
        this.unregisterReceiver(activityReceiver);
        :
    }
    :
    private class ActivityReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i(TAG, "BroadcastReceiver triggered");
            if (intent.getAction().equals(Tutorial3View.IMAGE_READY)) {
                Log.i(TAG, "BroadcastReceiver received");
            }
        }
    }    
}

The sendBroadcast() is invoked in the JavaCameraView as follows:

public class Tutorial3View extends JavaCameraView {
    :
    public static final String IMAGE_READY = "IMAGE_READY";
    private Context context;
    :
    public Tutorial3View(Context context, AttributeSet attrs) {
        :
        this.context = context;
        :
    }
    :
    public void takePicture(final String fileName) {
        PictureCallback callback = new PictureCallback() {
            private String mPictureFileName = fileName;
            @Override
            public void onPictureTaken(byte[] data, Camera camera) {
                :
                image_read();
                :
            }
        };
        mCamera.takePicture(null, null, callback);
    }
    :
    public void image_read() {
        Log.i(TAG, "BroadcastReceiver - send");
        Intent i = new Intent();
        i.setAction(IMAGE_READY);
        context.sendBroadcast(i);
        Log.i(TAG, "BroadcastReceiver - sent");
    }
}

The Manifest includes the BroadcastReceiver as follows:

<receiver android:name="ActivityReceiver">
    <intent-filter android:label="IMAGE_READY"></intent-filter>
</receiver>

When I take the picture, the LogCat shows:

03-30 17:22:53.410: I/Sample::Tutorial3View(3174): BroadcastReceiver - send
03-30 17:22:53.410: I/Sample::Tutorial3View(3174): BroadcastReceiver - sent

but there is no log for BroadcastReceiver triggered or BroadcastReceiver received.

Can someone advise why the broadcast isn't being received?

Thanks

2013-03-28 08:51:33 -0600 asked a question How can I change the sampling period for an OpenCV frame on an Android device?

I am trying to compare the colour of LEDs using OpenCV with an Android camera. Unfortuntely the LEDs have a cycle time that means the intensity of each LED is different within a single OpenCV frame. Is there some way I can extend the sampling period for the OpenCV frame so that it can cover the LED cycle time and all LED intensities can be as they appear to the naked eye?

2013-03-25 03:03:01 -0600 received badge  Student (source)
2013-03-24 11:51:42 -0600 commented question How do I achieve cloudy white balance (~6,000K)

Does OpenCV bypass the Android camera and therefore also bypass the Android camera settings?

2013-03-24 11:24:52 -0600 asked a question How do I achieve cloudy white balance (~6,000K)

I am using OpenCV to capture images on a Galaxy S2 but am finding the white balance is off. Using the phone's camera settings, the white balance I require is "Cloudy" (which I have found elsewhere equates to ~6,000K). Can I use the Android camera setting to set the white balance? If so, how? And if not, how else could I efficiently transform the image matrix to achieve the appropriate white balance?

2013-03-19 10:45:26 -0600 commented question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

The original image (origMat) is created using CvCameraViewFrame.rgba() and inRgbaMat is then created using origMat.submat(), so I would expect it to be RGBA.

2013-03-19 10:32:56 -0600 commented question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

How would I check that? inRgbaMat.size() returns 480x480 and inRgbaMat.type() returns 0. Does that help and, if so, what does it mean?

2013-03-19 10:12:06 -0600 commented question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

Decided to go with the suggestion of using threshold() rather than Canny(). However when I try to convert the RGBA Mat to gray in preparation using "Imgproc.cvtColor(inRgbaMat, outGrayMat, Imgproc.COLOR_RGBA2GRAY);" all I get is a crash: OpenCV Error: Assertion failed (scn == 3 || scn == 4) in void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int), file /home/reports/ci/slave/50-SDK/opencv/modules/imgproc/src/color.cpp, line 3326

Any advice?

2013-03-18 13:02:15 -0600 commented question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

Why is threshold() better than Canny()? Reading the documentation, it appears Canny() can be used on a colour image whereas threshold() works on a grayscale image. If I'm starting with a colour image why is it better to convert it to grayscale and use threshold()?

Thanks

2013-03-18 12:50:56 -0600 answered a question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

So how about the following (assuming I want all the points but only on the external contour)?

Mat cannyMat = new Mat();
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Mat hierarchy = new Mat();
MatOfInt hull = new MatOfInt();

Imgproc.Canny(originalMat, cannyMat, threshold1, threshold2);
Imgproc.findContours(cannyMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CV_CHAIN_APPROX_NONE);
Imgproc.convexHull(contours.get(0), hull);

Assuming that's correct, how do I then convert the hull back to a Mat that can be overlaid over originalMat?

2013-03-18 10:52:21 -0600 received badge  Editor (source)
2013-03-18 10:43:52 -0600 asked a question OpenCV4Android: Extracting a MatOfPoint from a Canny image for input into convexHull

Hi,

I am trying to teach myself Eclipse (ADT), Java, Android and OpenCV all at the same time (!) and need a way in Java to extract a MatOfPoint from a Canny image for inputting into convexHull. Can anyone advise?

Thanks

2013-02-25 02:53:26 -0600 received badge  Nice Answer (source)
2013-02-24 05:31:15 -0600 received badge  Teacher (source)
2013-02-23 13:20:16 -0600 answered a question no opencv_java244 in java.library.path

After much trial and error(!), assuming OpenCV is installed on a Windows machine at <opencv-dir>:

  • The JAR is in <opencv-dir>\build\java.
  • On a 32-bit Windows machine, the Native Library Location is <opencv-dir>\build\java\x86.
  • On a 64-bit Windows machine, the Native Library Location is <opencv-dir>\build\java\x64.

Therefore, on my 64-bit Windows 7 PC with OpenCV installed at D:\opencv:

  • The JAR is in D:\opencv\build\java.
  • The Native Library Location is D:\opencv\build\java\x64.
2013-02-23 12:21:29 -0600 commented answer no opencv_java244 in java.library.path

Have tried D:\opencv\build\x64\mingw\bin, D:\opencv\build\x64\mingw\lib and D:\opencv\build\x64\mingw and I still get the same "no opencv_java244 in java.library.path" error as goodspeed. A bit more information would be a real help. What identifies the native library's location?

2013-02-23 11:51:09 -0600 commented answer no opencv_java244 in java.library.path

So, for a 64-bit Windows machine, that would be ...\opencv\build\x64\mingw\bin or ...\opencv\build\x64\mingw\lib?