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 ...