Ask Your Question

rafafirenze's profile - activity

2017-10-25 04:19:30 -0600 received badge  Popular Question (source)
2015-03-22 10:12:46 -0600 asked a question Error building Static Library with OpenCV and Xcode on C++

I'm trying to build a DLL library for Unity3D (in 32-bit) but first of all I want to make a .a static library to make a C++ Wrapper for C#.

Well, this is what I've done.

  • I've built OpenCV unchecking BUILD_SHARED_LIBS in order to get the STATIC LIBS, with architecture i386.
  • I've made my static library code and built it, Linking the static libraries that I needed (I really import them all because I'm having errors and I want to know if it's an error lib-based), (included from /lib/ and /3rdparty/lib/).
  • I'm linking my library and header in a new project (Command Line Tool) in order to test my new static library, but my errors are:

Undefined symbols for architecture i386: "_gzclose", referenced from: icvClose(CvFileStorage, std::__1::basic_string<char, std::__1::char_traits<char="">, std::__1::allocator<char> >) in libeyeslibrary.a(persistence.cpp.o) _cvOpenFileStorage in libeyeslibrary.a(persistence.cpp.o) "_gzeof", referenced from: icvYMLSkipSpaces(CvFileStorage, char, int, int) in libeyeslibrary.a(persistence.cpp.o) icvXMLSkipSpaces(CvFileStorage, char, int) in libeyeslibrary.a(persistence.cpp.o) "_gzgets", referenced from: icvGets(CvFileStorage, char, int) in libeyeslibrary.a(persistence.cpp.o) "_gzopen", referenced from: _cvOpenFileStorage in libeyeslibrary.a(persistence.cpp.o) "_gzputs", referenced from: icvPuts(CvFileStorage, char const) in libeyeslibrary.a(persistence.cpp.o) "_gzrewind", referenced from: _cvOpenFileStorage in libeyeslibrary.a(persistence.cpp.o) ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Well, I have no idea what's wrong. Does anyone have idea about this?

Thank you very much in advance.

Regards.

2015-03-13 11:43:27 -0600 asked a question How to apply K means in a mask of an image instead the whole one

Hello.

I want to apply a K Means to a region of an image not squared or a rectangle. For example the source image is:

image description

now I select a custom mask:

image description

and apply K Means with k = 3:

image description

Obviously without considering the bounds (white).

Instead, what I can do with OpenCV is K Means but considering the bounds:

image description

And that messes out my final image because black is considered one colour.

Do you have any clue? Thank you in advance.

2015-03-11 07:00:31 -0600 asked a question ffmpeg fails to build on MacPorts

Hello,

I've seen a many problems about this, but I didn't get a solution.

My OS is Yosemite and current OpenCV is 2.4.9

I'm trying to install OpenCV with TBB, but when I do it by sudo port install opencv +debug +python27 +qt4 +tbb (through this SO question):

Rafaels-iMac:y3PQFyQhUG rafaelruizmunoz$ sudo port install opencv +debug +python27 +qt4 +tbb

Warning: The Xcode Command Line Tools don't appear to be installed; most ports will likely fail to build.

Warning: Install them by running 'xcode-select --install'.

Warning: The Xcode Command Line Tools don't appear to be installed; most ports will likely fail to build.

Warning: Install them by running xcode-select --install'.

---> Computing dependencies for ffmpeg

---> Configuring ffmpeg Error: Failed to configure ffmpeg, consult /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_multimedia_ffmpeg/ffmpeg/work/ffmpeg-2.6/config.log

Error: org.macports.configure for port ffmpeg returned: configure failure: command execution failed Please see the log file for port ffmpeg for details:

/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_multimedia_ffmpeg/ffmpeg/main.log

Error: Unable to upgrade port: 1

Error: Unable to execute port: upgrade ffmpeg failed

And there are not any logs on those paths.

I've tried (support from SO and MacPorts).

  • port selfupdate
  • port upgrade ffmpeg
  • port clean x264
  • port upgrade outdated
  • port -f selfupdate

but nothing happened.

Does anyone have a clue?

Thank you in advance.

EDIT: Doing xcode-select --install doesn't resolve anything.

2015-03-10 10:20:23 -0600 commented answer segmentation fault on traincascade

Sorry, doesn't change very much:

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   43 : 43
NEG count : acceptanceRatio    300 : 1
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.833333|
+----+---------+---------+
|   3|        1| 0.726667|
+----+---------+---------+
|   4|        1|     0.78|
+----+---------+---------+
Segmentation fault: 11
2015-03-10 10:04:47 -0600 commented answer segmentation fault on traincascade

