Ask Your Question

mddrill's profile - activity

2019-05-22 13:09:06 -0500 received badge  Popular Question (source)
2018-12-19 16:49:33 -0500 received badge  Notable Question (source)
2018-12-19 16:49:33 -0500 received badge  Popular Question (source)
2017-04-24 14:59:09 -0500 commented question How to use cvRandInit() and cvRandState in opencv 2.4

@StevenPuttemans I want to run it once first to see if it's worth updating to C++, @LBerger, what method is fill gaussian or uniform? I cant find it in the documentation. Thanks

2017-04-24 01:22:07 -0500 asked a question How to use cvRandInit() and cvRandState in opencv 2.4

Hi, I found some old code that uses OpenCV's C API. I'm trying to run it but the function cvRandInit() and the variable type CvRandState are not being recognized. Right now I'm only including opencv2/opencv.hpp. Is there another header file that I can use to access these older keywords? If not, are there newer functions that can be used to replace them?

Thank You!

2017-04-15 21:00:54 -0500 asked a question What file do I include to use the FaceRecognizer class in the iOS framework?

Hi, I'm trying to implement the Face Recognizer class using the instructions I found here

I noticed it includes a file called opencv2/face.hpp which seems to contain the cv::face namespace and the BasicFaceRecognizer class.

The problem is that I cant seem to find the face.hppfile in the opencv iOS framework which I downloaded from http://opencv.org/releases.html (I'm using OpenCV 3.2)

What file do I need to include in my project to use the face recognition API?

Thank You

2017-03-19 15:36:18 -0500 asked a question How do I fix an undefined reference error while build opencv from source?

I'm building opencv 3.2 from source on Ubuntu 16.04 using these instructions: http://docs.opencv.org/trunk/d7/d9f/t...

After running make -j7 when I get to 98% I get this error:

[ 98%] Built target opencv_cudaoptflow
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

If I scroll up in the console I see that there were problems earlier

[ 96%] Linking CXX executable ../../bin/opencv_test_cudalegacy
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut_32s8u'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcutInitAlloc'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcutFree'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut8_32s8u'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcutGetSize'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut8GetSize'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut8InitAlloc'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut_32f8u'
../../lib/libopencv_cudalegacy.so.3.2.0: undefined reference to `nppiGraphcut8_32f8u'
collect2: error: ld returned 1 exit status
modules/cudalegacy/CMakeFiles/opencv_test_cudalegacy.dir/build.make:501: recipe for target 'bin/opencv_test_cudalegacy' failed
make[2]: *** [bin/opencv_test_cudalegacy] Error 1
CMakeFiles/Makefile2:8465: recipe for target 'modules/cudalegacy/CMakeFiles/opencv_test_cudalegacy.dir/all' failed
make[1]: *** [modules/cudalegacy/CMakeFiles/opencv_test_cudalegacy.dir/all] Error 2

It looks like it's not recognizing any of the nppiGraphcut functions in cudalegacy. Does anyone know how to fix this?

My cmake options were cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_LIBPROTOBUF_FROM_SOURCES=ON .. I've tried with an without the -DBUILD_LIBPROTOBUF_FROM_SOURCES=ON.

I know it's recognizing that I have CUDA installed because I get this output in the beginning

-- CUDA detected: 7.5
-- CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-D_FORCE_INLINES

I don't know what else to try, I cant find anything on this error when googling it. Let me know if I need to post more information.

Thank you for your help!

2017-02-20 16:13:27 -0500 received badge  Enthusiast
2017-02-19 17:56:58 -0500 commented question Unknown type 'CvVideoCamera'

@Tetragramm I think that's been replaced by #include <opencv2/imgcodecs/ios.h>, it says "cap_ios.h" not found

2017-02-19 13:23:10 -0500 asked a question Unknown type 'CvVideoCamera'

I am trying to use OpenCV to process video feed in an Swift iOS app.

I read that the best way to do this is with the CvVideoCamera class in an objective-c wrapper.

When I try to declare a CvVideoCamera object or pointer I get the error Unkown type 'CvVideoCamera'

Here is my code

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    CvVideoCamera videoCamera;
    cv::Mat src;
}
@end

Here is my prefix header

#ifndef PrefixHeader_pch
#define PrefixHeader_pch

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __cplusplus
#include <opencv2/opencv.hpp>
#include <opencv2/imgcodecs/ios.h>
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

#endif /* PrefixHeader_pch */

I know that opencv is being included in the project because when I remove the line where I declare a CvVideoCamera The code builds with no errors, even though I declare a Mat object.

I tried using the cv scope in front of CvVideoCamera, When I do that I get and error No type named CvVideoCapture in namespace cv

I have also tried putting the CvVideoCamera declaration in the implementation instead or the interface, changing the .m files to .mm, and declaring a pointer instead of an object;I still get the same errors.

When I look in the 0pencv2/imgcodecs/ios.h file, this is what I find

#import <UIKit/UIKit.h>
#import <Accelerate/Accelerate.h>
#import <AVFoundation/AVFoundation.h>
#import <ImageIO/ImageIO.h>
#include "opencv2/core/core.hpp"

//! @addtogroup imgcodecs_ios
//! @{

UIImage* MatToUIImage(const cv::Mat& image);
void UIImageToMat(const UIImage* image,
                         cv::Mat& m, bool alphaExist = false);

//! @}

There is nothing in there about CvVideoCamera, which leads me to believe I may be using the wrong include file, but everything I look up says that that is the right one to include

Any help would be appreciated, Thank You

2017-02-06 11:08:31 -0500 commented answer Should I include opencv2/opencv.hpp?

I don't care about compilation time, but I do care about how fast the program runs. So I can just leave `#include "opencv2/opencv.hpp", right?

