CvMat convertTo operation

402 views
Skip to first unread message

Hans-Christian Sperker

unread,
Jul 25, 2012, 8:51:33 AM7/25/12
to jav...@googlegroups.com
Hey there,

in openCV it is possible to change the type of a cv::Mat via
Mat::convertTo(...) now I am looking to this possibility in javaCV.
But on CvMat there isn't an operation convertTo. How can I convert the
type then?

Thanks!

Samuel Audet

unread,
Jul 28, 2012, 12:27:43 AM7/28/12
to jav...@googlegroups.com

Hans-Christian Sperker

unread,
Jul 30, 2012, 1:20:12 PM7/30/12
to jav...@googlegroups.com
Hmm I would like to use the convertTo(...) like in http://find-object.googlecode.com/svn-history/r55/trunk/find_object/example/main.cpp 
where it is used to convert some CvMat to CV_32F. See code:

if(sceneDescriptors.type()!=CV_32F) {
    sceneDescriptors.convertTo(sceneData, CV_32F); // make sure it's CV_32F
}

How would I do this with cvConvertScale?

2012/7/28 Samuel Audet <samuel...@gmail.com>:

Samuel Audet

unread,
Jul 31, 2012, 9:48:56 AM7/31/12
to jav...@googlegroups.com
On 2012-07-31 02:20, Hans-Christian Sperker wrote:
> Hmm I would like to use the convertTo(...) like in
> http://find-object.googlecode.com/svn-history/r55/trunk/find_object/example/main.cpp
>
> where it is used to convert some CvMat to CV_32F. See code:
>
> if(sceneDescriptors.type()!=CV_32F) {
> sceneDescriptors.convertTo(sceneData, CV_32F); // make sure it's CV_32F
> }
>
> How would I do this with cvConvertScale?

In almost the same way:
sceneData = CvMat.create(..., CV_32F, ...);
cvConvert(sceneDescriptors, sceneData);

Hans-Christian Sperker

unread,
Aug 3, 2012, 9:57:21 AM8/3/12
to jav...@googlegroups.com
Thank you Samuel, seems to work ;-)

2012/7/31 Samuel Audet <samuel...@gmail.com>
Reply all
Reply to author
Forward
0 new messages