How we can make vignette filter in opencv? Do we need to implement any algorithm for it or only to play with the values of BGR ? Is there any implementation of vignette ? How we can make this type of filters
1 | initial version |
How we can make vignette filter in opencv? Do we need to implement any algorithm for it or only to play with the values of BGR ? Is there any implementation of vignette ? How we can make this type of filters
2 | No.2 Revision |
How we can make vignette filter in opencv? Do we need to implement any algorithm for it or only to play with the values of BGR ? Is there any I saw its implementation of vignette ? How we can make this type of filtershere but i didn't understand it clearly . Anyone with algorithms guidance is highly appriciated.
3 | No.3 Revision |
My code is working fine with showing brightness in the image using below code
jint* _in = env->GetIntArrayElements(in, 0);
jint* _out = env->GetIntArrayElements(out, 0);
Mat mSrc(height, width, CV_8UC4, (unsigned char*)_in);
Mat bgra(height, width, CV_8UC4, (unsigned char*)_out);
vector<Mat> sChannels;
split(mSrc, sChannels);
for(int i=0; i<sChannels.size(); i++)
{
Mat channel = sChannels[i];
equalizeHist(channel, channel);
}
merge(sChannels, bgra);
env->ReleaseIntArrayElements(in, _in, 0);
env->ReleaseIntArrayElements(out, _out, 0);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
It work for me too for changing image into grayscale but in this way :
Mat mSrc(height, width, CV_8UC4, (unsigned char*)_in);
Mat gray(height, width, CV_8UC1);
Mat bgra(height, width, CV_8UC4, (unsigned char*)_out);
cvtColor(mSrc , gray , CV_BGRA2GRAY);
cvtColor(gray , bgra , CV_GRAY2BGRA);
But when i am trying to use bilateralfilter
with it , which only work with 3 channels as given here , how to make vignette deal with it ? because java bitmap accept RGBA
format ,and when i change the above into
Mat mSrc(height, width, CV_8UC3, (unsigned char*)_in);
Mat mSrc(height, width, CV_8UC3, (unsigned char*)_in);
somehow bilateral filter How we show me output , but what if I have apply all these filter on one image ? how can ? make vignette filter in opencv? Do we need to implement any algorithm for it or I handle this problem ? because there may be other algorithms too which only to play with the values of BGR ? I saw its implementation here but i didn't understand it clearly . Anyone with algorithms guidance is highly appriciated.deal with 3 channels.
4 | No.4 Revision |
My code is working fine with in Visual Studio using opencv but its not showing brightness in the image using output in android ndk
application and its not showing even error , below codemy code.
jint* _in = env->GetIntArrayElements(in, 0);
jint* _out = env->GetIntArrayElements(out, 0);
void blending_softmode(Mat& img1, Mat& img2, Mat& out)
{
Mat mSrc(height, width, result(img1.size(), CV_32FC4); // result image is same size of input image
// Img2 is the value of solid colors
img2 = Mat(img1.size(), img1.type(), Scalar(186, 44, 28, 0));
// Iterate through rows , cols and colors(image channels)
for (int i = 0; i < img1.size().height; ++i){
for (int j = 0; j < img1.size().width; ++j){
for (int c = 0; c<img1.channels(); c++){ // Iterate through colors
//Formula for softmode blending
float target = (float)img1.at<uchar>(i, 4 * j + c) / 255.;
float blend = (float)img2.at<uchar>(i, 4 * j + c) / 255.;
if (blend > 0.5){
result.at<float>(i, 4 * j + c) = ((1 - (1 - target) * (1 - 2 * (blend - 0.5))));
}
else{
result.at<float>(i, 4 * j + c) = (target * (2 * blend));
}
}
}
}
result.convertTo(out, CV_8UC4, (unsigned char*)_in);
Mat bgra(height, width, CV_8UC4, (unsigned char*)_out);
vector<Mat> sChannels;
split(mSrc, sChannels);
for(int i=0; i<sChannels.size(); i++)
{
Mat channel = sChannels[i];
equalizeHist(channel, channel);
255);
}
merge(sChannels, bgra);
env->ReleaseIntArrayElements(in, _in, 0);
env->ReleaseIntArrayElements(out, _out, 0);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
It work for me too for changing image into grayscale in visual studio when I use it as 8UC3
but in this way :its not work in 8UC4
in android but showing no error , just no output in imageview
Mat mSrc(height, width, CV_8UC4, (unsigned char*)_in);
Mat gray(height, width, CV_8UC1);
Mat bgra(height, width, CV_8UC4, (unsigned char*)_out);
cvtColor(mSrc , gray , CV_BGRA2GRAY);
cvtColor(gray , bgra , CV_GRAY2BGRA);
But when i am trying to use bilateralfilter
with it , which only work with 3 channels as given here , how to deal with it ? because java bitmap accept RGBA
format ,and when i change the above into
Mat mSrc(height, width, CV_8UC3, (unsigned char*)_in);
Mat mSrc(height, width, CV_8UC3, (unsigned char*)_in);
somehow bilateral filter show me output , but what if I have apply all these filter on one image ? how can I handle this problem ? because there may be other algorithms too which only deal with 3 channels.
5 | No.5 Revision |
My code is working in Visual Studio using opencv but its not showing output in android ndk
application and its not showing even error , below my code.
void blending_softmode(Mat& sow(Mat& img1, Mat& img2, Mat& out)
{
Mat result(img1.size(), CV_32FC4); // result image is same size of input image
// Img2 is the value of solid colors
img2 = Mat(img1.size(), img1.type(), Scalar(186, 44, 28, 0));
// Iterate through rows , cols and colors(image channels)
for (int i = 0; i < img1.size().height; ++i){
for (int j = 0; j < img1.size().width; ++j){
for (int c = 0; c<img1.channels(); c++){ // Iterate through colors
//Formula for softmode blending
float target = (float)img1.at<uchar>(i, 4 * j + c) / 255.;
float blend = (float)img2.at<uchar>(i, 4 * j + c) / 255.;
if (blend > 0.5){
result.at<float>(i, 4 * j + c) = ((1 - (1 - target) * (1 - 2 * (blend - 0.5))));
}
else{
result.at<float>(i, 4 * j + c) = (target * (2 * blend));
}
}
}
}
result.convertTo(out, CV_8UC4, 255);
}
It work for me in visual studio when I use it as 8UC3
but its not work in 8UC4
in android but showing no error , just no output in imageviewimageview . The same thing work for me in android when i change the formula , but this formula work for me on visual studio . Some images work for me when i have the same code but different formula's in
if (blend > 0.5){
result.at<float>(i, 4 * j + c) = ((1 - (1 - target) * (1 - 2 * (blend - 0.5))));
}
else{
result.at<float>(i, 4 * j + c) = (target * (2 * blend));
}
And they are showing output.
6 | No.6 Revision |
My code is working in Visual Studio I am using opencv but its not with android ndk , Below is my jni code which is showing output in android me error on ndk
application resize
and its not showing even error , below my code.multiply
function :
void sow(Mat& Vite(Mat& img1, Mat& img2, Mat& out)
{
Mat result(img1.size(), CV_32FC4);
img2 = Mat(img1.size(), img1.type(), Scalar(186, 44, 28, 0));
for (int i = 0; i < img1.size().height; ++i){
for (int j = 0; j < img1.size().width; ++j){
for (int c = 0; c<img1.channels(); c++){ // Iterate through colors
//Formula
float target = (float)img1.at<uchar>(i, 4 * j + c) / 255.;
float blend = (float)img2.at<uchar>(i, 4 * j + c) / 255.;
if (blend > 0.5){
result.at<float>(i, 4 * j + c) = ((1 - (1 - target) * (1 - 2 * (blend - 0.5))));
}
else{
result.at<float>(i, 4 * j + c) = (target * (2 * blend));
}
}
}
}
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
cv::Mat result(img2.size(), CV_32FC4);
result=I1+I2;
result.convertTo(out, CV_8UC4, 255);
}
It work for me Below is my jni calling method :
JNIEXPORT jint JNICALL Java_org_opencv_samples_NativeActivity_CvNativeActivity_Vig(
JNIEnv* env, jobject, jint width, jint height, jint i, jint j, jintArray in,jintArray inn,
jintArray out) {
jint* _in = env->GetIntArrayElements(in, 0);
jint* _inn = env->GetIntArrayElements(inn, 0);
jint* _out = env->GetIntArrayElements(out, 0);
Mat mSrc(height, width, CV_8UC4, (unsigned char*) _in);
Mat nSrc(i, j, CV_8UC4, (unsigned char*) _inn);
Mat bgra(height, width, CV_8UC4, (unsigned char*) _out);
Vite(mSrc,nSrc, bgra);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
}
Result :
The other way I am trying in visual studio when I use it as which i am getting error 8UC3
but its not work in 8UC4
in android but showing no , just no output in imageview . The same thing work for me in android when i change the formula , but this formula work for me on visual studio . Some images work for me when i have the same code but different formula's in resize
and merging
if (blend > 0.5){
result.at<float>(i, 4 * j + c) = ((1 - (1 - target) * (1 - 2 * (blend - 0.5))));
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
vector<Mat> ch;
split(Img1,ch);
Mat mask = ch[4].clone();
ch.resize(4);
Mat I1,I2,result;
cv::multiply(mask,ch[0],ch[0]);
cv::multiply(mask,ch[1],ch[1]);
cv::multiply(mask,ch[2],ch[2]);
cv::multiply(mask,ch[3],ch[3]);
merge(ch,I1);
vector<Mat> ch2(4);
split(Img2,ch2);
cv::multiply(1.0-mask,ch2[0],ch2[0]);
cv::multiply(1.0-mask,ch2[1],ch2[1]);
cv::multiply(1.0-mask,ch2[2],ch2[2]);
cv::multiply(1.0-mask,ch2[3],ch2[3]);
merge(ch2,I2);
result=I1+I2;
result.convertTo(out, CV_8UC4, 255);
}
else{
result.at<float>(i, 4 * j + c) = (target * (2 * blend));
}
And they are showing output.
7 | No.7 Revision |
I am using opencv with android ndk , Below is my jni code which is showing me error on resize
and multiply
function :
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
cv::Mat result(img2.size(), CV_32FC4);
result=I1+I2;
result=img1+img2;
result.convertTo(out, CV_8UC4, 255);
}
Below is my jni calling method :
JNIEXPORT jint JNICALL Java_org_opencv_samples_NativeActivity_CvNativeActivity_Vig(
JNIEnv* env, jobject, jint width, jint height, jint i, jint j, jintArray in,jintArray inn,
jintArray out) {
jint* _in = env->GetIntArrayElements(in, 0);
jint* _inn = env->GetIntArrayElements(inn, 0);
jint* _out = env->GetIntArrayElements(out, 0);
Mat mSrc(height, width, CV_8UC4, (unsigned char*) _in);
Mat nSrc(i, j, CV_8UC4, (unsigned char*) _inn);
Mat bgra(height, width, CV_8UC4, (unsigned char*) _out);
Vite(mSrc,nSrc, bgra);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
}
Result :
The other way I am trying in which i am getting error on resize
and merging
#include <jni.h>
#include "opencv2/core/core.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
vector<Mat> ch;
split(Img1,ch);
split(img1,ch);
Mat mask = ch[4].clone();
ch.resize(4);
ch[3].clone();
ch.resize(3);
Mat I1,I2,result;
cv::multiply(mask,ch[0],ch[0]);
cv::multiply(mask,ch[1],ch[1]);
cv::multiply(mask,ch[2],ch[2]);
cv::multiply(mask,ch[3],ch[3]);
merge(ch,I1);
vector<Mat> ch2(4);
split(Img2,ch2);
ch2(3);
split(img2,ch2);
cv::multiply(1.0-mask,ch2[0],ch2[0]);
cv::multiply(1.0-mask,ch2[1],ch2[1]);
cv::multiply(1.0-mask,ch2[2],ch2[2]);
cv::multiply(1.0-mask,ch2[3],ch2[3]);
merge(ch2,I2);
result=I1+I2;
result.convertTo(out, CV_8UC4, 255);
}
Clone show me the error
Method 'clone' could not be resolved
and multiply show me the error
Invalid arguments '
Candidates are:
void multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray &, double, int)
'
My java calling
, where img1 is image in snapshot
and img2 image 2 is vignette of 4 channel
is input and out is output
InputStream is , Vign;
is = this.getResources().openRawResource(R.drawable.me);
final Bitmap bmInImg = BitmapFactory.decodeStream(is);
Vign = this.getResources().openRawResource(R.drawable.vig2);
final Bitmap bmInImg2 = BitmapFactory.decodeStream(Vign);
mPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
nPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
vPhotoIntArray = new int[bmInImg2.getWidth() * bmInImg2.getHeight()];
imageview_1.setImageBitmap(bmInImg);
bmInImg.getPixels(mPhotoIntArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
bmInImg2.getPixels(vPhotoIntArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
mCannyOutArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
final Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
Vig(bmInImg.getHeight(),bmInImg.getWidth(),bmInImg2.getHeight(),bmInImg2.getWidth(), mPhotoIntArray,vPhotoIntArray, mCannyOutArray);
Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
imageview_2.setImageBitmap(bmOutImg);
8 | No.8 Revision |
I am using opencv with android ndk , Below is my jni code which is showing me error on resize
and multiply
function :
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
cv::Mat result(img2.size(), CV_32FC4);
result=img1+img2;
result.convertTo(out, CV_8UC4, 255);
}
Below is my jni calling method :
JNIEXPORT jint JNICALL Java_org_opencv_samples_NativeActivity_CvNativeActivity_Vig(
JNIEnv* env, jobject, jint width, jint height, jint i, jint j, jintArray in,jintArray inn,
jintArray out) {
jint* _in = env->GetIntArrayElements(in, 0);
jint* _inn = env->GetIntArrayElements(inn, 0);
jint* _out = env->GetIntArrayElements(out, 0);
Mat mSrc(height, width, CV_8UC4, (unsigned char*) _in);
Mat nSrc(i, j, CV_8UC4, (unsigned char*) _inn);
Mat bgra(height, width, CV_8UC4, (unsigned char*) _out);
Vite(mSrc,nSrc, bgra);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
}
Result :
The other way I am trying in which i am getting error on resize
and merging
#include <jni.h>
#include "opencv2/core/core.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
vector<Mat> ch;
split(img1,ch);
Mat mask = ch[3].clone();
ch.resize(3);
Mat I1,I2,result;
cv::multiply(mask,ch[0],ch[0]);
cv::multiply(mask,ch[1],ch[1]);
cv::multiply(mask,ch[2],ch[2]);
cv::multiply(mask,ch[3],ch[3]);
merge(ch,I1);
vector<Mat> ch2(3);
split(img2,ch2);
cv::multiply(1.0-mask,ch2[0],ch2[0]);
cv::multiply(1.0-mask,ch2[1],ch2[1]);
cv::multiply(1.0-mask,ch2[2],ch2[2]);
cv::multiply(1.0-mask,ch2[3],ch2[3]);
merge(ch2,I2);
result=I1+I2;
result.convertTo(out, CV_8UC4, 255);
}
Clone show me the error
Method 'clone' could not be resolved
and multiply show me the error
Invalid arguments '
Candidates are:
void multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray &, double, int)
'
My java calling
, where img1 is image in snapshot
and img2 image 2 is vignette of 4 channel
is input and out is output
InputStream is , Vign;
is = this.getResources().openRawResource(R.drawable.me);
final Bitmap bmInImg = BitmapFactory.decodeStream(is);
Vign = this.getResources().openRawResource(R.drawable.vig2);
final Bitmap bmInImg2 = BitmapFactory.decodeStream(Vign);
mPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
nPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
vPhotoIntArray = new int[bmInImg2.getWidth() * bmInImg2.getHeight()];
imageview_1.setImageBitmap(bmInImg);
bmInImg.getPixels(mPhotoIntArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
bmInImg2.getPixels(vPhotoIntArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
mCannyOutArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
final Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
Vig(bmInImg.getHeight(),bmInImg.getWidth(),bmInImg2.getHeight(),bmInImg2.getWidth(), mPhotoIntArray,vPhotoIntArray, mCannyOutArray);
Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
imageview_2.setImageBitmap(bmOutImg);
9 | No.9 Revision |
I am using opencv with android ndk , Below for that I just try my code first on visual studio with opencv , it works fine on it and then I put it on android, but something is my jni code which confusing in understanding function and their cause of error like in for example the simple program
resize(image,image,image2.size());
image.convertTo(image,CV_32FC4,1.0/255.0);
image2.convertTo(image2,CV_32FC4,1.0/255.0);
vector<Mat> channel;
split(image,channel);
Mat mask = image.clone(); // clone function work fine
//Mat mask = channel[3].clone(); // clone function show me error
// channel.resize(3); // show error
Mat it;
multiply(mask,channel[0],channel[0]);
multiply(mask,channel[1],channel[1]);
multiply(mask,channel[2],channel[2]);
merge(channel,it);
When I use Mat mask = channel[3].clone();
It show me error of Method 'clone' could not be resolved
but when I use Mat mask = image.clone();
it works fine. Why is showing that ?
Same when I use channel.resize(3);
it show me error on in resize function , error is resize
Invalid arguments 'Candidates are: void resize(?, cv::Mat)'
.
and multiply
function :
when I move on to multiply function it show me error of Invalid arguments ' Candidates are:
void Vite(Mat& img1, Mat& img2, Mat& out)
{
cv::resize(img2,img2,img1.size());
img1.convertTo(img1,CV_32FC4,1.0/255.0);
img2.convertTo(img2,CV_32FC4,1.0/255.0);
cv::Mat result(img2.size(), CV_32FC4);
result=img1+img2;
result.convertTo(out, CV_8UC4, 255);
}
Below is my jni calling method :
JNIEXPORT jint JNICALL Java_org_opencv_samples_NativeActivity_CvNativeActivity_Vig(
JNIEnv* env, jobject, jint width, jint height, jint i, jint j, jintArray in,jintArray inn,
jintArray out) {
jint* _in = env->GetIntArrayElements(in, 0);
jint* _inn = env->GetIntArrayElements(inn, 0);
jint* _out = env->GetIntArrayElements(out, 0);
Mat mSrc(height, width, CV_8UC4, (unsigned char*) _in);
Mat nSrc(i, j, CV_8UC4, (unsigned char*) _inn);
Mat bgra(height, width, CV_8UC4, (unsigned char*) _out);
Vite(mSrc,nSrc, bgra);
jint retVal;
int ret = 1;
retVal = jint(retVal);
return retVal;
}
Result :
My java calling
, where img1 is image in snapshot
multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray&, double, int)' .
Though these all function are working in visual studio using opencv and img2 they are also working in android when using on different scenario's . image 2 is vignette
I am working on native environment using eclipse with opencv android version of 4 channel is input and out is output
InputStream is , Vign;
is = this.getResources().openRawResource(R.drawable.me);
final Bitmap bmInImg = BitmapFactory.decodeStream(is);
Vign = this.getResources().openRawResource(R.drawable.vig2);
final Bitmap bmInImg2 = BitmapFactory.decodeStream(Vign);
mPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
nPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
vPhotoIntArray = new int[bmInImg2.getWidth() * bmInImg2.getHeight()];
imageview_1.setImageBitmap(bmInImg);
bmInImg.getPixels(mPhotoIntArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
bmInImg2.getPixels(vPhotoIntArray, 0, bmInImg2.getWidth(), 0, 0, bmInImg2.getWidth(), bmInImg2.getHeight());
mCannyOutArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
final Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
Vig(bmInImg.getHeight(),bmInImg.getWidth(),bmInImg2.getHeight(),bmInImg2.getWidth(), mPhotoIntArray,vPhotoIntArray, mCannyOutArray);
Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
imageview_2.setImageBitmap(bmOutImg);
2.4.8. 10 | No.10 Revision |
I am using opencv with android , for that I just try my code first on visual studio with opencv , it works fine on it and then I put it on android, but something is confusing in understanding function and their cause of error like in for example the simple program
resize(image,image,image2.size());
image.convertTo(image,CV_32FC4,1.0/255.0);
image2.convertTo(image2,CV_32FC4,1.0/255.0);
vector<Mat> channel;
split(image,channel);
Mat mask = image.clone(); // clone function work fine
//Mat mask = channel[3].clone(); // clone function show me error
// channel.resize(3); // show error
Mat it;
multiply(mask,channel[0],channel[0]);
multiply(mask,channel[1],channel[1]);
multiply(mask,channel[2],channel[2]);
merge(channel,it);
When I use Mat mask = channel[3].clone();
It show me error of Method 'clone' could not be resolved
but when I use Mat mask = image.clone();
it works fine. Why is that ?
Same when I use channel.resize(3);
it show me error in resize function , error is Invalid arguments 'Candidates are: void resize(?, cv::Mat)'
.
and when I move on to multiply function it show me error of Invalid arguments ' Candidates are: void multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray&, double, int)'
.
Though these all function are working in visual studio using opencv and they are also working in android when using on different scenario's .
I am working on native environment using eclipse with opencv android version of 2.4.8.
11 | No.11 Revision |
I am using opencv with android , for that I just try my code first on visual studio with opencv , it works fine on it and then I put it on android, but something is confusing in understanding function and their cause of error like in for example the simple program
resize(image,image,image2.size());
image.convertTo(image,CV_32FC4,1.0/255.0);
image2.convertTo(image2,CV_32FC4,1.0/255.0);
vector<Mat> channel;
split(image,channel);
Mat mask = image.clone(); // clone function work fine
//Mat mask = channel[3].clone(); // clone function show me error
// channel.resize(3); // show error
Mat it;
multiply(mask,channel[0],channel[0]);
multiply(mask,channel[1],channel[1]);
multiply(mask,channel[2],channel[2]);
merge(channel,it);
When I use Mat mask = channel[3].clone();
It show me error of Method 'clone' could not be resolved
but when I use Mat mask = image.clone();
it works fine. Why is that ?
Same when I use channel.resize(3);
it show me error in resize function , error is Invalid arguments 'Candidates are: void resize(?, cv::Mat)'
.
and when I move on to multiply function it show me error of Invalid arguments ' Candidates are: void multiply(const cv::_InputArray &, const cv::_InputArray &, const cv::_OutputArray&, double, int)'
.
Though these all function are working in visual studio using opencv and they are also working in android when using on different scenario's .
I am working on native environment using eclipse with opencv android version of 2.4.8.
multiply and clone alternate work for me as i tried the code below , but don't know how to merge it
Mat alpha1 = ch[3];
Mat alpha = alpha1.clone();
Mat I1;
vector<Mat> ch0 = ch[0];
vector<Mat> ch1 = ch[1];
vector<Mat> ch2 = ch[2];
// I1 = alpha1.mul(ch0);
// I1 = alpha1.mul(ch1);
// I1 = alpha1.mul(ch2);
multiply(alpha, ch0, ch0);
multiply(alpha, ch1, ch1);
multiply(alpha, ch2, ch2);
merge(ch, I1);