你可以看看official OpenCV documentation,它宣稱detectMultiScale功能(CPU實現)的這個重載:
virtual void cv::HOGDescriptor::detectMultiScale ( InputArray img,
std::vector<Rect> & foundLocations,
std::vector<double> & foundWeights,
double hitThreshold = 0,
Size winStride = Size(),
Size padding = Size(),
double scale = 1.05,
double finalThreshold = 2.0,
bool useMeanshiftGrouping = false
) const
和for GPU
virtual void cv::cuda::HOG::detectMultiScale ( InputArray img,
std::vector<Rect> & found_locations,
std::vector<double> * confidences = NULL
)
所以,你可以簡單地把它(CPU模式):
std::vector< cv::Rect> found_locations_rect;
std::vector<double> found_weights;
d_hog->detectMultiScale(mat, found_locations_rect, found_weights);
或(GPU實現):
std::vector< cv::Rect> found_locations_rect;
std::vector<double> confidences;
d_hog->detectMultiScale(rGpuImg, found_locations_rect, &confidences);
如果它不會工作,OpenCV的會拋出異常。你可以像這樣顯示的:
try
{
std::vector< cv::Rect> found_locations_rect;
std::vector<double> confidences;
d_hog->detectMultiScale(rGpuImg, found_locations_rect, &confidences);
}
catch(const std::exception& e)
{
std::cout << e.what() << std::endl;
}
之後,你就可以解決問題
謝謝,但我得到以下異常拋出: –
異常在HOG_GPU.exe在0x00007FFA8C537788拋出:微軟C++異常:CV: :內存位置0x0000005431F0E690處出現異常。 HOG_GPU.exe中的0x00007FFA8C537788處未處理的異常:Microsoft C++異常:內存位置0x0000005431F0E690處的cv :: Exception異常。 –
@ErikS,如果您有例外 - 向我們顯示其文本 – Evgeniy