2017-02-06 10:31:49 -0500 asked a question Should I include opencv2/opencv.hpp?

Most of the OpenCV tutorials I've watching have only one include statement #include opencv2/opencv.hpp

But I'm not sure if this is the best way to do things or just the easy way, it seems like this include statement just includes everything whether I need it or not. Would it speed up my program if I only added the header files that I needed? If so, how can I find out what header files the functions in my program are in? The OpenCV documentation doesn't seem to give that information.

Thank You

2017-02-06 10:21:16 -0500 received badge  Scholar (source)
2017-02-06 10:21:15 -0500 received badge  Supporter (source)
2017-02-06 09:30:53 -0500 received badge  Editor (source)
2017-02-06 09:30:37 -0500 asked a question opencv_world320d.lib vs opencv_world320.lib?

What's the difference between these two files? I would guess that the d stands for debug, does that mean opencv_world320.lib is faster and is the one that should be used in production?

Thank You

2017-02-05 12:39:58 -0500 asked a question How do I set up Visual Studio to run the OpenCV T-API?

I am trying to run OpenCV with GPU support. I have read about the T-API and it seems fairly easy to use.

What I don't understand is whether I need to download my GPU's OpenCL SDK and start an OpenCL project in Visual Studio or if I can literally just take the project I have now and change the Mats to UMats.

Also, since everything in the T-API seems to be done in the background, is there a way that I can know for sure whether my code is running with GPU support or not?

If it matters, I am running Windows 10, Visual Studio 2015, and using OpenCV 3.2

Thank You

2017-02-01 17:44:48 -0500 received badge  Student (source)
2017-02-01 14:17:12 -0500 asked a question Last convexity defect not working

I am trying to write code to track hands. I am using the convexity defects function to find fingers, but for some reason, there seems to always be a problem with the last defect.

Here is a picture of what I'm talking about: pasteboard.co/tcOYWEp69.png (sorry, i''m new to the forum, so cannot post images, but there is no way for me to ask this question without posting one. It's also impossible for me to build karma, because the questions on here are way too advanced for me to answer, so please bear with me, thank you)

The cyan line is the contours, the yellow line is the hull points, and the red lines are the defect points. As you can see the last defect point detects the defect from the wrong side of the contour.

Here is my code:

#include "opencv2\opencv.hpp"

using namespace cv;
using namespace std;

int main() {
    VideoCapture cap(0);
    Mat src, gray, background, binary, diff;
    cap >> background;
    cvtColor(background, background, CV_BGR2GRAY);
    vector<vector<Point>> contours;
    vector < vector<int>> hullI = vector<vector<int>>(1);
    vector < vector<Point>> hullP = vector<vector<Point>>(1);
    vector<Vec4i> defects;
    while (waitKey(30)!='q') {
        cap >> src;
        cvtColor(src, gray, CV_BGR2GRAY);
        blur(gray, gray, Size(3, 3));
        absdiff(gray, background, diff);
        threshold(diff, binary, 15, 255, THRESH_BINARY);
        erode(binary, binary, Mat(Size(5, 5), CV_8U));

        imshow("binary", binary);

        findContours(binary, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
        if (!contours.empty()) {
            sort(contours.begin(), contours.end(), [](vector<Point> a, vector<Point> b) { return a.size() > b.size(); });
            drawContours(src, contours, 0, Scalar(255, 255, 0));

            convexHull(contours[0], hullI[0]);
            convexHull(contours[0], hullP[0]);
            drawContours(src, hullP, 0, Scalar(0, 255, 255));

            if (hullI[0].size() > 2) {
                convexityDefects(contours[0], hullI[0], defects);

                for (Vec4i defect : defects) {
                    line(src, contours[0][defect[0]], contours[0][defect[2]], Scalar(0, 0, 255));
                    line(src, contours[0][defect[1]], contours[0][defect[2]], Scalar(0, 0, 255));
                }
            }
        }
        imshow("src", src);
        char key = waitKey(30);
        if (key == 'q')break;
        else if (key == 'p') waitKey();
        else if (key == 'b') {
            cap >> background;
            cvtColor(background, background, CV_BGR2GRAY);
        }
    }
}

I have confirmed through experiments that it is always the last defect in the defect vector that this happens too. Is this a bug in opencv or am I doing something wrong?