Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all 353 articles
Browse latest View live

Opencv4android mask for matchTemplate()

$
0
0
Hi. I'm trying to speed up matchTemplate() for Android. I have already downsampled the image and template to half the original size, but the matching is still somewhat (understandably) slow on some older devices. I acknowledged that I can pass in a mask to the matchTemplate() method. I'm trying to utilize this in the following way: 1) I know the location of the object from the previous frame, lets say its (180, 30). 2) I want to search only around some specified distance around this point, rather than the whole frame. 3) I create a region of interest based on this distance. My question is, how can I utilize this roi such that I can take the current image being searched, and set everything outside the ROI to 0? I can then pass this in as a mask, and thus matchTemplate() would only search the image where pixel values are not 0 (so everything in the ROI)? I have something such as the following: cameraFrameROI = new Rect(topLeftX, topLeftY, width, height); Mat mask = new Mat(mCameraMatResized); // mask = 0 if not part of ROI, otherwise keep original value Imgproc.matchTemplate(new Mat(mCameraMatResized, cameraFrameROI), mTemplateMatResized, mResult, mMatchMethod); But I now need to utilize the ROI to create the actual mask. Would this speed up template matching, and if so, I'm hoping if anyone can provide pointers. Thanks.

Error:(45) *** Android NDK: Aborting . Stop?

