Ask Your Question

Simone's profile - activity

2014-10-21 09:03:14 -0500 received badge  Guru (source)
2014-10-21 09:03:14 -0500 received badge  Great Answer (source)
2013-07-09 01:38:01 -0500 received badge  Nice Question (source)
2013-06-20 08:40:35 -0500 received badge  Nice Answer (source)
2013-04-30 17:49:13 -0500 commented answer Location of the headers moved?

Hi, I made a pull today after long time and after compiling and installing i did notice this change and it is really annoying cause my project is pretty big and with a lot of include to correct. By any chances do you guys know if it is gonna be a "stable" change and if they gonna fix the include directory when installing, so we can have the "compatibility" headers (opencv2\<moduleName>\someHeader.hpp) in the include dir? Otherwise i agree that the workaround @berak proposed is smart and it can save some work (for now...)

2013-04-14 13:03:30 -0500 received badge  Enlightened (source)
2013-04-14 13:03:30 -0500 received badge  Good Answer (source)
2013-04-12 15:09:31 -0500 received badge  Student (source)
2013-01-17 07:38:20 -0500 asked a question Filter the rows/columns of a Mat

Hello,

I want to filter out the rows of a Mat according to a mask, a task that may be quite frequent in computer vision. I was wondering what's the most efficient way to do it. Suppose you have a matrix Mat A of size NxP and a mask vector<uchar> M of N elements, whose values are 0 or 255 whether the corresponding row of A is to delete or not, respectively. In Matlab would be easy to do something like

A = A(find(M),:)

to get the desired filtered matrix. In OpenCV the simplest way, i guess, to do something like that is to build another matrix copying row by row, so something like this:

Mat result = Mat( countNonZero(M), A.cols, A.type );
for(int i=0, k=0; i<M.size(); ++i )
{
    if( M[i] )
    {
        A.row( i ).copyTo( result.row( k++ ) );
    }
 }

This works just fine, but I was wondering if there is a more efficient method (computationally and/or from memory use point of view), such as for example casting somehow (i'm just fumbling here..) A to a vector of some sort and use the built-in delete of vector.

Also, another variant of the same problem is when you have as mask a vector<uchar> M of size K with K<=N storing the index of the rows of A to be keep in the new version of the matrix. Again a simple way to do it is:

Mat result = Mat( M.size(), A.cols, A.type );
for(int i=0; i<M.size(); ++i )
{
    CvAssert( M[i] < A.rows );
    A.row( M[i] ).copyTo( result.row( i ) );
}

Any comments? :-)

Thanks!

S.

2012-12-10 20:46:44 -0500 received badge  Necromancer (source)
2012-11-27 09:30:51 -0500 answered a question Extrinsics matrix after cv::StereoCalibrate

If you are using StereoCalibrate with Kinect1 as Camera1 and Kinect2 as Camera2 then the transformation between the two cameras is [R|t], meaning that if you have 3D points Q in the reference system of the first camera, then Q'=[R|r]*Q are the same points expressed in the reference system of the second camera.

2012-11-25 04:02:35 -0500 commented question Image matching problem

I don't know the time constraint of your application, but for example you can switch (temporaly) to the BruteForce method and impose the crossCheck flag, so that you always have two features that match in a reciprocal way. This may be helpful to see if there are some problem in your code. Also if u can share part of the code where u do the matching it would be helpful to see if everything is done correctly. Here is the doc for the BruteForce approach http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html#bfmatcher-bfmatcher

2012-11-23 05:34:20 -0500 commented answer OpenCV4Android and parallel code

thanks! I don't want to abuse your kindness but i'd have another question: what about renderscript? It seems google is preferring it to Opencl for android gpu computing. Is there any work done/planned in that direction?

2012-11-22 01:29:10 -0500 commented answer OpenCV4Android and parallel code

Thank you very much. Is there a plan to allow support for OpenCL in the future?

