Ask Your Question
0

opencv 4.5.0 cvDiv/cvMat equivalent ?

asked 2020-11-18 10:28:10 -0600

marius gravatar image

updated 2020-11-19 03:08:11 -0600

LE:

System information (version)

OpenCV => 4.5.0
Operating System / Platform => MacOS
Compiler => Android Studio with ndkBuild

Detailed description

I am developing and android app, I am using openCV android sdk along with some cpp files that process some images, building with ndkBuild all of the files. Now I updated from OpenCV-3.1-android-sdk to OpenCV-4.5.0-android-sdk

I am using these includes:

#include <opencv2/core/core.hpp>
#include <opencv2/core/core_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

In my cpp file was using it like this (So basically I had this code working in openCV 3.1.0):

Mat mat1 = new Mat(..);
Mat mat2 = new Mat(..);
CvMat src = mat1;
CvMat mask = mat2;
cvDiv(&src, &mask, &mask, 256);

In openCV 4.5.0 I get this error:

error: no viable conversion from 'cv::Mat' to 'CvMat '

If I use this instead

Mat mat1 = new Mat(..);
Mat mat2 = new Mat(..);
Mat src = mat1;
Mat mask = mat2;
cvDiv(&src, &mask, &mask, 256);

I get this error at runtime:

cv::error(): OpenCV(4.5.0) Error: Bad argument (Unknown array type) in cvarrToMat, file /build/master_pack-android/opencv/modules/core/src/matrix_c.cpp, line 185

I am actually asking: How can I convert this code to run with OpenCV 4.5.0. - I could use divide instead of cvDiv (as @sturkmen stated) - but what arguments do I feed to that function ? I cannot feed Mat, I cannot use CvMat.. PS: evidently I am clueless in C since I am just an android dev

edit retag flag offensive close merge delete

Comments

sturkmen gravatar imagesturkmen ( 2020-11-18 13:02:26 -0600 )edit

Can you check my revised question please ?

marius gravatar imagemarius ( 2020-11-18 17:25:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-11-19 02:49:13 -0600

berak gravatar image

updated 2020-11-19 02:51:05 -0600

this already won't compile:

Mat mat1 = new Mat(..);

do not use new anywhere with opencv in c++, a simple

Mat mat1 = Mat(..);
Mat mat2 = Mat(..);
Mat res;
divide(mat1, mat2, res, 256);

should do.

edit flag offensive delete link more

Comments

thanks!!!! it worked!

marius gravatar imagemarius ( 2020-11-19 04:59:08 -0600 )edit
1

You can directly do:

Mat mat1(..); Mat mat2(..);

Eduardo gravatar imageEduardo ( 2020-11-19 05:22:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-11-18 10:25:59 -0600

Seen: 864 times

Last updated: Nov 19 '20