$
0
0
There are many similar question but none of them help and some of them are not answered like [this](http://stackoverflow.com/questions/40751967/error45-android-ndk-aborting-stop). I am integrating opencv 3.1 with into android studio 2.2.2 to use c++ code in android i have android NDK downloaded by the android studio and i have Android.mk and Application.mk files. Android.mk file LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) #opencv OPENCVROOT:=C:\Users\The\Documents\OpenCV-android-sdk OPENCV_CAMERA_MODULES:=on OPENCV_INSTALL_MODULES:=on OPENCV_LIB_TYPE:=SHARED include ${OPENCVROOT}\sdk\native\jni\OpenCV.mk LOCAL_SRC_FILES :=print.cpp LOCAL_LDLIBS += -llog LOCAL_MODULE := MyLib include $(BUILD_SHARED_LIBRARY) Application.mk file APP_STL := gnustl_static APP_CPPFLAGS := -frtti -fexceptions APP_ABI :=all APP_PLATFORM := android-25 This worked but i need the opencv extera-module i followed many tutorials like [this](https://zami0xzami.wordpress.com/2016/03/17/building-opencv-for-android-from-source/) but i am unable to build opencv from source with extera-module then i decided to use opencv 2.4 but when i change the above Android.mk openc-android-sdk location to opencv 2.4 the Error:(45) *** Android NDK: Aborting . Stop error occurring. What is wrong it worked for opencv 3.1 but it doesn't work in opencv 2.4?

DescriptorMatcher reports good matches even when object is not in the scene

$
0
0
I'm trying to detect a known object by comparing the current frame in a video against pre-stored feature descriptors. My thought is to match the features of the current frame against the prestored features, and report a positive detection when the number of good features is above some threshold. This, however, doesn't seem to work because `DescriptorMatcher` will always report a certain fixed number of matches regardless of whether the object is actually in the scene. Even though I use a pretty conventional filtering approach to keep the top x number of good matches, it's still a metric that's relative to the current frame. Is there something like goodness of match from `DescriptorMatcher` that I can potentially use as a hard threshold? Is there a better approach to this? I have used Bag of Words before but it seems a bit overkill for the problem at hand, also it's a bit too computational exhaustive for my needs. Any suggestions/tips/pointers would be appreciated. ImageDescriptor imageDescriptor = null; imageDescriptor = ImageDescriptor.fromJson(jsonMetadata); Mat storedDescriptors = imageDescriptor.getFeatureDescriptors(); // prestored features FeatureDetector featureDetector = FeatureDetector.create(FeatureDetector.ORB); DescriptorExtractor descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.ORB); DescriptorMatcher descriptorMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING); MatOfKeyPoint keyPoints = new MatOfKeyPoint(); featureDetector.detect(rgba, keyPoints); // rgba is the image from current video frame MatOfDMatch matches = new MatOfDMatch(); Mat currDescriptors = new Mat(); descriptorExtractor.compute(rgba, keyPoints, currDescriptors); descriptorMatcher.match(descriptors_scene, storedDescriptors, matches); MatOfDMatch good_matches = filterMatches(matches); // filterMatches return the matches that have a distance measure of < 2.5*min_distance if(good_matches.rows()>threshold) return true; return false;

Hi , I have some error in BaseLoaderCallback in android Studio Please look at the code and possibly guide me

$
0
0
MainActivity_show_camera ----- package tahanian.mohsen.camera.one; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.MenuItem; import android.view.SurfaceView; import android.view.WindowManager; import org.opencv.android.BaseLoaderCallback; import org.opencv.android.CameraBridgeViewBase; import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; import org.opencv.android.JavaCameraView; import org.opencv.android.LoaderCallbackInterface; import org.opencv.android.OpenCVLoader; import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; import org.opencv.imgproc.Imgproc; // OpenCV Classes public class MainActivity_show_camera extends AppCompatActivity implements CvCameraViewListener2 { // Used for logging success or failure messages private static final String TAG = "OCVSample::Activity"; // Loads camera view of OpenCV for us to use. This lets us see using OpenCV private CameraBridgeViewBase mOpenCvCameraView; // Used in Camera selection from menu (when implemented) private boolean mIsJavaCamera = true; private MenuItem mItemSwitchCamera = null; // These variables are used (at the moment) to fix camera orientation from 270degree to 0degree Mat mRgba; Mat mRgbaF; Mat mRgbaT; private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { @Override public void onManagerConnected(int status) { switch (status) { case LoaderCallbackInterface.SUCCESS: { Log.i(TAG, "OpenCV loaded successfully"); mOpenCvCameraView.enableView(); } break; default: { super.onManagerConnected(status); } break; } } }; private int show_camera; public MainActivity_show_camera() { Log.i(TAG, "Instantiated new " + this.getClass()); mOpenCvCameraView = (JavaCameraView) findViewById(R.id.show_camera_activity_java_surface_view); } @Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "called onCreate"); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.show_camera); mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE); mOpenCvCameraView.setCvCameraViewListener(this); } private void setContentView(int show_camera) { this.show_camera = show_camera; } private Intent getWindow() { return null; } private void findViewById(int show_camera_activity_java_surface_view) { } @Override public void onPause() { super.onPause(); if (mOpenCvCameraView != null) mOpenCvCameraView.disableView(); } @Override public void onResume() { super.onResume(); if (!OpenCVLoader.initDebug()) { Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization"); OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this.mLoaderCallback); } else { Log.d(TAG, "OpenCV library found inside package. Using it!"); mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS); } } public void onDestroy() { super.onDestroy(); if (mOpenCvCameraView != null) mOpenCvCameraView.disableView(); } public void onCameraViewStarted(int width, int height) { mRgba = new Mat(height, width, CvType.CV_8UC4); mRgbaF = new Mat(height, width, CvType.CV_8UC4); mRgbaT = new Mat(width, width, CvType.CV_8UC4); } public void onCameraViewStopped() { mRgba.release(); } public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // TODO Auto-generated method stub mRgba = inputFrame.rgba(); // Rotate mRgba 90 degrees Core.transpose(mRgba, mRgbaT); Imgproc.resize(mRgbaT, mRgbaF, mRgbaF.size(), 0,0, 0); Core.flip(mRgbaF, mRgba, 1 ); return mRgba; // This function must return } }` My layout : show_camera My Manifest.xml and BaseLoaderCallback.java (The source code is 10 errors) package org.opencv.android; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.util.Log; /** * Basic implementation of LoaderCallbackInterface. */ public abstract class BaseLoaderCallback implements LoaderCallbackInterface { public BaseLoaderCallback() { this(); } public BaseLoaderCallback(tahanian.mohsen.translate.camera.one.MainActivity_show_camera AppContext) { mAppContext = AppContext; } public BaseLoaderCallback(MainActivity_show_camera mainActivity_show_camera) { } public BaseLoaderCallback(CameraBridgeViewBase.CvCameraViewListener2 mainActivity_show_camera) { } public void onManagerConnected(int status) { switch (status) { /** OpenCV initialization was successful. **/ case LoaderCallbackInterface.SUCCESS: { /** Application must override this method to handle successful library initialization. **/ } break; /** OpenCV loader can not start Google Play Market. **/ case LoaderCallbackInterface.MARKET_ERROR: { Log.e(TAG, "Package installation failed!"); AlertDialog MarketErrorMessage = new AlertDialog.Builder(mAppContext).create(); MarketErrorMessage.setTitle("OpenCV Manager"); MarketErrorMessage.setMessage("Package installation failed!"); MarketErrorMessage.setCancelable(false); // This blocks the 'BACK' button MarketErrorMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); MarketErrorMessage.show(); } break; /** Package installation has been canceled. **/ case LoaderCallbackInterface.INSTALL_CANCELED: { Log.d(TAG, "OpenCV library instalation was canceled by user"); finish(); } break; /** Application is incompatible with this version of OpenCV Manager. Possibly, a service update is required. **/ case LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION: { Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!"); AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create(); IncomatibilityMessage.setTitle("OpenCV Manager"); IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play."); IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); IncomatibilityMessage.show(); } break; /** Other status, i.e. INIT_FAILED. **/ default: { Log.e(TAG, "OpenCV loading failed!"); AlertDialog InitFailedDialog = new AlertDialog.Builder(mAppContext).create(); InitFailedDialog.setTitle("OpenCV error"); InitFailedDialog.setMessage("OpenCV was not initialised correctly. Application will be shut down"); InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); InitFailedDialog.show(); } break; } } public void onPackageInstall(final int operation, final InstallCallbackInterface callback) { switch (operation) { case InstallCallbackInterface.NEW_INSTALLATION: { AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create(); InstallMessage.setTitle("Package not found"); InstallMessage.setMessage(callback.getPackageName() + " package was not found! Try to install it?"); InstallMessage.setCancelable(false); // This blocks the 'BACK' button InstallMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { callback.install(); } }); InstallMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "No", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { callback.cancel(); } }); InstallMessage.show(); } break; case InstallCallbackInterface.INSTALLATION_PROGRESS: { AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create(); WaitMessage.setTitle("OpenCV is not ready"); WaitMessage.setMessage("Installation is in progress. Wait or exit?"); WaitMessage.setCancelable(false); // This blocks the 'BACK' button WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { callback.wait_install(); } }); WaitMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "Exit", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { callback.cancel(); } }); WaitMessage.show(); } break; } } void finish() { ((Activity) mAppContext).finish(); } protected tahanian.mohsen.translate.camera.one.MainActivity_show_camera mAppContext; private final static String TAG = "OpenCVLoader/BaseLoaderCallback";

cannot save SVM in OpenCV4Android 3.2 after upgrade: Fatal signal 11

$
0
0
I just upgraded to 3.2.0 from 2.4.9 and it seems like the save function is broken? All I did was change `CvSVM` to `SVM` SVM svmClassifier = SVM.create(); File svm_file = new File(dir, "svm_test.xml"); svmClassifier.save(svm_file.toString()); will now report `A/libc: Fatal signal 11 (SIGSEGV) at 0x644e98f8 (code=2), thread 2380 (Thread-6433)`. The same flow worked fine with 2.4.9 and `CvSVM`. Help?

Display detected face image on Android

$
0
0
Hello. I'm trying to develop a mobile app where I would perform some operations on detected face images. So first I want to display detected images on the screen. I used example opencvsamplefacedetection as a starting point. Then I created a imageview object (detectedFace). Following is what I attempted: public Mat onCameraFrame(CvCameraViewFrame inputFrame) { mRgba = inputFrame.rgba(); mGray = inputFrame.gray(); if (mAbsoluteFaceSize == 0) { int height = mGray.rows(); if (Math.round(height * mRelativeFaceSize) > 0) { mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize); } mNativeDetector.setMinFaceSize(mAbsoluteFaceSize); } MatOfRect faces = new MatOfRect(); if (mDetectorType == JAVA_DETECTOR) { if (mJavaDetector != null) mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size()); } else if (mDetectorType == NATIVE_DETECTOR) { if (mNativeDetector != null) mNativeDetector.detect(mGray, faces); } else { Log.e(TAG, "Detection method is not selected!"); } Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++){ Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); } **if (facesArray.length>=1){ Rect Reg = facesArray[0]; Mat m = mGray.submat(Reg); Bitmap bm = Bitmap.createBitmap(m.cols(), m.rows(),Bitmap.Config.ARGB_8888); Utils.matToBitmap(m, bm); // find the imageview and draw it! ImageView iv = (ImageView) findViewById(R.id.detectedFace); iv.setImageBitmap(bm); }** return mRgba; } When I run this I found that at iv.setImageBitmap(bm) my program crashes. Why is this? Is there a reason why I can't change attributes within this class? Please help me to figure out how this can be done. Thanks!

Can you capture screen and run a filter on Android?

$
0
0
Hi, I have written my Android app (java) so it can capture my Android app screen (framebuffer) put it in a bitmap then run a filter on the bitmap then put it back into a resultant bitmap to display as a texture overlay. I am using glreadpixels for opengl es 3.0 to get the image. It is slower than I like it to be and was looking at using the NDK but was wondering if OpenCV can do that. If so what example(s) should I look at to accomplish that goal? So basically the steps are that I am doing now: 1. Capture the frame of pixels using GLES30.glreadpixels() 2. Convert the captured frame buffer pixels from GLES30.GL_RGBA to RGBA_8888 and put into Bitmap 3. Run the Bitmap from step 2 through the desired filter producing a resultant Bitmap 4. Convert the Bitmap to a texture 5. Overlay texture on glsurfaceview. I want to do steps 1-4 faster using OpenCV. Step 1 is taking me around 60ms, step 2 around 200ms I have not measured the other steps yet. The steps are all done right now using java and GLES30 outside of NDK. If I can do all easily and quick using NDK with OpenCV that is good but most of the examples I have seen use a camera and save to a file. So not sure I can use OpenCV to do what I need. Thanks for the help! -Tony

Fatal signal 11 (SIGSEGV), code 2 from knnMatch in OpenCV4Android 3.2

$
0
0
I'm trying to do a pretty simple feature matching project but am running into `this line here causes Fatal signal 11 (SIGSEGV), code 2, fault addr 0x12c4f000 in tid 10135 (Thread-3960)` from OpenCV 3.2.0. Basically I am calling ORB on two images, and then BFMatcher. I have the same code working in OpenCV 3.2.0 C++, and OpenCV4Android 2.4.9. Is this a bug with 3.2.0? Code below: ORB featureDetector = ORB.create(300, 1.2f, 4, 31, 0, 2, ORB.HARRIS_SCORE, 31, 20); BFMatcher descriptorMatcher = BFMatcher.create(BFMatcher.BRUTEFORCE_HAMMING,false); MatOfKeyPoint keyPoints1 = new MatOfKeyPoint(); MatOfKeyPoint keyPoints2 = new MatOfKeyPoint(); Mat testDescriptor1 = new Mat(); Mat testDescriptor2 = new Mat(); List nn_matches = new ArrayList(); featureDetector.detect(Img1, keyPoints1); featureDetector.detect(Img2, keyPoints2); featureDetector.compute(Img1, keyPoints1, testDescriptor1); featureDetector.compute(Img2, keyPoints2, testDescriptor2); descriptorMatcher.knnMatch(testDescriptor1, testDescriptor2, nn_matches, 2); // crash here

how to add android opencv library in Qt project

$
0
0
hey guys! could anybody help me with setting up qt project for using opencv on android? my pro file looks like this: ... ANDROID_OPENCV = ../opencv2410androidsdk/sdk/native INCLUDEPATH += $ANDROID_OPENCV/jni/include/ LIBS += -L$$ANDROID_OPENCV/libs/armeabi-v7a\\\* ... opencv2410androidsdk is directory, where opencv for android was unzipped The problem is that qt doesn't see given libraries and gives me many errors like "undefined reference to .." in each place when i try to use opencv objects and methods. Could anybody help me pls

Configure OpenCV for Android with Visual Studio(NVIDIA Nsight )

$
0
0
I want to develop the Android app using opencv4android SDK with Visual Studio(not C# Android), I can not use Eclipse or Android studio with some reasons. I have installed VS 2015 professional, I set up the environment use [NVIDIA Codeworks for Android version 1R4](https://developer.nvidia.com/codeworks-android) (TADP) , it includes JDK SDK NDK ANT Gradle Eclipse CDT opencv4tegra and Nsight Tegra Visual Studio Edition, I use Eclipse to test OpenCV samples(OpenCV-2.4.8.2-Tegra-sdk\samples), all samples can compile and work, so that I assumed that the installation is ok. ![image description](/upfiles/14850810748318066.png) I create Android Application under Nsight Tegra, write a simple helloworld(pure java without native code c/c++), the program can compile and work. I import opencv module in .java file, " import org.opencv.*.**** ;" it surely compile with error, error says that it can not find org.opencv.* , Next, I want to include opencv4android SDK(it's a challenge for me), I click Properties of project, Ant Build -> Java -> Java Source Directories, I add opencv java source dir "C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src" to it, it compile with a different error, now it can find the org.opencv folder, error is "Package R not exist", the R is org.opencv.R. -compile: [javac] Compiling 93 source files to C:\Users\linzi\Desktop\kk\Android1\Android1\Tegra-Android\Debug\bin\classes [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:5: Error: can not find symbol [javac] import org.opencv.R; [javac] ^ [javac] symbol: class R [javac] location: package org.opencv [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:72: error: package R not exist [javac] TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase); [javac] ^ [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:73: error: package R not exist [javac] if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false)) [javac] ^ [javac] C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java:76: error: package R not exist [javac] mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1); [javac] ^ [javac] 4 errors BUILD FAILED C:\NVPACK\android-sdk-windows\tools\ant\build.xml:716: The following error occurred while executing this line: C:\NVPACK\android-sdk-windows\tools\ant\build.xml:730: Compile failed; see the compiler error output for details. Total time: 3 seconds Picked up _JAVA_OPTIONS: -Xms256m -Xmx1024m C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Tegra-Android\Nvidia.AndroidBuild.targets(253,5): error : No errors were parsed from the Ant log. See the Output window for the build messages. C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning : Error: can not find symbol C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning : symbol: class R C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(5,18): warning : location: package org.opencv C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(72,78): warning : error: package R not exist C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(73,37): warning : error: package R not exist C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(76,44): warning : error: package R not exist C:\NVPACK\OpenCV-2.4.8.2-Tegra-sdk\sdk\java\src\org\opencv\android\CameraBridgeViewBase.java(76,44): warning : 4 errors [this link](http://answers.opencv.org/question/25482/cant-build-opencv-library-and-samples-for-android-opencvengineinterface-and-orgopencvr/) answer says: org.opencv.R and org.opencv.engine.OpenCVEngineInterface are auto generated classes. But I still don't know I to configure... how to solve this problem?

DescriptorMatcher in OpenCV3 for Android

$
0
0
Dear all, I am a newbie for developing with OpenCV and computer Vision, this is a first project i developed with OPENCV on Mobile - Android - used Android Studio. I can use many functions of OpenCV Library, but when I call DescriptoerMatcher in Java file, I miss errors, details code: //detect the key points detector.detect(inputMat1,keypoints1); detector.detect(inputMat2,keypoints2); //detect decriptor Mat descriptors1 = new Mat(); Mat descriptors2 = new Mat(); descriptorExtractor.compute(inputMat1,keypoints1,descriptors1); descriptorExtractor.compute(inputMat2,keypoints2,descriptors2); processedMat1 = new Mat(); processedMat2 = new Mat(); Imgproc.cvtColor(inputMat1,processedMat1,Imgproc.COLOR_RGBA2RGB); Imgproc.cvtColor(inputMat2,processedMat2, Imgproc.COLOR_RGBA2RGB); Features2d.drawKeypoints(processedMat1,keypoints1,processedMat1,new Scalar(255,255,0),4); Features2d.drawKeypoints(processedMat2,keypoints2,processedMat2,new Scalar(255,255,0),4); ***DescriptorMatcher descriptorMatcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);*** But the error is line create **DescriptoerMatcher**. Detailed of error: JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x4 from long org.opencv.features2d.DescriptorMatcher.create_0(int) I trying research but now, I haven't found a issue and how to implement error. Hope received of any people. Thanks so much.

how can i detect shapes what i define in android opencv

$
0
0
i want to detect small particles which are different each other in android. and i want to take count same shape. sample code please! i tried following codes and minEnclosingCircle is not working in this codes

mat newMat = new Mat() crashes android app

$
0
0
The title pretty much sums it up. I have this chunk of code that runs fine, but when I try to create a mat, the entire app crashes.

Bicycle detection with opencv library in android

$
0
0
I am very new with opencv. My project is to detect bicycle using opencv or any other open source library in android. I can successfully run the sample project of opencv and import in android studio using another. Then I have tried to achieve my goal by replacing the xml from raw directory with /latentsvmdetector/bicycle.xml but it shows unsupported character in xml and crashed the application. After that I have researched almost every link. Many suggest that it is a complex task and it needs to use Latent SVM. But I am failed to find the way how to use this in my project. I don't get any suitable example of Latent SVM in android. I have also tried to build the cascade xml from positive images(1600) and negative images(600) data set from but failed to build it with some opencv error. I am really very confused what is the suitable way for this task. I think if I get any sample project to detect such complex object in android then I can be able to complete my task. Any link or sample code will be really appreciable. Thanks every one for your kind attention.

OpenCV Matrix get wrong values JNI Java

$
0
0
I'm trying to pass OpenCV Matrix to a cpp file but the data I read from the Matix in the cpp is not right. I don't know what I'm missing here, Maybe something with the pointer. This is part of my cpp file: jintArray Java_qc_yotm_mes_com_yo_1qc_MainActivity_stringFromJNI(JNIEnv *env,jclass cls,jint NUMBER_OF_HALF_LINES, jint HALF_LINE_LENGTH, jlong inMat) { cv::Mat* GraySubMat = (cv::Mat*)inMat; unsigned char * MatData = GraySubMat->data; jdouble SumSpikesHeight = 0; jint ListOfPeaks = 0; jintArray ListSpikesCount = env->NewIntArray(2 * NUMBER_OF_HALF_LINES); jintArray ListSpikesCountHeight = env->NewIntArray(2 * NUMBER_OF_HALF_LINES); jint outarray[2 * NUMBER_OF_HALF_LINES]; for(int line_number = 0 ; line_number < 2 * NUMBER_OF_HALF_LINES ; line_number++) { //Find Peaks on every 5 pixels for (int i = 2; i < (HALF_LINE_LENGTH * 2) - 3; i++) { if ((MatData[(line_number *HALF_LINE_LENGTH * 2)+i] > MatData[(line_number *HALF_LINE_LENGTH * 2)+i - 1]) && (MatData[(line_number *HALF_LINE_LENGTH * 2)+i] > MatData[(line_number *HALF_LINE_LENGTH * 2)+i - 2]) && (MatData[(line_number *HALF_LINE_LENGTH * 2)+i] > MatData[(line_number *HALF_LINE_LENGTH * 2)+i + 1]) && (MatData[(line_number *HALF_LINE_LENGTH * 2)+i] > MatData[(line_number *HALF_LINE_LENGTH * 2)+i + 2]) && (MatData[(line_number *HALF_LINE_LENGTH * 2)+i] > 0) ) { ListOfPeaks++; SumSpikesHeight += MatData[(line_number *HALF_LINE_LENGTH * 2)+i]; i += 3; } } outarray[line_number] = ListOfPeaks*SumSpikesHeight; SumSpikesHeight = 0; ListOfPeaks=0; } env->SetIntArrayRegion(ListSpikesCountHeight, 0, 2 * NUMBER_OF_HALF_LINES, outarray); return ListSpikesCountHeight; } This is the Java call: int[] spikecountheight = stringFromJNI(NUMBER_OF_HALF_LINES, HALF_LINE_LENGTH, GraySubMat.getNativeObjAddr());

Image Calibration

$
0
0
I am new to image processing. I have a data set of images and I want to perform calibration on those images based on a target image. I have surfed a lot on image calibration but the majority of the results yield camera calibration.So,I I am confused as to whether these are same or different things.I have several question in my mind. Can anybody explain to me the difference between these two terms? On reading through one of the results on image calibration, I got to know that there are three steps that I need to perform: * Bias Frame Calibration * Dark Frame Calibration * Flat Field Frame Calibration So, I want to know if these 3 steps will be possible using OpenCV or not? Also, I need to perform this in Android. For that, I have figured out that I will need to use OpenCV. I have seen the documentation of it. There are lot of things there onto documentation page. So, Which part can solve my problem. Kindly share some resource for this. Thank you so much for your time.

How do I support c++11 in Opencv 3 Android NDK

$
0
0
Hi, all I am doing the next changes to support c++11 with opencv 3 in android NDK: I change from APP_STL := gnustl_static to APP_STL := c++_static Application.mk APP_STL := c++_static APP_CPPFLAGS := -std=c++11 -frtti -fexceptions APP_ABI := armeabi armeabi-v7a mips x86 arm64-v8a x86_64 mips64 APP_PLATFORM := android-14 # use this to select gcc instead of clang NDK_TOOLCHAIN_VERSION := 4.9 Android.mk LOCAL_PATH := $(call my-dir) LOCAL_PATH_LIB_DIR:=library/lib/classifier include $(CLEAR_VARS) OPENCV_CAMERA_MODULES:=off OPENCV_INSTALL_MODULES:=on OPENCV_LIB_TYPE:=SHARED include ../../../OpenCV-android-sdk/sdk/native/jni/OpenCV.mk LOCAL_MODULE:= detection_based_tracker LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp \ library/jniUtils.cpp \ ${ LOCAL_PATH_LIB_DIR}/logic.cpp \ ${ LOCAL_PATH_LIB_DIR}/logic2.cpp \ LOCAL_C_INCLUDES += $(LOCAL_PATH) LOCAL_LDLIBS += -llog -ldl -lm -latomic -L$(LOCAL_PATH)/libs/armeabi - L$(LOCAL_PATH)/libs/armeabi-v7a -L$(LOCAL_PATH)/libs/mips -L$(LOCAL_PATH)/libs/x86 -L$(LOCAL_PATH)/libs/arm64-v8a -L$(LOCAL_PATH)/libs/mips64 -L$(LOCAL_PATH)/libs/x86_64 LOCAL_CPPFLAGS += -ljnigraphics -D_LINUX -DBOOST_HAS_PTHREADS -fexceptions -std=c++11 -I$(LOCAL_PATH)/ -I$(LOCAL_PATH)/library/lib/pico/ I LOCAL_CPP_FEATURES := exceptions rtti APP_OPTIM := debug include $(BUILD_SHARED_LIBRARY) When I compile the Android app with Android NDK r10e. I hav the next errores in the Log: error: undefined reference to 'cv::DescriptorMatcher::match(cv::_InputArray const&, cv::_InputArray const&, std::__1::vector>&, cv::_InputArray const&) const' undefined reference to 'cv::Subdiv2D::insert(std::__1::vector,std::__1::allocator>> const&)' error: undefined reference to 'cv::imwrite(cv::String const&, cv::_InputArray const&, std::__1::vector> const&)' the undefined reference to cv::imwrite method, this method is in the native SDK opencv in the path "opencv/imgcodecs.hpp" CV_EXPORTS_W bool imwrite( const String& filename, InputArray img, const std::vector& params = std::vector());

Applying NDVI indicator on JPEG images in Android using OpenCV

$
0
0
I am a beginner in image processing. I have a set of survey images of a farm which I have stitched (eliminating the overlap) and the result is one single image (JPEG) of the entire farm. I want to apply different algorithms on this image for analysis. I want to apply the NDVI index on this farm image and for that I need to do raster calculations. Can someone tell me the workflow or the steps that I will need to perform to produce a NDVI image of the farm in Android using OpenCV? Is it possible by OpenCV? If not, what are the other ways to produce this output in Android?

How to Manually Change Exposure Value in Android

$
0
0
I'm trying to disable auto-exposure and manually set an exposure value in the color-blob-detection sample provided with the SDK. Is there a way to do this via OpenCV or the native Android Camera2 API? Any help would be greatly appreciated.

How can i use opencv FloodFill with java?

$
0
0
I tried to use floodfill in my source code but the application doesn't work and this is my code : `final Bitmap bitmap = BitmapFactory.decodeFile(fileUri.getPath(),options); Mat tmp = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1); Utils.bitmapToMat(bitmap, tmp); Mat gray = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1); Imgproc.cvtColor(tmp, gray, Imgproc.COLOR_RGB2GRAY); Photo.fastNlMeansDenoising(gray, gray,5,7,21); Mat stub = new Mat(gray.rows() + 2,gray.cols() + 2, CvType.CV_8U); Imgproc.floodFill(gray,stub, new Point(0, 0), new Scalar(255, 255, 255)); Utils.matToBitmap(stub, bitmap);`
Viewing all 353 articles
Browse latest View live