Ask Your Question

verified.human's profile - activity

2020-10-07 08:10:47 -0600 received badge  Notable Question (source)
2018-02-28 10:50:34 -0600 received badge  Popular Question (source)
2017-07-13 06:15:56 -0600 received badge  Notable Question (source)
2016-03-12 00:20:51 -0600 received badge  Popular Question (source)
2016-01-12 08:44:30 -0600 received badge  Nice Question (source)
2015-04-30 10:28:52 -0600 asked a question UMat fast downloading GPU >> CPU

I am working on implementing some OpenCL GPU kernels using OpenCV. This is all working fine, but I am wondering what the fastest is to download the images back from the device to host (GPU >> CPU). I have a total of 10 channels that I want to copy back to CPU memory.

cv::UMat gpu_luvm_u8 =   cv::UMat(cpuInputImage.size(), CV_8UC4);
cv::UMat gpu_angle1_u8 = cv::UMat(cpuInputImage.size(), CV_8UC4);
cv::UMat gpu_angle2_u8 = cv::UMat(cpuInputImage.size(), CV_8UC4); // last 2 channels unused

Of course after processing them on the CPU I can download them to an CV_8UC4 using .copyTo(). However since I am using 10 channels and I would like to have them at std::vector<cv::mat> I am wondering what the fastest method would be? Also the GPU matrices gpu_angle1_u8 and gpu_angle2_u8 contain the same sort of data, but since 4 channels is the maximal depth in OpenCV (?) I am have split them over two matrices. Is this a correct assumption or is there a better way of getting all data into a single UMat ? Any feedback is more than welcome!

Btw, I am using OpenCV 3.0.0

2015-03-03 09:56:54 -0600 commented answer Visualizing learned features from Haar cascade classifier

Thanks Steven, your images look very good ! Is it me or is there no code on the CV Dazzle website? You are not sharing your code before releasing your book I suppose? Thanks anyway for your very nice response.

2015-03-03 09:52:26 -0600 received badge  Scholar (source)
2015-03-02 10:29:01 -0600 received badge  Editor (source)
2015-03-02 10:28:09 -0600 asked a question Visualizing learned features from Haar cascade classifier

Using the opencv_traincascade application I have trained a cascade classifier on Haar features for car detection. The detector is working pretty good, but I am wondering what kind of rectangle features were selected using AdaBoost. In other words, I want to visualize the features in the same way Viola and Jones are doing in their paper for face detection (see image below). However I find the cascade.xml file not so trivial to interpreted, so I was wondering whether there is a way to visualize the 'learned' rectangular features?

image description

2015-03-02 10:17:55 -0600 answered a question Are cascades the best way to detect different mouth shapes on photos?

Have a look at Active Appearance Models, they are very well suited for deformations that occur in lips, eyebrows and faces in general.

2015-02-26 06:27:51 -0600 asked a question Integral Channel Feature Detector for Cars (bad results)

I have been trying to get the Integral Channel Features detector from OpenCV 3.0 (contrib) working but unfortunately the results are not so good. The goal is to compare the ICF detector to standard HOG+SVM detectors and the one from Felzenswalb et al. The latter two detectors work fine in detecting cars when trained on my image sets containing lots of image patches from rears of cars.

The dataset that I am training on contains ~2.000 positive image patches containing rear views of cars, vans and trucks. The negative dataset contains 10.000 images samples from Pascal VOC and random patches from highway scenes (not containing cars). The images are available in sizes 32x32, 64x64, 80x80 and 128x128 pixels.

Then the detector is trained using the following settings (for 64x64px images)

ICFDetectorParams icfParams;
icfParams.feature_count =  10000;      // number of features to generate
icfParams.weak_count =     1000;        // number of weak classifiers in cascade
icfParams.bg_per_image =   1;          // number of windows to sample per bg image
icfParams.features_type =  "icf";      // feature type (icf or acf)
icfParams.alpha =          0.01;       // alpha value
icfParams.is_grayscale =   false;      // grayscale or color images
icfParams.use_fast_log =   false;      // use fast log function
icfParams.model_n_cols =   64;         // model size (pixels)
icfParams.model_n_rows =   64;         // model size (pixels)

