Ask Your Question

Spooky's profile - activity

2017-08-14 08:52:33 -0600 received badge  Taxonomist
2012-07-13 13:43:26 -0600 received badge  Famous Question (source)
2012-07-07 08:59:55 -0600 commented answer OpenCV for Android (2.4.2): OpenCV Loader imports not resolved

Can I please get an answer on this? And it does no good to simply tell me that there's a way to convert a bitmap to Mat in C++ if you won't point me to either a reference indicating how, a tutorial, or simply tell me how to do it. Am I just supposed to GUESS? As I said, I have NOT found ANY reference or tutorial showing how to do so IN C++. I have only found info on doing this from Java, which will not work, unless it uses ZERO additional RAM. Thanks.....

2012-07-07 00:29:55 -0600 received badge  Notable Question (source)
2012-07-07 00:17:04 -0600 received badge  Famous Question (source)
2012-07-06 05:18:04 -0600 received badge  Popular Question (source)
2012-07-06 04:15:19 -0600 commented answer OpenCV for Android (2.4.2): OpenCV Loader imports not resolved

My workspace is in /Users/jim/Android/workspace, and both my app's top-level directory (UltraCamPro) and OpenCV-2.4.2-android-sdk (which I downloaded yesterday) are directly under the workspace directory. You mention that OpenCV does convert bitmap to Mat in C++ ... I have not found ANY documentation or examples---please point me in the right direction. I need to be able to do this entirely in C++, as I'm working with high-res camera images that exceed the Java memory limits on Android by 3--4 times, and I'm only working with a 5 MP camera...some devices have up to either 13 or 15 MP (can't remember which it was). I have NO idea how those manage to work at all, though, as the image itself exceeds Java's memory limit on Android... Thanks.

2012-07-06 04:00:50 -0600 commented answer OpenCV for Android (2.4.2): OpenCV Loader imports not resolved

In my main activity (UltraCamPro.java), I added the following after the global variables: [trying to move to a new line to add src, but no luck---it just ends the comment, so this may get messy] static {\n if (OpenCVLoader.initDebug()) { System.loadLibrary("cvBlend"); } else { // Report initialization error } } I was expecting this to load opencv into my app, as per the docs for 2.4.2. Instead, I got an error saying that OpenCVLoader cannot be resolved. So I looked at tutorial-3, and saw three import files that appeared to be what I needed (import org.opencv.android.BaseLoaderCallback; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; Eclipse then says for each): the import ... cannot be resolved.

2012-07-05 20:35:14 -0600 asked a question OpenCV for Android (2.4.2): OpenCV Loader imports not resolved

The three imports (copied from samples/tutorial-3-..... are repeatedly not seen by Eclipse. As a result, OpenCVLoader.initDebug doesn't load, nor does it load my JNI lib. I need to find out if the JNI C++ code I did today (to convert a bitmap to a Mat in C++) to see if I got it right---it's 100% trial and error for that. I was hoping 2.4.2 would build and run in Eclipse, where 2.4.1 did not (and hopefully, from there, run on my tablet without force closing the instant it tries to load libopencv_java.so).

I followed the directions on both tutorials on installing and using OpenCV (on the SDK side, and on the JNI side, respectively), very carefully, and found the imports for the loader in, as I said, tutorial-3, but it didn't work. For my project, all of the image conversion, resizing, blending, and post-processing must be done in JNI, not in Java (memory constraints in Java).

Please advise.

Thanks, --jim

2012-06-28 13:05:18 -0600 received badge  Notable Question (source)
2012-06-27 19:57:43 -0600 received badge  Autobiographer
2012-06-27 03:29:43 -0600 received badge  Student (source)
2012-06-27 03:27:52 -0600 received badge  Popular Question (source)
2012-06-26 22:07:48 -0600 received badge  Editor (source)
2012-06-26 10:46:02 -0600 asked a question Need help resizing and blending two images (first attempt w/ OpenCV/Android)

I need a bit of help with my first attempt at using both OpenCV for Android and the Android NDK. What this ultimately needs to do is take two images: the first is a byte[] array from the Android camera (assume that it's the highest resolution the device's camera supports, which at this time, could be up to 13 to 15 MP). The second image is a bitmap that is a color filter (one or more of solid color, graduated, and/or split-field) with some level of opacity (alpha) already set.

Both need to be converted to Mat, and the filter image needs to be resized. I can either pass the desired size as an arg to main() or get it from the photo image. I know how to do the former, not the latter. After that, the two need to be blended in the same way as looking through the lens of an SLR or DSLR camera, with a color filter attached to the lens. (In Java/Android, that would be PorterDuff's SRC_OVER method.)

Finally, all three (the original photo, the resized filter, and the result, should be saved to png files (the path and basename will be passed as args): Original: path/basename-original.png Filter: path/basename-filter.png Result: path/basename.png

Here's what I have so far:

// angle brackets left out here because they hide the include files
// and just show include (and nothing after that) * 3.
#include cv.h
#include highgui.h
#include iostream

using namespace cv;

/// argv[1] is a byte[] array (photo image, jpg, ARGB_8888)
/// argv[2] is a bitmap (color filter, must resize, ARGB_8888)
/// argv[3] is the size for the resized bitmap
/// argv[4] is the path and basename for saving the output (ARGB_8888)
/// this should save the resulting image to path/basename.png and
///    return 0 for success, 1 for error

// oops....what I saw below was not what I typed....
int main (int argc, char **argv)  {
   double alpha = 0.5; double beta; double input;

   Mat src1, src2, dst;

   /// convert the photo and color filter to Mats here

   /// resize the filter image to match the specified size (matches
   /// photo)

   /// Blend the two images---should match the "blending" seen when
   /// looking through an SLR lens with a color filter in front

   beta = (1.0 - alpha);
   cvAddWeighted(src1, alpha, src2, beta, 0.0, dst);

   /// save resulting image here; also save unfiltered image and
   /// resized bitmaps.  Filenames:  path/basename-original.png,
   /// patn/basename-filter.png, and path/basename.png

   return 0;  // will ultimately return 0 for success, 1 for failure
}

Can someone who works with the Android NDK and OpenCV for Android please help me with this first attempt? This is my first time trying to use both, and after all the time I've spent trying to learn both, I'm still confused (that's primarily a result of the permanent aftermath from my first cancer, which really hosed my short-term memory, ability to concentrate, and much more.... Hopefully, if I get ... (more)