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

How to determine an image with strong or weak illumination in android API please

$
0
0
I need to analyse an image and see if it has a good level of ilumination, but I need to do that in Android.

How to integrate OpenCV Manager in Android App without ask user to install additional app in the device please

$
0
0
Hello I need a way to instal the opencv manager within the host app without install a second app for it, that works well in production. Kind regards.

why imread return empty matrix

$
0
0
l'm work on android app with opencv 2.4.9 and in jni function l try to read images from database l test simple one Mat testSample = imread("/storage/emulated/0/h.jpg"); l search online but can't solve it but imread function return empty so what's problem? and what's debug mode or release mode (Do l face problem because of them if yes how to fix it) sorry l'm beginner

How to Crop image after extract text in JAVA

$
0
0
I'm trying to use android-opencv to recognize text in the picture and I want to do something like finding blocks of text in an image and crop them. After croping image I will get some of text image and I plan to use them to do OCR in the future. For now I can detect the text regien in the image already by useing this algorithm guide from this link stackoverflow.com/questions/34271356/extracting-text-opencv-java ** My problem is I do not know how to Croping image after extracting text in java language. ** In my concept, I will crop the image from top to button and from left to right. After that put all of croped image in an array of MAT (I'm not sure that MAT function can do the array or not) i.imgur.com/mZfM7H9.jpg [see my concept picture] I do not know how to deal with them. Could anyone please help me, guide me, or give me some advice please ... Thanks in advance.

How to convert Camera frame to Video in android?

$
0
0
I need to convert camera frame to video . how to do it ? . is there sample code for this?

Built library is twice as large as the distributed one

$
0
0
When I use `cmake` to build `libopencv_java3.so` in release mode with default configuration I got a library of **17MB** I can reduce that to **10MB** by adding some flags and disabling some modules. cmake -DBUILD_opencv_videostab=OFF \ -DBUILD_ANDROID_EXAMPLES=OFF \ -DBUILD_opencv_stitching=OFF \ -DBUILD_opencv_tracking=OFF \ -DBUILD_opencv_datasets=OFF \ -DBUILD_opencv_nonfree=OFF \ -DBUILD_opencv_contrib=OFF \ -DBUILD_opencv_legacy=OFF \ -DBUILD_opencv_world=OFF \ -DBUILD_opencv_photo=OFF \ -DBUILD_opencv_apps=OFF \ -DBUILD_opencv_ts=OFF \ -DBUILD_EXAMPLES=OFF \ -DBUILD_SAMPLES=OFF \ -DWITH_CUDA=OFF \ ... -DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all" \ -DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all - fvisibility-inlines-hidden" \ -DBUILD_WITH_DEBUG_INFO=OFF \ ... But the distributed library available in opencv-3.2.0-android-sdk.zip is **8.6MB** large ! How can I get a library of that size ?

Loading video files using VideoCapture in Android

$
0
0
Hi, My aim is to load two video files, grabbing the frames from each file and creating a single frame. I have understood I can use `VideoCapture` java class to load files and use `Mat` class to work on individual frames. I have two AVI files stored at `/storage/emulated/0/Download/received_files/.avi`. However VideoCapture is unable to open the files. VideoCapture vc1 = new VideoCapture(); VideoCapture vc2 = new VideoCapture(); if (!vc1.open(video1)) { Log.e(TAG, "Could not open the video file1"); } else { Log.i(TAG, "Video1 loaded"); } if (!vc2.open(video1)) { Log.e(TAG, "Could not open the video file1"); } else { Log.i(TAG, "Video2 loaded"); } It always pronts "Could not open ..." message. I have tested the file paths using File.exists and it returns true. What am I missing here? I am using OpenCV 3.2.0 for Android and Android lollipop. My Android setup is done properly and I can view the camera in JavaCameraView.

build OpenCV 3.1 for android with openCL support

