ylqfp / pyopencv

Automatically exported from code.google.com/p/pyopencv
0 stars 0 forks source link

HOGDescriptor argument #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use HOGDescriptor in pyopencv to computeGradient
2. python throws the exception:"HOGDescriptor.computeGradient(hog, img, 
gradmat, angmat)
Boost.Python.ArgumentError: Python argument types in
    HOGDescriptor.computeGradient(HOGDescriptor, Mat, function, function)
did not match C++ signature:
    computeGradient(HOGDescriptor_wrapper {lvalue}, cv::Mat img, cv::Mat {lvalue} grad, cv::Mat {lvalue} angleOfs, cv::Size_<int> paddingTL=Size2i(width=0, height=0), cv::Size_<int> paddingBR=Size2i(width=0, height=0))
    computeGradient(cv::HOGDescriptor {lvalue}, cv::Mat img, cv::Mat {lvalue} grad, cv::Mat {lvalue} angleOfs, cv::Size_<int> paddingTL=Size2i(width=0, height=0), cv::Size_<int> paddingBR=Size2i(width=0, height=0))
"
3. I think the problem will be use Mat in argument...so how to use Mat in 
python as argument in response with cv:Mat reference in c++?

What is the expected output? What do you see instead?
get the gradient of the input image

What version of the product are you using? On what operating system?
python 2.6.5
opencv 2.0
win 7 32 bit

Please provide any additional information below.

Original issue reported on code.google.com by liangji...@gmail.com on 2 Sep 2010 at 8:31

GoogleCodeExporter commented 9 years ago
How about:

gradmat = cv.Mat()
gradmat = cv.Mat(cv.Size(320, 200), cv.CV_8UC3, cv.Scalar(20, 30, 40))

Pls take a look at the demo package. There are a few examples there.

Cheers,
Minh-Tri

Original comment by pmtri80@gmail.com on 2 Sep 2010 at 8:55

GoogleCodeExporter commented 9 years ago
I use gradmat = cv.Mat(), then the argument part is correct now, but when i try 
to write gradmat as an image, i get this error,

OpenCV Error: Assertion failed (image.channels() == 1 || image.channels() == 3 
|| image.channels() == 4) in imwrite_, file 
M:\programming\packages\opencv\workspace\2.1\OpenCV-2.1.0\src\highgui\loadsave.c
pp, line 272
Traceback (most recent call last):
  File "D:\Research\Experiments\Hog\src\hogtest.py", line 27, in <module>
    pcv.imwrite("gradimg.jpg", gradmat)
RuntimeError: 
M:\programming\packages\opencv\workspace\2.1\OpenCV-2.1.0\src\highgui\loadsave.c
pp:272: error: (-215) image.channels() == 1 || image.channels() == 3 || 
image.channels() == 4 in function imwrite_

why the Mat's channels is 2 and how to solve this error? thank you in advance.

Regards,
Kei

Original comment by liangji...@gmail.com on 2 Sep 2010 at 10:51

GoogleCodeExporter commented 9 years ago
Hi Kei,

To be frank, I don't really know how that computeGradient() function works. I 
doubt it produces a gradient image, in which each pixel is a 2D vector that 
represents a gradient vector. Perhaps that's why the number of channels is 2.

Cheers,
Minh-Tri

Original comment by pmtri80@gmail.com on 2 Sep 2010 at 11:07

GoogleCodeExporter commented 9 years ago
I assume you've fixed the issue. I'd like to close the issue. Feel free to open 
a new one if you have other issues.

Cheers,
Minh-Tri

Original comment by pmtri80@gmail.com on 5 Sep 2010 at 11:59

GoogleCodeExporter commented 9 years ago
okay..

Original comment by liangji...@gmail.com on 5 Sep 2010 at 1:16