OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 24 Dec 2017 07:47:57 -0600Matlab min equivalent in OpenCVhttp://answers.opencv.org/question/180985/matlab-min-equivalent-in-opencv/ I'm looking for an equivalent for the `min` function of Matlab in OpenCV, with this particular functionality (taken from [the official Matlab documentation](https://www.mathworks.com/help/matlab/ref/min.html)):
> [M,I] = min(___) finds the indices of
> the minimum values of A and returns
> them in output vector I, using any of
> the input arguments in the previous
> syntaxes. If the minimum value occurs
> more than once, then min returns the
> index corresponding to the first
> occurrence.
In my specific case, I have 2 images. I want to create a new image with the minimum value of each pixel (wrt those 2 images), and I need to store a map (i.e a `Mat` object or something similar with a similar size) where each pixel of the map tells me whether the minimum value was taken from he first or the second image
(You can consider them as n*m*2 image where I want to take the minimum value channel-wise, and want to be able to tell from which channel I got this value).
Is there an easy way to do this in OpenCV?
btw, It's for an Android app, so Java answers are preferred over C++. thanks.noamgotSun, 24 Dec 2017 07:47:57 -0600http://answers.opencv.org/question/180985/Matlab and OpenCV4Android - different Mat dimensionshttp://answers.opencv.org/question/180182/matlab-and-opencv4android-different-mat-dimensions/Ther's a piece of code I should translate from Matlab to OpenCV4Android.
Part of this code takes and RGB image and splits it.
When I run the Matlab app, I can see that each of the splitted channels is of type uint8 and the dimensions are 376x640. In that case, the image was loaded by imread , and split by simple matrix operations:
input_im = imread('Field.png');
R = input_im(:,:,1);
G = input_im(:,:,2);
B = input_im(:,:,3);
![image description](/upfiles/15129889098334685.png)
When I run the Android app, after splitting the image (to RGBa first, it doesn't matter), I get that each channel is of type CV_8UC1 (which should be equivalent to uint8, If I'm getting it right), but the dimensions are 1128x1920 (which is multiplying the original dimensions by a factor of 3). The original image was with the same dimensions, but the type was CV_8UC4. The image was preloaded to an `ImageView` and was converted to `Mat`:
private Bitmap mBitmap;
private Mat mImToProcess;
// ...
mBitmap = ((BitmapDrawable) mImageView.getDrawable()).getBitmap();
Utils.bitmapToMat(mBitmap, mImToProcess);
// ...
List<Mat> chans = new ArrayList<>(mImToProcess.channels());
Core.split(mImToProcess, chans);
![image description](/upfiles/15129889912348368.png)
I would like to now what makes this difference? And is there to work in my Android app with similar dimensions to the Matlab app.noamgotMon, 11 Dec 2017 04:45:08 -0600http://answers.opencv.org/question/180182/Matlab haar cascade opencv android compatibilityhttp://answers.opencv.org/question/89190/matlab-haar-cascade-opencv-android-compatibility/I trained a haar cascade classifier in matlab. I want to use the model(xml file) in opencv with android. The xml file says its compatible with OpenCV 2.4. I am using OpenCV 3.0 in android. Will it have any compatibility issue? I am using Android Studio. PulkitThu, 03 Mar 2016 01:44:34 -0600http://answers.opencv.org/question/89190/Converting pixel data from MatLab to something useable in OpenCV4Androidhttp://answers.opencv.org/question/69576/converting-pixel-data-from-matlab-to-something-useable-in-opencv4android/ So I have a bunch of data from MatLab in a 16bit format... Values like Red: 42676, Green: 60145, Blue: 38758 and I'm trying to convert it to something usable in OpenCV as my values coming back are like 238.38.
I'm at a bit of a loss how to make those numbers match up... Any idea's on how to convert the MatLab data would be appreciated.
edit: Is it as simple as dividing by 256?DDS_MytheralThu, 27 Aug 2015 15:10:32 -0500http://answers.opencv.org/question/69576/Porting face alignment project to Android.http://answers.opencv.org/question/56218/porting-face-alignment-project-to-android/The project uses MATLAB, OpenCV, mexopencv and VL Feat. It is based on this research paper : [Face Alignment by Explicit Shape Regression](http://research.microsoft.com/pubs/192097/cvpr12_facealignment.pdf).This is the output that the project produces : [Output.jpg](http://imgur.com/1EGAWme)
My task is to get the code running on an Android device.
I looked into JNI, but thats only for C/C++ as I understand.
What would be the preferred method to go about doing this project?
P.S.- I am a beginner at this, please excuse me if I am unclear.
pookaWed, 25 Feb 2015 18:19:07 -0600http://answers.opencv.org/question/56218/SVM Training Parameters to OpenCVhttp://answers.opencv.org/question/40332/svm-training-parameters-to-opencv/I am creating an Android application that will use OpenCV, specifically its SVM feature. I have a prototype of my application in MATLAB wherein I have already pre-processed multiple images and saved the output values in a csv file and had weka train my SVM classifier. I am porting my code now to Android and I seem to have hit a road bump. Do I have to train the classifier within my OpenCV code? Or can I just input the model parameters and have it predict my outputs? (I take a picture and SVM will automatically classify what kind of image is it.)
I'm reluctant to perform training on my Android device since doing so would be time consuming and I have a deadline to meet. So is it possible to just enter the model parameters in my Android application and it will predict the output? Or if ever I do retrain my classifier in the device, can I use the CSV file I have previously used?
Thanks!joshua_jorel_leeTue, 26 Aug 2014 09:00:47 -0500http://answers.opencv.org/question/40332/Find element position with a limit condition in androidhttp://answers.opencv.org/question/21634/find-element-position-with-a-limit-condition-in-android/Hi,
I would like to know if there is a way to do this function(from Matlab) in opencv:
[R_max_G2 , C_max_G2] = find(max_G2 > 76);
My problem is that i don't want to use 2D for loop or ather kind of loop.
I just want to know if there is another combination in opencv to do this.
This function find the elements in max_G2 that greater than 76 and place their location in R_max_G2 and C_max_G2 arrays;itayMon, 30 Sep 2013 06:03:24 -0500http://answers.opencv.org/question/21634/Replicate with mask in Opencvhttp://answers.opencv.org/question/20785/replicate-with-mask-in-opencv/Hi,
I would like to know if there is a way to do a replicate with Mask?
it should do it like this code in matlab:
imfilter(currGray , [-1 1] , 'same' , 'replicate')
Thanks for help.itayMon, 16 Sep 2013 08:29:48 -0500http://answers.opencv.org/question/20785/Calculation on matrixhttp://answers.opencv.org/question/20859/calculation-on-matrix/Hi, I would like to know if there is a easy way to make some calculations on matrix?
Like add, subtruct, multiply, divide matrix to another matrix, and calculate the power and sqrt of matrix.
For example i want to implement this line from matlab in opencv : Matrix.^2 or sqrt(Matrix)itayTue, 17 Sep 2013 08:02:25 -0500http://answers.opencv.org/question/20859/