मैं केवल ब्लॉक के लिए HOG सुविधाओं की गणना करने की कोशिश कर रहा हूं। मैंने को opencv/module/gpu/src/
के अंतर्गत सूचीबद्ध किया। नीचे वह कोड है जिसे मैं कंप्यूटर में केवल ब्लॉक की विशेषताओं में बदलता हूं।होग सुविधाओं केवल ब्लॉक के लिए
void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride, GpuMat& descriptors, int descr_format)
{
CV_Assert(win_stride.width % block_stride.width == 0 && win_stride.height % block_stride.height == 0);
computeBlockHistograms(img);
// give block back
/*
const size_t block_hist_size = getBlockHistogramSize();
Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride);
descriptors.create(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32F); */
switch (descr_format)
{
case DESCR_FORMAT_ROW_BY_ROW:
hog::extract_descrs_by_rows(win_size.height, win_size.width, block_stride.height, block_stride.width,
win_stride.height, win_stride.width, img.rows, img.cols, block_hists.ptr<float>(), descriptors);
break;
case DESCR_FORMAT_COL_BY_COL:
hog::extract_descrs_by_cols(win_size.height, win_size.width, block_stride.height, block_stride.width,
win_stride.height, win_stride.width, img.rows, img.cols, block_hists.ptr<float>(), descriptors);
break;
default:
CV_Error(CV_StsBadArg, "Unknown descriptor format");
}
}
यहां computeBlockHistograms
कोड भी है।
void cv::gpu::HOGDescriptor::computeBlockHistograms(const GpuMat& img)
{
computeGradient(img, grad, qangle);
size_t block_hist_size = getBlockHistogramSize();
Size blocks_per_img = numPartsWithin(img.size(), block_size, block_stride);
// block_hists.create(1, block_hist_size * blocks_per_img.area(), CV_32F);
block_hists = getBuffer(1, static_cast<int>(block_hist_size * blocks_per_img.area()), CV_32F, block_hists_buf);
hog::compute_hists(nbins, block_stride.width, block_stride.height, img.rows, img.cols,
grad, qangle, (float)getWinSigma(), block_hists.ptr<float>());
hog::normalize_hists(nbins, block_stride.width, block_stride.height, img.rows, img.cols,
block_hists.ptr<float>(), (float)threshold_L2hys);
}
संपादित करें: मैं hog.cpp
से getDescriptor समारोह शामिल कर रहा हूँ के रूप में अच्छी तरह से
void cv::gpu::HOGDescriptor::getDescriptors(const GpuMat& img, Size win_stride, GpuMat& descriptors, int descr_format)
{
CV_Assert(win_stride.width % block_stride.width == 0 && win_stride.height % block_stride.height == 0);
computeBlockHistograms(img);
const size_t block_hist_size = getBlockHistogramSize();
Size blocks_per_win = numPartsWithin(win_size, block_size, block_stride);
Size wins_per_img = numPartsWithin(img.size(), win_size, win_stride);
descriptors.create(wins_per_img.area(), static_cast<int>(blocks_per_win.area() * block_hist_size), CV_32F);
switch (descr_format)
{
case DESCR_FORMAT_ROW_BY_ROW:
hog::extract_descrs_by_rows(win_size.height, win_size.width, block_stride.height, block_stride.width,
win_stride.height, win_stride.width, img.rows, img.cols, block_hists.ptr<float>(), descriptors);
break;
case DESCR_FORMAT_COL_BY_COL:
hog::extract_descrs_by_cols(win_size.height, win_size.width, block_stride.height, block_stride.width,
win_stride.height, win_stride.width, img.rows, img.cols, block_hists.ptr<float>(), descriptors);
break;
default:
CV_Error(CV_StsBadArg, "Unknown descriptor format");
}
}
किसी ब्लॉक के लिए ही हॉग सुविधाओं को पाने के लिए मेरी मदद कर सकते। संपादित: मैं केवल सेल और ब्लॉक के लिए सुविधाओं को रखने के लिए विभिन्न विंडो आकार के लिए HOG सुविधाओं की गणना करने में रूचि रखता हूं।
आपको एक उदाहरण आप क्या हासिल करना चाहते दे सकते हैं ? मैं होग से इतना परिचित नहीं हूं, लेकिन इससे पहले यह फीचर की गणना नहीं करता है लेकिन डिस्क्रिप्टर। तो उदाहरण के लिए एक होग डिस्क्रिप्टर को 64x128 पिक्सेल विंडो से गणना की जा सकती है। उस खिड़की के भीतर, एल्गोरिदम द्वारा ब्लॉक का मूल्यांकन किया जाता है। क्या आप 64x128 आकार की विंडो को कुछ अलग में बदलना चाहते हैं? आप एक ही ब्लॉक आकार का उपयोग करना चाहते हैं? (क्या यह वर्णनकर्ता तत्व का आकार नहीं बदलता है?) – Micka
प्रतिक्रिया देने के लिए धन्यवाद। असल में मैं केवल ब्लॉक के लिए होग डिस्क्रिप्टर की गणना करना चाहता हूं क्योंकि मेरे पास तीन अलग-अलग विंडो हैं इसलिए मैं केवल एक बार ब्लॉक के लिए होग डिस्क्रिप्टर की गणना करना चाहता हूं। यदि मैं तीन अलग हवाओं के लिए होग डिस्क्रिप्टर की गणना करता हूं तो मैं तीन बार ब्लॉक के लिए होग डिस्क्रिप्टर की गणना कर रहा हूं। मुझे उम्मीद है कि अब आप इसे – shah
आह ठीक कर चुके हैं। क्या आपको जीपीयू संस्करण का उपयोग करना है या सीपीयू भी ठीक होगा? – Micka