After training the detector (which takes much longer than training a SVM on HOG descriptors), I evaluate my images using the following settings for example (I have tried many different parameters for both training and testing):

ICFParams icfParams;
icfParams.slidingWindowStep = 8;
icfParams.scaleFactor =       1.4;
icfParams.minObjectSize =     cv::Size(30, 30);
icfParams.maxObjectSize =     cv::Size(250, 250);

Detections are generally very bad, lots of false positives etc. Here is an example:

image description

Can anyone give me some advice on what parameters to change to get the detector working? Especially the feature_count, weak_count, alpha value and the model size I am not so sure about. Any help is appreciated !

2015-02-12 02:31:33 -0600 received badge  Enthusiast
2015-02-11 05:45:18 -0600 received badge  Teacher (source)
2015-02-11 05:45:18 -0600 received badge  Self-Learner (source)
2015-02-10 03:26:37 -0600 commented question LatentSVM crashes in OpenCV 3.0.0 (contrib)

Thanks you are right! I was using the model files as suggested here (opencv_extra repository): http://docs.opencv.org/modules/objdet...

But I guess that was changed in OpenCV 3.0.0 - Many thanks for your help!!

2015-02-09 14:29:25 -0600 asked a question HoG Descriptor: signed 0-360 orientation bins?

I am trying to use HOG descriptors together with SVM classifiers to build a car detection algorithm. Of course inspiration for this approach is the original paper by Dalal & Triggs in which they build such detector for pedestrian detection. However for pedestrian detection it is best to use 9 orientation bins 0-180 degrees, so the orientation is UNSIGNED. Unfortunately for building a good descriptor for cars I probably need SIGNED orientation bins, for example in total 18 bins in the range 0-360 degrees.

