This is error:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.1.2-dev) /home/ztftrue/Downloads/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<vscn, vdcn,="" vdepth,="" sizepolicy="">::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<1>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
Invalid number of channels in input image:
'VScn::contains(scn)'
where
'scn' is 1
Code :
cv::Ptr<cv::featuredetector>
> cv::Ptr<cv::FeatureDetector>
detector =
ORB::create(); cv::Ptr<cv::descriptorextractor>
ORB::create();
> cv::Ptr<cv::DescriptorExtractor> extractor =
ORB::create(); cv::Ptr<cv::descriptormatcher>
ORB::create();
> cv::Ptr<cv::DescriptorMatcher> matcher =
cv::DescriptorMatcher::create("BruteForce"); cv::DescriptorMatcher::create("BruteForce");
> cv::BOWImgDescriptorExtractor bowide(extractor,
matcher); bowide.setVocabulary(vocabulary);
matcher);
> bowide.setVocabulary(vocabulary);
> bowide.compute(inputImage, keypoints,
descriptors); descriptors);
The vocabulary.type()==5
I try change inputImage channels 1(GARY) and 3(BGR) , but this error can't disappearance.
I have a very bad question. In addition to svm, can pytorch still use the key points of opencv? I learn by this https://www.learnopencv.com/mask-r-cnn-instance-segmentation-with-pytorch/, I don't know how to use the key points of opencv.
--------------update---------
cvtColor()
Code :
cv::Ptr<cv::featuredetector>
> cv::Ptr<cv::FeatureDetector>
detector =
ORB::create(); cv::Ptr<cv::descriptorextractor>
ORB::create();
> cv::Ptr<cv::DescriptorExtractor> extractor =
ORB::create(); cv::Ptr<cv::descriptormatcher>
ORB::create();
> cv::Ptr<cv::DescriptorMatcher> matcher =
cv::DescriptorMatcher::create("BruteForce"); cv::DescriptorMatcher::create("BruteForce");
> cv::BOWImgDescriptorExtractor bowide(extractor,
matcher); bowide.setVocabulary(vocabulary);
matcher);
> bowide.setVocabulary(vocabulary);
> cv::Mat
descriptors; descriptors;
> Mat
inputImage(it); inputImage(it);
> // cvtColor(it, it1,
COLOR_BGR2GRAY); COLOR_BGR2GRAY);
> cvtColor(it, inputImage,
COLOR_GRAY2BGR); COLOR_GRAY2BGR);
> cout << inputImage.channels() <<
endl; endl;
> cout << inputImage.type() <<
endl; endl;
> bowide.compute(inputImage, keypoints,
descriptors); descriptors);
Error:
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.1.2-dev)
/home/ztftrue/Downloads/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<vscn, vdcn,="" vdepth,="" sizepolicy="">::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<1>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
Invalid number of channels in input image:
'VScn::contains(scn)'
where
'scn' is 3