2012-11-22 01:24:45 -0500 received badge  Scholar (source)
2012-11-21 17:11:47 -0500 commented answer How to create a binary image mat?

I don't know what else could be. What other values did u get? Can u somehow compare them with the original ones in the grayscaleMat?

2012-11-21 15:44:58 -0500 answered a question How to create a binary image mat?

Try to use

THRESH_BINARY

instead of CV_THRESH_BINARY.

S.

2012-11-21 14:46:43 -0500 answered a question lkdemo don't work .

It could be either:

  1. the video file you are using (when you pass the parameter) is either not found (check the path) or you don't have the proper codec installed to read the video
  2. if u are using the webcam input, there may be some problem with your device.
2012-11-21 12:22:48 -0500 asked a question OpenCV4Android and parallel code

Hi,

I have 2 questions concerning OpenCV4Android:

  1. I'm using the latest prebuilt version of OpenCV4Android on an armeabi-v7 with NEON device. I was wondering if the opencv functions are running with the TBB support by default. I see in the package that under the 3rdparty there is the libtbb.so, so i guess that the library comes already with the tbb support. Anyone can confirm that?
  2. Still concerning the parallelization, I was wondering if OpenCL is supported in Android and therefore if i can call any of the ocl:: functions of the OpenCL module of opencv. I know that the support of opencl depends on the manifacturer of the GPU, so let's say it is so in my case, are those functions available to be used, say, in a JNI application in android?

Thank you!

Simone

2012-11-14 01:02:24 -0500 received badge  Nice Answer (source)
2012-11-13 05:07:49 -0500 answered a question Is it possible to extract a 3D Cad model from pictures like 123D?

Hi,