In my application I am using the standard OpenCV implementation for extracting HOG descriptors. Currently only 9 histogram orientation bins are supported (see: http://docs.opencv.org/modules/gpu/do...). Is there any way to work around this limitation and easily compute SIGNED HOG descriptors?

Quote from Dalal & Triggs paper:

For humans, the wide range of clothing and background colours presum- ably makes the signs of contrasts uninformative. However note that including sign information does help substantially in some other object recognition tasks, e.g. cars, motorbikes

2015-02-09 14:13:02 -0600 commented question LatentSVM crashes in OpenCV 3.0.0 (contrib)

Berak, thanks for your reply! When giving it a 24 bit BGR image the error changes, but now I get a EXC_BAD_EXCESS error. I am not sure whether this is an OpenCV issue or has something to do with OS X or Xcode...?

This screenshot shows the error message, there is nothing to debug...It just crashes :-( Any clue? https://dl.dropboxusercontent.com/u/8...

2015-02-09 09:51:23 -0600 asked a question LatentSVM crashes in OpenCV 3.0.0 (contrib)

I am trying to detect objects using the LatentSVM detector that is currently in the contrib repository for OpenCV. My OpenCV installation is 3.0.0 on OS X Mavericks. After loading the model successfully from the opencv_extra repository the detector crashes upon finding objects in an image. In this example I have loaded the car.xml model but this does not seem to be the problem.

void LSVM_Detector::detect(cv::Mat& image)
{
    if (detector->isEmpty()) {
        cout << "Model is not loaded...EXIT" << endl;
        return;
    }

    // Line below outputs '1'
    //cout << "Number of classes = " << detector->getClassCount() << endl;

    // Actual detection of objects in the image
    cout << "Detecting objects..." << flush;
    vector<LSVMDetector::ObjectDetection> detections;

    // Line below crashes...
    detector->detect(image, detections);
    cout << "DONE" << endl;
    cout << "Found " << detections.size() << " objects." << endl;

    cv::namedWindow("LSVM Detections", cv::WINDOW_AUTOSIZE);

    for (auto&d  : detections) {
        cv::Rect r  = d.rect;
        float score = d.score;

        cout << "Detection score = " << score << endl;
        cv::rectangle(image, r, cv::Scalar(0, 255, 0));
    }

    cv::imshow("LSVM Detections", image);
}

I have tried to read out images in color and grayscale, however both result in the same error:

init done 
opengl support available 
Loading LSVM model file...DONE
Detecting objects...OpenCV Error: Assertion failed (src.size == dst.size && src.channels() == dst.channels()) in cvConvertScale, file /Users/username/Development/libraries/opencv-3.0.0-beta/modules/core/src/convert.cpp, line 4008
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/username/Development/libraries/opencv-3.0.0-beta/modules/core/src/convert.cpp:4008: error: (-215) src.size == dst.size && src.channels() == dst.channels() in function cvConvertScale

I have tried various images, but unfortunately without any luck. Does anyone have an idea what goes wrong here? Any help would be appreciated, I am kind of stuck and the documentation of OpenCV (3.0.0) and the LatentSVM class lacks a little bit here to be honest. Thanks in advance!

2015-01-29 09:39:43 -0600 commented question OpenCV 3.0 (contrib) Integral Channel Features

Well, I think the documentation is very limited at this point. Some examples:

  1. ICFDetector::detect() --> what is the threshold parameter? (probably threshold of weak learner)
  2. Setting the scaleFactor to 1.0 causes an infinite loop (or very long at least) for ICFDetector::detect()

I will report back if I have some results out of the classifier.

2015-01-22 14:24:59 -0600 received badge  Nice Question (source)
2015-01-22 06:56:58 -0600 commented question OpenCV 3.0 (contrib) Integral Channel Features

Thanks, you are right. The default parameters are incorrect. Settings all of them manually works indeed.

2015-01-22 04:44:42 -0600 received badge  Student (source)
2015-01-22 04:27:57 -0600 asked a question OpenCV 3.0 (contrib) Integral Channel Features

I was happy to see that there is an implementation of the Integral Channel Features + WaldBoost algorithm implemented in OpenCV 3.0. This code is currently in the opencv_contrib repository. Unfortunately I have problems to get it working. When I am trying to train the classifier using the following code it looks like something is happening because I see "1/3 - 2/3 ..." as progress indicator in the console. However the function crashes with the following error message:

OpenCV Error: Assertion failed (count > 0) in generateFeatures, file /Users/Development/libraries/opencv_contrib/modules/xobjdetect/src/acffeature.cpp, line 237 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/Development/libraries/opencv_contrib/modules/xobjdetect/src/acffeature.cpp:237: error: (-215) count > 0 in function generateFeatures

This assertion is made in this file: https://github.com/Itseez/opencv_cont...

I was wondering whether this ICF implementation is usable or very unstable pre-alpha code? Maybe someone can shine some like upon this or hint me into the direction of why the training does not work.

void ChannelFeaturesDetector::trainDetector(string objectDirectory, string backgroundDirectory) {

vector<cv::String> objectFilenames;
objectFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/car_rear_100x80/Car_000000.png"));
objectFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/car_rear_100x80/Car_000005.png"));
objectFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/car_rear_100x80/Car_000010.png"));

vector<cv::String> backgroundFilenames;
backgroundFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/negatives_100x80/000000.png"));
backgroundFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/negatives_100x80/000001.png"));
backgroundFilenames.push_back(cv::String("/Users/Development/data/KITTI_benchmark/negatives_100x80/000002.png"));

// Parameters for ICF training
ICFDetectorParams params;
params.model_n_rows = 56;
params.model_n_cols = 56;
params.is_grayscale = false;

ICFDetector detector;
detector.train(objectFilenames, backgroundFilenames, params); }