$
0
0
Hi All! I tried OpenCL on my OpenCV project and the result is a huge improvement in terms of performance so I would like to try OpenCL on android. I use this [article](http://docs.opencv.org/3.1.0/d7/dbd/tutorial_android_ocl_intro.html) to guide me. Here is my cmake command: cmake -GNinja -DCMAKE_MAKE_PROGRAM="/usr/bin/ninja" -DCMAKE_TOOLCHAIN_FILE="../opencv-3.1.0/platforms/android/android.toolchain.cmake" -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DWITH_OPENCL=YES -DANDROID_ABI="armeabi-v7a" ../opencv-3.1.0 and I use this command ninja install/strip I have no errors neither on compilation nor installation. And an `install` folder has been created. I think all is perfectly fine except that I can't find the `libopencv_java3.so` file !!!!! so: 1. Do you know how I can generate libopencv_java3.so ? 2. Do you know how I can target several abis ? I tried `-DANDROID_ABI="armeabi-v7a" -DANDROID_ABI="x86"` and `-DANDROID_ABI="armeabi-v7a x86"` but it is not correct. Thank you !

It is possible to know how much of a given color is Required to If you come to another color with OpenCV?

$
0
0
My question was a bit confusing. I'll explain the situation. I have 1 color, which is the result of mixing other 4 colors. Since I am new to the forum, I can not Attach the image in that question, But it can be accessed from [this link](http:// www.dropbox.com/s/e5tv96984hpe6jt/image.png?dl=0) -> The image that is in the link, shows that the color that a color was Formed by the mastrura of 4 other colors. Knowing that colors are fluid, and that The amount of fluid used to obtain the new color are the following:

1st Situation

Tio2 - 2kg of fluid

GG - 0.2kg of fluid.

A407 - 0.3kg of fluid.

Yellow - 1kg of fluid.

Color generated by the [1st situation](http://www.dropbox.com/s/0tdkht08p73sy6j/img-01.png?dl=0):

Caution: above values are fixed.

I want to create your whole situation: Suppose the person responsible for producing the color uses the values below

2nd Situation

Tio2 - 1.5 kg of fluid

GG - 0.2 kg of solid.

A407 - 0.3 kg fluid.

Yellow - 0.5 kg of fluid.

Color generated by the [2nd situation: ->](http://www.dropbox.com/s/bnddoq9q3lqcyqc/img-02.png?dl=0) **Note: Note that the values used for Ti02 and yellow have changed.** The values that should be used were the 1st situation.

Tio2 - 2 kg of fluid

GG - 0.2 kg of solid.

A407 - 0.3 kg fluid.

Yellow - 1 kg of fluid.

**The result we already know:** The mixture of the 2nd situation will have a completely different color from the 1st situation, As the images show. *Comparison between [the two images](http:// www.dropbox.com/s/hsytwtkhtt94xn5/img-03.png?dl=0)*

Now we are ready for the question:

The two images will be placed side by side: I would like to know if analyzing the images using OpenCV it is possible to identify, Which should be added:

0.5 kg of Thio 2 fluid

and

0.5 kg of yellow

The example is in [image 4](http://www.dropbox.com/s/uqeomxgme7h30lv/img-04.png?dl=0) I do not know if it was well explained. If anyone can help me, then I need to develop an application that is able to make that comparison and give me that result. Thanks

Open cv image proc on iOS and Android framework limit size.

$
0
0
I want to be able to only use a couple of image processing components in my app. I am limited by the size of what I can use as it is part of an SDK. How would I go about compiling just the canny edge detector and contour detector for use in iOS and Android without taking in the whole frame work.

Cannot load SVM .xml file in OpenCV 3.2.0 Android

$
0
0
I have problem with loading saved .xml file for my SVM predictor after upgrading OpenCV version to 3.2.0. The error I get is following: java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.ml.SVM.load_0(java.lang.String) (tried Java_org_opencv_ml_SVM_load_10 and Java_org_opencv_ml_SVM_load_10__Ljava_lang_String_2) And the code which do this: String dataPath = Environment.getExternalStorageDirectory().toString() + "/svmdata.xml"; SVM predictor = SVM.load(dataPath); It fails in the second line while loading. Am I missing something in this new version? Could not find any solution for that.

Improper Computation of NDVI

$
0
0
I am new to image processing. I am applying NDVI index on an image of an agricultural farm taken by drone. But the formula (NIR-Red)/(NIR+Red) is giving me wrong output (here instead of NIR we are using the blue channel). Then I came to know that the image I am using is taken by camera with NIR sensors. Would the formula differ from normal formula of NDVI?

How can I regenerate .SO files for my opencv library

$
0
0
I am using opencv library for Video Recording , My application is for live video streaming and recording (both audio and video) using wifi. Once I tried to upload to play store Google rejected my application due to Libpng vulnerability , and I found the problem with opencv lib version, so replaced the opencv jar file with its gradle dependency ,deleted the .so files from libs/armeabi.jar folder and rebuit the project,,then Google didn't show that vulnerability issue and it got uploaded to the play store. But the Shared object files arent regenerating, hence some functionality like recording the streamed video does not work. I would like to know How can I regenerate .SO files .

algorithm to computer vision obstacle detection ??

$
0
0
My graduation project is indoor navigation system for blind people so I need to implement obstacle detection using android and open CV, I followed these steps but accuracy is not good : 1- convert to grayscale 2-canny function to detect edges 3- dilate the detected edges by 500% 4- blur the image using a Gaussian blur 5- use findContours function to detect closed shapes and draw bounding circles around the shapes any help with paper or algorithm I should follow??

How to do face detection using VideoCapture?

$
0
0
I've to develop a makeup application like Lakme pro. someone suggest me to use opencv. I found a demo for face detection of opencv lib but the demo is not working. please help me to implement opencv for face detection.

Extract symbols from an image

$
0
0
Hi, I'm working on an android app that make some image processing by using opencv , I made a grayscale image, then Canny edge detection Like this photo : ![image description](/upfiles/14878745053552298.png) Now i need to get every symbol from this equation in a picture alone, How can i do that ?

Android Java Opencv canny throws cvexception

$
0
0
I want to detect edges from images using Canny in Android, but it keeps throwing this error: E/cv::error(): OpenCV Error: Assertion failed (_dx.type() == CV_16SC1 || _dx.type() == CV_16SC3) in void cv::Canny(cv::InputArray, cv::InputArray, cv::OutputArray, double, double, bool), file /build/master_pack-android/opencv/modules/imgproc/src/canny.cpp, line 959 E/org.opencv.imgproc: imgproc::Canny_11() caught cv::Exception: /build/master_pack-android/opencv/modules/imgproc/src/canny.cpp:959: error: (-215) _dx.type() == CV_16SC1 || _dx.type() == CV_16SC3 in function void cv::Canny(cv::InputArray, cv::InputArray, cv::OutputArray, double, double, bool) W/System.err: CvException [org.opencv.core.CvException: cv::Exception: /build/master_pack-android/opencv/modules/imgproc/src/canny.cpp:959: error: (-215) _dx.type() == CV_16SC1 || _dx.type() == CV_16SC3 in function void cv::Canny(cv::InputArray, cv::InputArray, cv::OutputArray, double, double, bool) W/System.err: ] W/System.err: at org.opencv.imgproc.Imgproc.Canny_1(Native Method) W/System.err: at org.opencv.imgproc.Imgproc.Canny(Imgproc.java:984) W/System.err: at app.android.opencvproject.OpenCVText.detectContours(OpenCVText.java:185) W/System.err: at app.android.opencvproject.CameraPreview$1$1.run(CameraPreview.java:428) W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) W/System.err: at java.lang.Thread.run(Thread.java:818) I don't know what causes the error and I did not find any answer on the internet. Here is the code I used: public void detectContours(Bitmap bitmap){ try{ Mat img = new Mat(); Utils.bitmapToMat(bitmap, img); Mat gray = new Mat(img.size(), CvType.CV_8UC1); Imgproc.cvtColor(img, gray, Imgproc.COLOR_RGB2GRAY, 4); Imgproc.Canny(gray, gray, 80, 100); Bitmap outputBitmap = Bitmap.createBitmap(gray.cols(), gray.rows(), Bitmap.Config.ARGB_8888); Utils.matToBitmap(gray, outputBitmap); MediaStore.Images.Media.insertImage(context.getContentResolver(), outputBitmap, "Opencv" , "Hello"); Log.d("OPENCV", "Image stored in your gallery"); }catch (Exception e){ e.printStackTrace(); } } Can someone help me to solve this problem? Thanks in advance!

Android_app_not_working_on_x86_64_systems

$
0
0
A friend asked me to check whether it is possible to make an app work on a x86_64 Android system. The app was written a couple of years ago implementing openCv 2.4.5 libraries and works fine on x86 systems. The real problem is that he lost (or so he says) the source code files and all I have is an .apk file. I decompiled it using apktool, and found, among others, a 'lib' directory containing the following directories:'arm64-v8a', 'armeabi', armeabi-v7a', 'mips', 'mips64', 'x86', 'x86_64'. There's a 'libopencv_info.so' file in each directory, but only in x86 directory I found the 'libopencv_java.so' libraries file. Am I right in thinking that there is no 'libopencv_java.so' libraries file that I could put into the 'x86_64' directory so as to make the app work on 64bit systems? Could I somehow change the smali files (what to look for?) or do I have write the app from scratch? I will be grateful for any suggestions :-)

How can i increade and decrease the thickness for the Curve openCV

$
0
0
How can I increase and decrease the thickness for the Curve in openCV My code can draw like below pictuer: ![image description](/upfiles/1488477924974987.png) I want my code to do : show the result by increasing the spline’s thickness and changing the color to blue. 1- ‘I’ or ‘i’ – increase the spline thickness by 1 2- ‘D’ or ‘d’ – decrease the spline thickness by 1 as figure 2 ![image description](/upfiles/14884779492579524.png) My code is below: #include #include "opencv2/imgproc/imgproc.hpp" #include #include #include using namespace std; using namespace cv; int first_click = 0; int Xholder, Yholder; Point pt[4]; vector pts; Mat img_org; Mat img_show;// show image int Mousedrag = 0; Mat img; Mat imgcopy; int remove1 = 0; int id = -1; void onMouse(int event, int x, int y, int flags, void* param) { if (event == CV_EVENT_LBUTTONDOWN) { for (int i = 0; i < pts.size(); i++) { if (((x - 4) < pts[i].x && pts[i].x < (x + 4) && (y - 4) < pts[i].y && pts[i].y < (y + 4))) { id = i; break; } id = -1; } Mousedrag = 1; if (first_click == 4 || first_click == 0) { if (id == -1) pts.push_back(cv::Point(x, y)); first_click = 1; } else if (first_click == 1){ pts.push_back(cv::Point(x, y)); first_click = 2; } else if (first_click == 2){ pts.push_back(cv::Point(x, y)); first_click = 3; } else { pts.push_back(cv::Point(x, y)); first_click = 4; } } //in order to delete the last pont else if (event == CV_EVENT_RBUTTONDOWN) { if (first_click == 1) { pts.pop_back(); first_click = 4; } else if (first_click == 2){ pts.pop_back(); first_click = 1; } else if (first_click == 3){ pts.pop_back(); first_click = 2; } else if (first_click == 4){ pts.pop_back(); first_click = 3; } } else if (event == CV_EVENT_LBUTTONUP) { Mousedrag = 0; if (id >= 0){ pts[id].x = x; pts[id].y = y; } } } void drawSpline(cv::Point a, cv::Point b, cv::Point c, cv::Point d) { // Way one to assign a matrix cv::Mat G_Hermite(4, 2, CV_32FC1); G_Hermite.ptr(0)[0] = a.x; G_Hermite.ptr(0)[1] = a.y; G_Hermite.ptr(1)[0] = b.x; G_Hermite.ptr(1)[1] = b.y; G_Hermite.ptr(2)[0] = c.x; G_Hermite.ptr(2)[1] = c.y; G_Hermite.ptr(3)[0] = d.x; G_Hermite.ptr(3)[1] = d.y; //Way two to assign a matrix float data[4][4] = { { -1, 3, -3, 1 }, { 3, -6, 3, 0 }, { -3, 3, 0, 0 }, { 1, 0, 0, 0 } }; cv::Mat M_Hermite(4, 4, CV_32FC1, &data); cv::Mat coefficient_AB(4, 2, CV_32FC1); coefficient_AB = M_Hermite * G_Hermite; for (float t = 0.0f; t <= 1.0f; t += 0.0001f) { int x = coefficient_AB.ptr(0)[0] * pow(t, 3) + coefficient_AB.ptr(1)[0] * pow(t, 2) + coefficient_AB.ptr(2)[0] * t + coefficient_AB.ptr(3)[0]; int y = coefficient_AB.ptr(0)[1] * pow(t, 3) + coefficient_AB.ptr(1)[1] * pow(t, 2) + coefficient_AB.ptr(2)[1] * t + coefficient_AB.ptr(3)[1]; cv::circle((img), cv::Point(x, y), 1, cv::Scalar(0, 0, 0), 1); } cv::line(img, a, b, cv::Scalar(0, 0, 255)); cv::line(img, c, d, cv::Scalar(0, 0, 255)); } void drawPoint(cv::Point a) { cv::circle(img, a, 1, cv::Scalar(0, 0, 255), 2); } int main(int argc, const char * argv[]) { imgcopy = imread("c:/aa/download.png"); imgcopy.copyTo(img); //Initially set negative number as no points have been selected yet pt[0].x = -1; pt[0].y = -1; pt[1].x = -1; pt[1].y = -1; pt[2].x = -1; pt[2].y = -1; pt[3].x = -1; pt[3].y = -1; cv::namedWindow("test"); cv::setMouseCallback("test", onMouse); while (1) { imgcopy.copyTo(img); for (int i = 4; i <= pts.size(); i = i + 4) { drawSpline(pts[i - 4], pts[i - 3], pts[i - 2], pts[i - 1]); } if (!remove1){ for (int i = 0; i < pts.size(); i++) drawPoint(pts[i]); } cv::imshow("test", img); char c = cv::waitKey(1); if (c == 27) break; else if (c == 'R' || c == 'r') //remove all the points { remove1 = 1; } else if (c == 'S' || c == 's') // save the iamge imwrite("new_test.jpg", img); } return 0; }

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
Viewing all 353 articles
Browse latest View live