Ask Your Question

alykhantejani's profile - activity

2020-02-25 13:12:06 -0500 received badge  Popular Question (source)
2019-06-05 02:14:48 -0500 received badge  Notable Question (source)
2017-06-18 14:03:06 -0500 received badge  Popular Question (source)
2013-12-16 06:45:37 -0500 asked a question Speed of cv::linemod with SSE3


I have recently installed Intel IPP and re-build opencv with SSE and IPP. I am trying to run cv::linemod, which is claimed to run at ~120ms for matching 3000 templates.

I have checked that it is making the SSE calls, but still cv::linemod runs at ~4s for ~700 templates. Do you know if the opencv version is able to attain the speed shown in the publication by Hinterstoisser et al. ?

2013-08-06 18:08:50 -0500 received badge  Student (source)
2013-07-24 06:22:02 -0500 asked a question opencv cv::linemod throwing runtime errors

I am using opencv-2.4.6 and trying to run a simple program to use the cv::linemod functionality.

Here is my code:

    #include <opencv2/core/core.hpp>
    #include <opencv2/imgproc/imgproc_c.h> 
    #include <opencv2/imgproc/imgproc.hpp>
    #include <opencv2/objdetect/objdetect.hpp>
    #include <opencv2/highgui/highgui.hpp>

int main(int argc, char **argv) {

    cv::Ptr<cv::linemod::Detector> detector;
    detector = cv::linemod::getDefaultLINEMOD();

    Mat depth = imread("input/duck/duck_650_depth2.png", CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);
    Mat color = imread("input/duck/duck_650_rgb2.png", CV_LOAD_IMAGE_ANYCOLOR);

    Mat object_mask = Mat(depth.rows, depth.cols, CV_32S);

    for (int x = 0; x < depth.cols; x++) {
        for (int y = 0; y < depth.rows; y++) {
            if (<int16_t>(y, x) > 0) {
      <int>(y, x) = 1;
            } else {
      <int>(y, x) = 0;

    vector<Mat> sources;
    std::string class_id = cv::format("class%d", 1);
    Mat display = color.clone();
    Rect bb;

    int template_id = detector->addTemplate(sources, class_id, object_mask, &bb);
    if (template_id != -1) {
        cout << " added template " << endl;
    return 0;

Which compiles fine, however at runtime I get this error:

OpenCV Error: The function/feature is not implemented (Unsupported data type (=4)) in getMorphologyRowFilter, file /home/aly/libs/opencv-, line 894
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/aly/libs/opencv- error: (-213) Unsupported data type (=4) in function getMorphologyRowFilter

I don't really understand what it means? I am using the latest opencv version

2013-03-11 10:19:57 -0500 asked a question How to use cv::meanShift (C++)


I have a vector of 2-D points, I am trying to use the meanshift algorithm to detect multiple modes in the data but am a bit confused by the method signature.

1) Can I pass in my vector (if so in what form) or must I conver to cv::Mat (if so how? if I have points with negative values).

2) How do I extract the multiple modes, from what I can see the function only returns an int


2012-12-12 06:46:34 -0500 commented question How to visualize a depth image

Can you provide a code sample? Or link to tutorial, I am fairly new to the library

2012-12-12 06:27:43 -0500 asked a question How to visualize a depth image


I am using a dataset in which it has images where each pixel is a 16 bit unsigned int storing the depth value of that pixel in mm. I am trying to visualize this as a greyscale depth image by doing the following:

cv::Mat depthImage; 
depthImage = cv::imread("coffee_mug_1_1_1_depthcrop.png", CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR ); // Read the file 
depthImage.convertTo(depthImage, CV_32F); // convert the image data to float type   
float max = 0;
for(int i = 0; i < depthImage.rows; i++){
    for(int j = 0; j < depthImage.cols; j++){
        if(<float>(i,j) > max){
            max =<float>(i,j);
cout << max << endl;

float divisor = max / 255.0;
cout << divisor << endl;
for(int i = 0; i < depthImage.rows; i++){
    for(int j = 0; j < depthImage.cols; j++){
        cout <<<float>(i,j) << ", ";
        max =<float>(i,j) /= divisor;
        cout <<<float>(i,j) << endl;

imshow("window", depthImage);

However, it is only showing two colours this is because all of the values are close together i.e. in the range of 150-175 + the small values which show up black (see below).

RGB image greyscale image

Is there a way to normalize this data such that it will show various grey levels to highlight these small depth differences?

2012-12-12 06:22:33 -0500 asked a question Cant open capture object for Kinect

I have installed OpenNI and SensorKinect following the tutorial here: and the example viewer works just fine. I have downloaded OpenCV 2.4.3 and then done the following:

  1. mkdir release
  2. cd release
  3. cmake-gui ..
  4. hit configure
  5. set WITH_OPENNI to ticked
  6. checked that it has found OPENNI dirs and primesense dir
  7. hit configure and then generate
  8. ran make

I then try and run the sample code from OpenCV-2.4.3/samples/openni_capture.cpp

However I get the following output:

Device opening ...
Can not open a capture object.

The relevant code is:

VideoCapture capture(CV_CAP_OPENNI);
if( isVideoReading ) filename );

cout << "done." << endl;

if( !capture.isOpened() )
    cout << "Can not open a capture object." << endl;
    return -1;