I've tried to make a -numNeg lower as well

2015-03-10 09:58:14 -0600 commented answer segmentation fault on traincascade

Hello @fedor, thank you for your answer. I reduced the number to 315 and I did the -numPos / numStages, setting -numStages to 10. So the new command would be :

opencv_traincascade -data data -vec "/Users/rafaelruizmunoz/Desktop/metal/lv.vec" -bg bg.txt -numPos 31 -numNeg 3019 -numStages 10 -w 35 -h 35

But I got Segmentation fault again.

2015-03-10 09:18:03 -0600 commented question segmentation fault on traincascade

Hi @thdrksdfthmn , in my experience I've just used cascades downloaded from Internet... would you reccomend me a ratio of pos/neg ??

2015-03-10 09:07:44 -0600 asked a question segmentation fault on traincascade

Hello.

I'm getting this weird error. I have 437 positive images and 3019 negative images.

The positive images all taken of 35x35 pixels.

This is the command that I use:

opencv_traincascade -data data -vec lv.vec -bg bg.txt -numPos 437 -numNeg 3019 -numStages 10 -w 35 -h 35

if I use -featureType LBP, it hangs on the 0-stage not calculating anything. If I remove it, this is what happens:

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   437 : 437
NEG count : acceptanceRatio    3019 : 1
Precalculation time: 3
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.988738|
+----+---------+---------+
|   4|        1| 0.998344|
+----+---------+---------+
|   5|        1| 0.998675|
+----+---------+---------+
Segmentation fault: 11

When I try to retry the process, I get:

PARAMETERS:
cascadeDirName: data
vecFileName: /Users/rafaelruizmunoz/Desktop/metal/lv.vec
bgFileName: bg.txt
numPos: 437
numNeg: 3019
numStages: 10
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 35
sampleHeight: 35
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

Stage 0 is loaded

===== TRAINING 1-stage =====
<BEGIN
POS OpenCV Error: Bad argument (Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
) in get, file /Users/rafaelruizmunoz/Downloads/opencv/apps/traincascade/imagestorage.cpp, line 163
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/rafaelruizmunoz/Downloads/opencv/apps/traincascade/imagestorage.cpp:163: error: (-5) Can not get new positive sample. The most possible reason is insufficient count of samples in given vec-file.
 in function get

Abort trap: 6

Does anyone know what is happening?

Thank you in advance.

2015-02-15 06:24:48 -0600 asked a question Infinite loop on brew install opencv on Mac

Hello,

I'm trying to install opencv on my Mac by brew tap homebrew/science && brew install opencv but I got an infinite loop installing it.

When I try to exit the terminal, I get:

(Translated from spanish): You are about to close the terminal and will force to quit the next processes:

bash, genautomata, ruby(4), clang(23), make(3), sh(14)

and never finishes... do you have any clue??

Thank you in advance

2015-02-15 05:12:41 -0600 commented question Draw projection from a 3d item

I think I would have to use Unity3D for it

2015-02-14 07:31:11 -0600 asked a question Draw projection from a 3d item

Hello.

I'm completely lost in this argument.

I know that if I want to draw a 3d item in OpenCV, I have to do a projection, but how do I load an item in 3d? For example, for 2d, a .png would be great. For 3d... what should I load in order to make the projection ???

Thank you, and sorry for being so basic. Cheers.

2015-02-02 07:35:00 -0600 commented question What's wrong with scaling?

hahahaha :) I need it for a game

2015-02-02 07:23:31 -0600 commented question What's wrong with scaling?

The whole image.

2015-02-02 07:12:38 -0600 commented question What's wrong with scaling?

Hi @StevenPuttemans, thanks for your reply.

  1. I have tried with no interpolation as well. The same result happened.
  2. I can't publish the image because it's copyrighted. I made another example: link text
2015-02-02 05:24:29 -0600 asked a question What's wrong with scaling?

Hello.

I'm trying to scale an image into 4x4 pixels by this code:

    Mat image4x4;

    vector<int> compression_params;
    compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
    compression_params.push_back(9);

    resize(imageFromFile, image4x4, Size(4,4), INTER_CUBIC);
    imwrite("/Users/macuser/Desktop/4x4/"+names.at(i), image4x4, compression_params);

The result is this:

image description

but if I do it with GIMP (in 'cubic' as well), the result is:

image description

I don't know what factor I'm not considering when scaling... do you have any clue?

Thank you very much. Regards.

2015-01-27 12:05:35 -0600 asked a question Unable to make OpenCV with TBB

