Ask Your Question

Andrey Pavlenko's profile - activity

2020-10-20 12:12:07 -0600 received badge  Good Answer (source)
2016-06-18 07:15:14 -0600 commented answer OpenCL and GPU with Android OpenCV SDK
2016-06-02 00:46:53 -0600 received badge  Good Answer (source)
2016-04-10 03:52:47 -0600 received badge  Good Answer (source)
2015-07-08 04:22:03 -0600 received badge  Good Answer (source)
2015-05-09 21:49:25 -0600 received badge  Nice Answer (source)
2015-01-29 10:28:11 -0600 received badge  Nice Answer (source)
2014-10-01 04:51:38 -0600 received badge  Nice Answer (source)
2014-08-06 09:17:46 -0600 received badge  Nice Answer (source)
2014-07-16 10:29:56 -0600 received badge  Nice Answer (source)
2014-07-03 06:43:02 -0600 received badge  Nice Answer (source)
2014-05-05 08:01:12 -0600 commented question Android x86_64 support?

OpenCV for Android is built using Android NDK. Do you know anything about NDK version supporting compilation for Android x86_64?

2014-05-05 07:50:33 -0600 answered a question Opencv 2.4.9 Viz module not there.

The new viz module exists in OpenCV-2.4.9 sources but was not included into pre-built libraries since it depends on VTK that assumes redistribution of pre-built VTK with the package.

For those who needs the viz module we suggest building OpenCV-2.4.9 from sources with -DWITH_VTK=ON CMake option. (Use -DVTK_DIR=/your/vtk/build/path to help CMake finding VTK).

2014-04-15 09:46:14 -0600 edited question couldn't link successfully when i use ndk-build to complile my opencv code on android platform

hi, i use ndk-build to compile my opencv code for android.I have successful experience on the work.but,today i fail to success.this is my log under ndk-build:

 /cygdrive/e/EclipseSomkeDetect/obj/local/armeabi/libopencv_androidcamera.a(camera_activity.o):
In function 'CameraWrapperConnector::getPathLibFolder()': camera_activity.cpp:
(.text._ZN22CameraWrapperConnector16getPathLibFolderEv+0x38): 
undefined reference to 'dladdr' 
collect2: ld returned 1 exit status /cygdrive/d/android-ndk-r4-crystax/build/core/build-shared-library.mk:38: 
recipe for target '/cygdrive/e/EclipseSomkeDetect/obj/local/armeabi/libSmokeDetect.so' failed
make: *** [/cygdrive/e/EclipseSomkeDetect/obj/local/armeabi/libSmokeDetect.so] Error 1

could any expert tell me what is problem?several weeks ago,i compile opencv code successfully which include no cvcapture func .My current c++ code uses cvcapture func and could not link successfully.any message would be appreciated. someone tells you should add app_platform:=android-8 in application.mk,i try,but i fail.

2014-04-15 09:41:17 -0600 commented question couldn't link successfully when i use ndk-build to complile my opencv code on android platform

What I would suggest first: please use the latest NDK (r9d), the latest OpenCV4Android SDK (2.4.8 or even coming soon 2.4.9) and don't use Cygwin. Start from here: http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/android_dev_intro.html

2014-04-12 06:57:07 -0600 received badge  Good Answer (source)
2014-04-10 05:51:38 -0600 commented question Opencv with native android
2014-04-10 05:26:10 -0600 commented question Opencv with native android

still getting the same error as i mentioned in links , it runs in first time but when i click on DetectionBasedTracker_jni.cpp it showing me error on

  # include < string >
  # include < vectotr >
  # include < jni.h >
2014-04-03 13:37:16 -0600 commented question recompile OpenCV for Android on Windows

Are you going to use 'core' and 'imgproc' in JNI C++ code or in Java code?

2014-03-31 11:10:19 -0600 commented answer Windows 8 Metro apps

OpenCV has WinRT support, no plans for Win Phone 8 for today.

2014-03-31 11:06:56 -0600 answered a question How to pass a MatOfKeyPoint and MatOfPoint2f to native code? (OpenCV 4 Android)
//C++/JNI
//vector_Point2f

void Mat_to_vector_Point2f(Mat& mat, vector<Point2f>& v_point)
{
    v_point.clear();
    CHECK_MAT(mat.type()==CV_32FC2 && mat.cols==1);
    v_point = (vector<Point2f>) mat;
}

void vector_Point2f_to_Mat(vector<Point2f>& v_point, Mat& mat)
{
    mat = Mat(v_point, true);
}
2014-03-31 11:03:37 -0600 answered a question How to pass a MatOfKeyPoint and MatOfPoint2f to native code? (OpenCV 4 Android)
// C++ / JNI
// vector_KeyPoint converters

