Ask Your Question

kiranpradeep's profile - activity

2015-04-03 03:43:48 -0600 commented question wrong sample source in opencv official dft document

Thanks @boaz001. But the first step mentioned in Reporting bugssection of http://code.opencv.org/projects/openc... link was to ask in answers.opencv.org to verify if that is really a bug. I did that with a complete minimal running sample code ( posted above ) and it appears a bug. I was expecting some reply like if this an intentional / expected behaviour or if it is really a bug. Should I go ahead and a file a bug or wait for a reply here ?

2015-04-03 02:39:20 -0600 commented question wrong sample source in opencv official dft document

@FooBar If I see a bug in opencv source, I try fixing it myself ( submitted pull requests in github ) or if I cannot, I submit a bug report. I don't have that options for wrong opencv documentation. The idea here is 1) to know if this really an incorrect sample, and if yes, 2) could I do any thing to fix it ? If you are incapable to confirm either of that, thanks for reading.

2015-04-02 23:52:13 -0600 asked a question wrong sample source in opencv official dft document

I tried the sample for convolution of 2D arrays with DFT in official opencv documentation(1). But the results of the sample are not matching cv::matchTemplate with cross correlation. The kernel is symmetrical and so convolution and correlation results shouldn't differ. Why are wrong samples provided in official opencv documentation itself ?

The convolveDFT method below is copied from the linked offical opencv document.

#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv;

void convolveDFT(cv::Mat A, cv::Mat B, cv::Mat& C);

int main()
{
    Mat img = Mat::ones(3, 3, CV_32FC1);
    Mat kernel = Mat::ones(3, 3, CV_32FC1);
    std::cout << img << '\n';

    cv::Mat out1(1,1, CV_32FC1);
    cv::matchTemplate( img, kernel, out1, TM_CCORR);
    std::cout << out1 << '\n';

    cv::Mat out2(1,1, CV_32FC1);
    convolveDFT( img, kernel, out2 );
    //this result is not matching with value in out1 Mat
    std::cout << out2 << '\n';

    return 0;
}

// code copied from opencv offical document for dft convolution
void convolveDFT(cv::Mat A, cv::Mat B, cv::Mat& C)
{
    // reallocate the output array if needed
    C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
    Size dftSize;
    // calculate the size of DFT transform
    dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
    dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);

    // allocate temporary buffers and initialize them with 0's
    Mat tempA(dftSize, A.type(), Scalar::all(0));
    Mat tempB(dftSize, B.type(), Scalar::all(0));

    // copy A and B to the top-left corners of tempA and tempB, respectively
    Mat roiA(tempA, cv::Rect(0,0,A.cols,A.rows));
    A.copyTo(roiA);
    Mat roiB(tempB, cv::Rect(0,0,B.cols,B.rows));
    B.copyTo(roiB);

    // now transform the padded A & B in-place;
    // use "nonzeroRows" hint for faster processing
    dft(tempA, tempA, 0, A.rows);
    dft(tempB, tempB, 0, B.rows);

    // multiply the spectrums;
    // the function handles packed spectrum representations well
    mulSpectrums(tempA, tempB, tempA, 0);

    // transform the product back from the frequency domain.
    // Even though all the result rows will be non-zero,
    // you need only the first C.rows of them, and thus you
    // pass nonzeroRows == C.rows
    dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);

    // now copy the result back to C.
    tempA(cv::Rect(0, 0, C.cols, C.rows)).copyTo(C);
}
2015-03-31 14:58:11 -0600 received badge  Student (source)
2014-10-20 01:17:10 -0600 received badge  Critic (source)
2014-10-20 01:14:20 -0600 received badge  Editor (source)
2014-10-20 01:13:43 -0600 asked a question using opencl as private framework for building opencv

I am currently using GPUImage on iOS and would like to replace it with UMat in OpenCV 3.0. This is an example, for using OpenCL as private framework in iOS. Is it possible to custom build OpenCV 3.0 with OpenCL as private framework ( ignoring AppStore ) so that, in iOS, function calls with UMat results in offloading to GPU ? If yes, will the changes be limited to build_framework.py and CMakefiles only ?

2014-01-16 16:17:09 -0600 received badge  Nice Answer (source)
2014-01-16 02:00:24 -0600 received badge  Teacher (source)
2014-01-16 01:07:04 -0600 received badge  Necromancer (source)
2014-01-15 23:27:52 -0600 answered a question POSIT in C++ API?

From another answer in same forum, it appears cvPosit is not part of OpenCV anymore. You can use solvePnp).

2014-01-15 23:13:48 -0600 received badge  Supporter (source)