the answer by @Ben is a good direction to search. I suggest you also take a look to this kind of systems (and the relevant pubblications cited in the website

  • this talk will introduce you to the topic and to the various (actually, a lot) possible approaches.
  • PMVS2 this is a 3D reconstruction tool from multiple images, it provides a sparse/dense reconstruction on the scene.
  • VisualSFM it's basically very similar to the above but a lot improved with gpu.

They both give you as output points. I guess you prefer to have some sort of geometric surfaces fitted to that data, which may be the starting point for you. Also it depends a lot on the prior knowledge you have about the shapes you want to recover: if you know that the objects are man-made with simple geometric shapes like then you can set and impose some constraints during the 3D reconstruction so that you get as output geometric primitives (box planes and so on) describing your object. For example this may be a first point to start.

Hope it helps

S.

2012-11-13 04:44:23 -0500 received badge  Citizen Patrol (source)
2012-11-13 04:44:17 -0500 received badge  Critic (source)
2012-11-12 08:38:30 -0500 answered a question MatOfDMatch how can it be used?

Hi,

you can convert the MatOfDMatch to a Java list and then go through it with the List iterator as you do in a any Java program:

List<DMatch> myList = temp.toList();

Iterator itr = myList.iterator(); 
while(itr.hasNext()) 
{
      DMatch element = itr.next(); 
      // your code here
}

You can check the documentation of DMatch here, basically every DMatch element corresponds to a match between the two images: when comparing only two images (trained is just a simple list of descriptors) then you only need the queryIdx and trainIdx fields which indicate the index of the feature in the query image (in your case keypoints) and in the train image, respectively. In case your trained descriptors are a list of list of descriptors (so you are comparing your image to a set of images) then the imgIdx will tell you the index of the image that has the match.

Hope it helps

S.

2012-11-12 08:22:05 -0500 commented question Initializing static cv::Mat with cv::Mat::zeros causes segmentation fault

I tried to reproduce it but I have gcc 4.5.2 and i don't have any issue with that code. I don't know if it is just a version number problem. Anyway, have you tried to initialize the matrix like

static cv::Mat staticMatTwo = cv::Mat::zeros(3,3,CV_32FC1);

S.

2012-11-12 01:24:47 -0500 received badge  Nice Answer (source)
2012-11-12 00:23:57 -0500 received badge  Teacher (source)
2012-11-11 12:14:09 -0500 commented answer Problem installing the right Manager.apk and Binary_pack.apk for OpenCV4Android

If you are using eclipse then you can go to Window > AVD Manager and then you see the list of emulators you have created. Select the one you want to use and click Edit. On the third box of the windows that pops up you can see the CPU of the Emulator. check this http://developer.android.com/tools/devices/managing-avds.html

Otherwise you have for sure installed the Android SDK (http://developer.android.com/sdk/installing/index.html), go to that directory from the windows prompt, go to tools directory and run the above command

2012-11-11 10:50:30 -0500 answered a question Problem installing the right Manager.apk and Binary_pack.apk for OpenCV4Android

Hi,

from the windows shell or a linux terminal you can run this command with your device attached to your PC

adb shell getprop ro.product.cpu.abi

this will return the type of cpu your device has, and then you can load the correct version of the manager and of the library

S.

2012-11-11 10:15:38 -0500 answered a question To save vector "KeyPoint" to file using builtin write function

Hi,

it's actually simple. In order to save your keypoints

 vector<Keypoint> mykpts;
 FileStorage fs("keypoints.yml", FileStorage::WRITE);
 write( fs , "aNameYouLike", mykpts );
 fs.release();

This will store your keypoints in a file named keypoints.yml and the node containing the data is named "aNameYouLike". This will be used to read back the keypoints from the file:

  vector<Keypoint> mykpts2;
  FileStorage fs2("keypoints.yml", FileStorage::READ);
  FileNode kptFileNode = fs2["aNameYouLike"];
  read( kptFileNode, mykpts2 );
  fs2.release();

You may want to check the XML/YAML file storage documentation for more information.

Hope it helps

S.

2012-11-08 11:30:48 -0500 answered a question cv::Mat divide by last row.

Hi,

I don't know if it is particularly efficient but you can do the following using repeat

Mat src ...;  // your 3XN matrix
Mat lastRow = src.row( 2 );
Mat tmp;
repeat(lastRow, tmp, 3, 1 );  // create a tmp matrix of 3xN whose elements are repeated elements of the last row of src
src = src / tmp;

This is like doing

src = src./repmat(src(3,:), 3, 1)

in matlab. Otherwise another way to do it is to pass element by element and do the division

for(int i =0; i<src.cols; ++i )
{
     // you should first check that the last element is !=0 !!!
     src.at<float>(0, i) /= src.at<float>(2, i);
     src.at<float>(1, i) /= src.at<float>(2, i);
}

and replace <float> with the correct type of your matrix.

Hope it helps.

S.

2012-11-07 04:36:12 -0500 commented question Problem loading the jni lib with OCV Manager

Ok my bad... I was actually using the trunk version of OCV to build while on the devices i still had the OCV 2.4.3 binary version. As soon as i made everything coherent with the binary version it worked.

2012-11-06 10:20:12 -0500 asked a question Problem loading the jni lib with OCV Manager

Hello,

I had a simple app for LK tracking that was basically built following and slightly the "Tutorial 2 - mix Java+Native" of a older version of OCV (2.3.x i think). So now I'm trying to update the application in order to use it with the 2.4.3.

I succesfully managed to slightly change the code so i can use the 2.4.3 in a static way. Now I'd like to go further and update it to use the OCV Manager. Here come the problems. :(

Let me first recall that the architecture of the app is exactly the same as the old sample i mentioned before, so we have 3 files, with the main TrackingActivity, the TrackerBase Class with the threaded structure and the Tracker derived class that implements the method to be called whenever a frame is available.

I removed all the code for static loading and added the new way of interacting with the manager to the main activity

public class TrackingActivity extends Activity 
{
 ...
private BaseLoaderCallback  mLoaderCallback = new BaseLoaderCallback(this) {  
    @Override
    public void onManagerConnected(int status) 
    {
        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");

                // Load native library after(!) OpenCV initialization
                System.loadLibrary("LKTracker");

            } break;
            default:
            {
                Log.e(TAG, "problem loading OCV?");
                super.onManagerConnected(status);
            } break;
        }
    }
};
...
...
@Override
protected void onResume()
{
    // TODO Auto-generated method stub
    super.onResume();
    if( !OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback) )
    {
        Log.e(TAG, "Cannot connect to OpenCV Manager");
    }
}