void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
{
    v_kp.clear();
    CHECK_MAT(mat.type()==CV_32FC(7) && mat.cols==1);
    for(int i=0; i<mat.rows; i++)
    {
        Vec<float, 7> v = mat.at< Vec<float, 7> >(i, 0);
        KeyPoint kp(v[0], v[1], v[2], v[3], v[4], (int)v[5], (int)v[6]);
        v_kp.push_back(kp);
    }
    return;
}


void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
{
    int count = (int)v_kp.size();
    mat.create(count, 1, CV_32FC(7));
    for(int i=0; i<count; i++)
    {
        KeyPoint kp = v_kp[i];
        mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, (float)kp.octave, (float)kp.class_id);
    }
}
2014-03-31 10:56:52 -0600 edited question SVD on Android SDK

Hi, I am doing some Structure-from-Motion approach and having some trouble getting R and T from the essential matrix.

So far I am doing the following steps:

  • Calibrate Camera
  • Take two images with the same camera
  • undistort images
  • find feature points
  • match features
  • calculate fundamental matrix F using Mat fundamental = Calib3d.findFundamentalMat(object_left, object_right);
  • Calculate essential matix E using the following block of code:

    Mat E = new Mat();
    Core.multiply(cameraMatrix.t(),fundamental, E);
    Core.multiply(E, cameraMatrix, E);
    

Using E I now need to calculate R and T, the relative rotation and translation between both cameras. I've read the chapter about SCV and E in Hartley and Zisserman, but now I am struggeling with OpenCV Code. A quick google-question brought me this code which is in C++:

Matx34d P;
//decompose E 
SVD svd(E,SVD::MODIFY_A);
Mat svd_u = svd.u;
Mat svd_vt = svd.vt;
Mat svd_w = svd.w;
Matx33d W(0,-1,0,1,0,0,0,0,1);//HZ 9.13
Mat_<double> R = svd_u * Mat(W) * svd_vt; //
Mat_<double> T = svd_u.col(2); //u3

if (!CheckCoherentRotation (R)) {
  std::cout<<"resulting rotation is not coherent\n";
  return 0;
}

The problem is now that I don't know how to transfer this code to Android/Java. There is no object SVD. I am doing the SVD for E using Mat svd = E.inv(Core.DECOMP_SVD); which returns a Mat Object.

Can someone help me please? I need access to U, W and VT from the singular value decomposition.

2014-03-31 10:47:18 -0600 edited question Android VideoCapture from video file always return null

I use example code as following to try open MP4 video file and put some text to video file but open result always return failed.