Hello,

I'm following this tutorial to make able to work with more than 1 thread for opencv_traincascade

I tried with the 3.0 BETA and 2.4.10 STABLE but I got the same error.

The log is here: http://pastebin.com/FeZZ0A1K

but the last lines are:

[ 22%] Building CXX object

3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfConvert.cpp.o

Linking CXX static library

../lib/libIlmImf.a [ 22%] Built target

IlmImf [ 22%] Generating

opencv_core_pch_dephelp.cxx Scanning

dependencies of target

opencv_core_pch_dephelp [ 22%]

Building CXX object

modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o

c++: error: “: No such file or

directory c++: fatal error: no input

files compilation terminated. /bin/sh:

1: -fopenmp”: not found make[2]: *

[modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o]

Error 127 make[1]: *

[modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/all]

Error 2 make: * [all] Error 2

do you have any clue? on CMake I have to enable OPENMP like the tutorial says.

Thanks in advance. Regards

2015-01-27 12:02:31 -0600 received badge  Enthusiast
2015-01-16 10:02:58 -0600 commented answer Problem on initialize FeatureDetector or DescriptorExtractor on OpenCV 3.0

You are the best! thank you !

2015-01-16 10:02:49 -0600 received badge  Scholar (source)
2015-01-16 10:02:43 -0600 received badge  Supporter (source)
2015-01-16 09:41:45 -0600 asked a question Problem on initialize FeatureDetector or DescriptorExtractor on OpenCV 3.0

Hello mates.

I'm trying to change my old OrbFeatureDetector for a Ptr<FeatureDetector> and giving the parameter ORB, but when I try to detect something as:

Ptr<FeatureDetector> detector = FeatureDetector::create<FeatureDetector>("ORB");
detector->detect(img_object, keypoints_object);
  1. My detector is null
  2. I get an EXC_BAD_ACCESS with address=0x0

Do you have any idea why it could happen?

Thank you in advance.

2015-01-16 09:21:10 -0600 asked a question Trying to port 2.4.9 to 3.0

Hello.

I followed this tutorial to port OpenCV 2.4.9 to 3.0 for Mac.

I had to do it without VIZ because I was getting errors, but I think it's not my problem now.

I've changed all my header paths where they really are (the new installed) and changed the .dylib to .3.0.0.dylib.

The problem is that the header didn't really change. If I click on them, they port me to /usr/local/Cellar/opencv/2.4.9 ..... /objdetect/objdetect.hpp (for example) instead /usr/local/objdetect/objdetect.hpp which is my real header path (for 3.0.0).

What am I doing wrong? Thank you in advance

2015-01-16 07:42:51 -0600 commented question Error while building viz module on Mac (Mavericks) opencv 3.0 beta

but I think you missunderstood me. I said to say what you said as Answer to mark you as correct on answers.opencv.org :)

2015-01-16 06:45:25 -0600 commented question Error while building viz module on Mac (Mavericks) opencv 3.0 beta

cmake -D BUILD_opencv_viz=OFF

2015-01-16 06:41:05 -0600 commented question Error while building viz module on Mac (Mavericks) opencv 3.0 beta

and I compiled with libc++ (I changed it in flags)... I don't know what the problem could be

2015-01-16 06:40:03 -0600 commented question Error while building viz module on Mac (Mavericks) opencv 3.0 beta

could you say it as answer ? it worked! I had no idea about that :\ Thank you!

2015-01-16 06:22:58 -0600 asked a question Error while building viz module on Mac (Mavericks) opencv 3.0 beta

I need new features on OpenCV 3.0 beta. The explanation to install it is already here: http://hugofeng.info/2014/04/17/Compi...

When I do make, the following error is up:

I'm trying to sort this error but I can't... http://pastebin.com/DPRdvjvU (I can't paste all the RAW data here).

I've seen similar errors solved because of CUDA or sorting flags, but I didn't get it to work.

do you have any clue? thank you in advance.

Regards.

[ 44%] Building CXX object modules/viz/CMakeFiles/opencv_viz.dir/src/shapes.cpp.o
In file included from /Users/rafaelruizmunoz/Downloads/opencv/modules/viz/src/clouds.cpp:46:
In file included from /Users/rafaelruizmunoz/Downloads/opencv/modules/viz/src/precomp.hpp:144:
In file included from /Users/rafaelruizmunoz/Downloads/opencv/modules/viz/src/vtk/vtkCloudMatSink.h:48:
In file included from /Users/rafaelruizmunoz/Downloads/opencv/modules/core/include/opencv2/core.hpp:57:
/usr/local/include/opencv2/core/mat.hpp:58:13: error: incomplete type 'cv::Mat'
      named in nested name specifier