So far so good. I also changed all the .mk files to resemble those of the official documentation and of the new samples of OCV 2.4.3. When i tried to execute the application (both on real devices and on the AVD) the OpenCV Manager is connected succefully and then when it comes to

System.loadLibrary("LKTracker");

I get this exception

11-06 14:46:31.224: I/Tracking::Activity(1461): OpenCV loaded successfully
11-06 14:46:31.224: D/dalvikvm(1461): Trying to load lib /data/data/com.example.lktracker/lib/libLKTracker.so 0x412a4d98
11-06 14:46:31.224: D/AndroidRuntime(1461): Shutting down VM
11-06 14:46:31.224: W/dalvikvm(1461): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
11-06 14:46:31.244: E/AndroidRuntime(1461): FATAL EXCEPTION: main
11-06 14:46:31.244: E/AndroidRuntime(1461): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]:    36 cannot locate '_ZN2cv12_OutputArrayD1Ev'...
11-06 14:46:31.244: E/AndroidRuntime(1461):     at java.lang.Runtime.loadLibrary(Runtime.java:370)
11-06 14:46:31.244: E/AndroidRuntime(1461):     at java.lang.System.loadLibrary(System.java:535)
11-06 14:46:31.244: E/AndroidRuntime(1461):     at fr.lab.gipsa.lktracker.TrackingActivity$1.onManagerConnected(TrackingActivity.java:62)
11-06 14:46:31.244: E/AndroidRuntime(1461):     at org.opencv.android.AsyncServiceHelper$1.onServiceConnected(AsyncServiceHelper.java:314)
11-06 14:46:31.244: E/AndroidRuntime(1461):     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1068)
11-06 14:46:31.244: E/AndroidRuntime(1461):     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1085)
11-06 ...
(more)
2012-11-02 18:37:28 -0500 commented answer Building Android Manager from git repository

PS My apps are just for research purpose, there won't be anything commercial or public (at least for the moment), so I don't think it's necessary to change the name to avoid any sort of conflicts with the "official" libraries.

2012-11-02 18:36:06 -0500 commented answer Building Android Manager from git repository

Hi Kiril and thank you very much for your answer. Ok i get that i don't need to build the Manager, i can use the one from the binary build. And I have been perfectly fine so far working with static initialization of the library. On the other hand, since I'm working with several applications, all using the my own build of OpenCV, I was wondering if i can switch to the Manager way of handling the library with my own build, provided that the Manager can handle that. Therefore, just for the sake of the argument, what should I do to generate my apk? Shall i do a make install when building or what?

Thanks!

S.

2012-11-02 10:43:45 -0500 received badge  Editor (source)
2012-11-02 10:43:45 -0500 edited question Building Android Manager from git repository

Hello, I'm upgrading to the new version of OCV4Android and I see that now the library are managed in a different way with the OpenCv Library Manager and I understand the benefits of it. My device cannot connect to the Internet neither have google play so i guess i should proceed as described here

adb install OpenCV_2.4.2_Manager.apk
adb install OpenCV_2.4.2_binary_pack_armv7a.apk

My question is: say that I want to compile my own version of OpenCV4Android (eg using always the latest version from the repository or change something in the code), how can I generate the above Manager.apk and binarypack.apk? I successfully followed the instruction from here to compile the code but I cannot find those apk. Yet I can see the source code of the manager in the service folder. Is there any documentation about it somewhere?

Thank you!

Simone