extern "C"
{
//.... something code............

const char* arrURL = "mnt/sdcard/Download/VID_20140317_104750.mp4";
string source(arrURL);

VideoCapture inputVideo;              // Open input
//inputVideo.open(source);

if (!inputVideo.open(source)) -> alway return false here...
{
    env->ReleaseStringUTFChars(URL, arrURL);
    env->ReleaseStringUTFChars(sInputText, arrInputText);
    return;
}
//....

i used eclipse CDT - juno, NDK-r9, OpenCV 2.4.8 do everyone can help me answer some questions? - VideoCapture can not be supported on android? - Do you know any other solution on android? (not FFMPEG lib)

Thanks

2014-03-31 04:18:55 -0600 commented answer cv::format does not format the way it should.
2014-03-31 03:49:16 -0600 edited question cv::format does not format the way it should.

I started to use cv::format() a while ago to format my data in a CSV like text stream, and noticed it worked oddely : no problem of importance when used on a N * P cv::Mat where P is greater or equal to 2. The only matter then would be the useless spaces before each row but the first, but we can trim them afterwards easily.

But when P is equal to 1 (the matrix is a column), cv::format() does not seem to add the end of line signals between lines and I end up with a single line full of characters with no separation in between.

Here is an exemple, where I fill up two matrices and display them before and after using cv::format() :

#include <iostream>
#include "opencv2/opencv.hpp"

using namespace std;

int main()
{
  int dimensions = 5;
  int sampleCount = 4;

  cv::Mat points(sampleCount,dimensions, CV_32F,cv::Scalar(10));
  cout<<points<<endl;
  cout<<cv::format(points,"csv")<<endl;

  cv::Mat points2(sampleCount,1, CV_32F,cv::Scalar(10));
  cout<<points2<<endl;
  cout<<cv::format(points2,"csv")<<endl;

  return 0;
}

The output given is :

[10, 10, 10, 10, 10;
  10, 10, 10, 10, 10;
  10, 10, 10, 10, 10;
  10, 10, 10, 10, 10]
10, 10, 10, 10, 10
  10, 10, 10, 10, 10
  10, 10, 10, 10, 10
  10, 10, 10, 10, 10

[10; 10; 10; 10]
10101010

The extra spaces in the first case seem to come from the << operator which gives a nicer display since it displays a bracket on first line.

As for the second and most important case, I don't know where it comes from but I think this should be fixed.

Note the "csv" format seems not to be the only one with this kind of output, I tried with "python" and got a similar [10101010] output.

2014-03-29 08:50:47 -0600 received badge  Good Answer (source)
2014-03-27 01:44:49 -0600 received badge  Good Answer (source)
2014-01-22 12:23:09 -0600 answered a question 'Intel License Agreement' intentional?

By 3.0 release we plan to keep a single license text as the 'opencv/LICENSE' (3-clause BSD) file and just reference it in every source file. The work is just started: https://github.com/Itseez/opencv/pull/2000

2013-12-28 17:11:23 -0600 received badge  Nice Answer (source)
2013-12-13 08:01:28 -0600 commented answer OpenCL and GPU with Android OpenCV SDK

Probably because OpenCV4Android dev team has other priorities now. But you or somebody else are welcome to contribute OpenCL support for Android.

2013-12-13 07:58:00 -0600 commented question cascade.xml in Android APK

I believe the best practice is to use Java code for assets extraction (like the OpenCV sample does). But if you really need it in JNI, try the approach mentioned at http://stackoverflow.com/questions/13317387/how-to-get-file-in-assets-from-android-ndk

2013-10-28 06:29:52 -0600 received badge  Nice Answer (source)
2013-10-14 15:20:16 -0600 answered a question Print Mat values out to screen and vice versa

Probably the following code will give you an idea:

//==== storing data ====
FileStorage fs(".xml", FileStorage::WRITE + FileStorage::MEMORY);
fs << "date" << date_string << "mymatrix" << mymatrix;
string buf = fs.releaseAndGetString();

//==== reading it back ====
FileStorage fs(buf, FileStorage::READ + FileStorage::MEMORY);
fs["date"] >> date_string;
fs["mymatrix"] >> mymatrix;
2013-10-08 10:57:31 -0600 commented answer Bug in GPU_SURF and OpenCV's OpenCL module?

I suggest you submit a bugs against CUDA and OCL SURF (reproducer is appreciated) if you'd like to see the problem fixed.

2013-09-27 06:44:34 -0600 commented question Printing from inside module/src/initialization.cpp file

Have you tried to print to STDERR?

fprintf(stderr, ...);

2013-09-16 02:37:22 -0600 answered a question ANDROID: How to posterize a Bitmap or a Mat in OpenCV? (Image included.)

I suggest you use cv::threshold(THRESH_BINARY).

2013-09-14 10:27:17 -0600 commented answer make Mat from buffer byte

@TimeManx No, it's not possible: Mat reallocates its buffer on native level when needed, so it's hard to share it between native and java without copying...

2013-09-11 09:41:07 -0600 commented question add openCV to eclipse

Maybe the following tutorial will look better for you?

http://www.anlak.com/opencv-java-with-eclipse/

2013-09-09 10:03:45 -0600 answered a question trouble with android sample

OpenCV camera support may not work on some devices due to Android OS vendor customization. In particular it happens on some TI-based hardware like the 'Panasonic SoftBank 102P' is. Also you can provide logcat for deeper analysis.

2013-08-12 14:29:56 -0600 answered a question OpenCV (Java): how to access coordinates returned by findNonZero()?

The returned Mat is of N*1 size (where N is a number of non-zero elements of input Mat) and each of its elements contains row & col of non-zero element of input Mat. Consider it as an array non-zero pixels indexes.

2013-08-04 18:43:21 -0600 received badge  Nice Answer (source)
2013-08-02 09:28:37 -0600 answered a question Augmented reality Android application to recognize known object in real time camera frame.

There are plans to add a simple AR Android sample to OpenCV, but now we don't have it. I suggest you look at the "Mastering OpenCV with Practical Computer Vision Projects" book and its samples on GitHub.

2013-08-01 08:47:10 -0600 received badge  Nice Answer (source)
2013-07-29 01:50:41 -0600 commented question Video capture on MacBook

Also try the OpenCV 2.4.6 (not .1).

2013-07-24 01:48:59 -0600 commented answer Convert pixels to Mat
Mat mat565(height, width, CV_8UC2, pixels);
Mat graymat;
cvtColor(mat565, graymat, COLOR_BGR5652GRAY);