inline void Mat::initEmpty()
            ^~~~~
/Users/rafaelruizmunoz/Downloads/opencv/modules/core/include/opencv2/core/base.hpp:679:18: note:
      forward declaration of 'cv::Mat'
class CV_EXPORTS Mat;
                 ^

(a lot more of those)

2015-01-12 03:41:02 -0600 received badge  Critic (source)
2014-12-08 10:09:56 -0600 asked a question Converting Bitmap to Mat and passing it through JNI

Hello.

I've seen the same problem here but I didn't find a good solution for me.

I'm trying to pass one Bitmap to JNI as:

            String name = String.valueOf((int)i+1) + ".jpg";
            Bitmap image = AssetBitmapFile(name, this);
            image = Bitmap.createScaledBitmap(image, 500, 500, false);

            Mat imageMat = new Mat(500, 500, CvType.CV_8U);

            System.out.println("width: " + image.getWidth() + " height: " + image.getHeight());

            Utils.bitmapToMat(image, imageMat);
            Imgproc.cvtColor(imageMat, imageMat, Imgproc.COLOR_RGBA2GRAY);
            imageMat.convertTo(imageMat, CvType.CV_8U);

            System.out.println("infoMat: " + imageMat);
            openCV.setTrainedImages(name, imageMat);

and the console shows:

12-08 16:03:35.742 12466-12466/com.example.try I/System.out﹕ width: 500 height: 500

12-08 16:03:35.742 12466-12466/com.example.try I/System.out﹕ infoMat: Mat [ 500 * 500 * CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x725c8300, dataAddr=0x725cc010 ]

and on my JNI bridge I do:

     Mat* imageMat = (Mat*)image;
    __android_log_print(ANDROID_LOG_INFO, "TAG", to_text(imageMat->rows).c_str());

and the result is :

12-08 16:03:35.742 12466-12466/com.example.try I/TAG﹕ 1933574177

but it's really 500.

What am I doing bad? I'm using the same code than other projects that I've done and the other worked fine. This is not working fine... it's weird!

thank you very much.

2014-11-11 09:48:19 -0600 received badge  Editor (source)
2014-11-10 06:13:48 -0600 asked a question Problems using Stitcher::stich

Hello.

I'm trying to use Stitcher::Status as this example:

vector<Mat> imgs;
// I add images...
Mat pano;
Stitcher stitcher = Stitcher::createDefault(false);
Stitcher::Status status = stitcher.stitch(imgs, pano);
cout << endl << status << endl;

The printed result is "0". But I get a 1x1 black pixel image.

Sometimes, if I remove one image from the vector<Mat> I get a result, but if I add more it doesn't work.

I'm taking pictures as panorama, but with createPanorama I get an Assertion error:

imgs.size() == imgs_.size()

What am I doing bad? Thank you.

Update:

I'm trying to add rois taking the 50% of every image. For the first image I take the right 50%. For the last, the left 50%, and for the rest I take 50% of left and 50% of right:

vector<Mat> imgs;
imgs.push_back(imread("/Users/myImages/IMG_0073.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0074.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0075.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0076.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0077.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0078.jpg"));

processImage(imgs);

and my function is:

void processImage(vector imgs){

vector<vector<Rect>> rois;
vector<Rect> roisVect;
for (int j = 0; j < imgs.size(); j++) {
    if (j == 0) {
        Rect rect1 = Rect(imgs.at(j).cols*50/100, 0, imgs.at(j).cols*50/100,imgs.at(j).rows);
        roisVect.push_back(rect1);
        rois.push_back(roisVect);

        roisVect.clear();
    } else if (j == imgs.size() - 1) {
        Rect rect2 = Rect(0, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        roisVect.push_back(rect2);
        rois.push_back(roisVect);

        roisVect.clear();
    } else {
        Rect rect3 = Rect(imgs.at(j).cols*50/100, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        Rect rect4 = Rect(0, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        roisVect.push_back(rect4);
        roisVect.push_back(rect3);
        rois.push_back(roisVect);

        roisVect.clear();
    }

}
Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = stitcher.stitch(imgs, rois, pano);
cout << endl << status;
cout << endl << pano.size();
if (!pano.empty())
    imshow("pano", pano);
waitKey(10);

imwrite("/Users/myImages/final" + to_string(imgs.size()) + ".jpg", pano);
}

And my results (cout) are:

0 // (OK)

[1 x 1]