0

私は、輪郭を使用して人体を検出する必要があるFYPを完了するためにVS2012とopenCVを使用する初心者です。私は両方(VS2012とopenCV)を正常にインストールし、現在拘束されているfindContours関数を使用するまで、論理的または構文的以外の未知の問題なしに基本的な画像処理を行っていました。私の問題は次のとおりです。

輪郭関連のもの、つまり findContours 、 drawContours をコメントで使用しない場合、すべて問題なく、トラックバーを使用して画像を拡張/侵食できますが、輪郭関連のものを使用して「F5」を押すとすぐに、画像検出されたオブジェクトの周りに等高線を表示すると、Program.exe がブレーク ポイントをトリガーしたため、これ以上使用できないことを示すブレークポイントが表示されます。

参考までに、スタック トレースのリストを以下に示します。

の指示に従いました が、強調表示されていない "ntdll.dll & msvcr" を Microsoft シンボル サーバー経由で読み込んだ後、再起動 (Cntrl+Shift+F5) またはデバッグ (F5) すると再び強調表示されます。強調表示されていないものは、欠落していることを示します。

注 2: 便宜上、リストを簡潔にしています。

ntdll.dll!77ca5204()    Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] 
    ntdll.dll!77c6fbae()    Unknown
    ntdll.dll!77c02b04()    Unknown
    KernelBase.dll!75ff7e27()   Unknown
>   msvcr110d.dll!_CrtIsValidHeapPointer(const void * pUserData) Line 2036  C++
    msvcr110d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1322   C++
    msvcr110d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265  C++
    msvcr110d.dll!operator delete(void * pUserData) Line 54 C++
    binaryFrame.exe!std::allocator<cv::Point_<int> >::deallocate(cv::Point_<int> * _Ptr, 
unsigned int __formal) Line 586 C++
    binaryFrame.exe!std::_Wrap_alloc<std::allocator<cv::Point_<int> > 
>::deallocate(cv::Point_<int> * _Ptr, unsigned int _Count) Line 888 C++
    binaryFrame.exe!std::vector<cv::Point_<int>,std::allocator<cv::Point_<int> > >::_Tidy() 
    binaryFrame.exe!showBinImage() Line 66  C++
    binaryFrame.exe!main(int __formal, char * * argv) Line 21   C++
    binaryFrame.exe!__tmainCRTStartup() Line 536    C
    binaryFrame.exe!mainCRTStartup() Line 377   C
    kernel32.dll!763e1154() Unknown
    ntdll.dll!77c3b299()    Unknown
    ntdll.dll!77c3b26c()    Unknown

以下は、画像の輪郭検出に使用しているコードです。

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

void showBinImage();

int val=2;


int main( int, char** argv )
{
    showBinImage();
    return 0;
}  


void showBinImage(){
Mat bin;
Mat im_gray;   


Mat im_rgb  = imread("nk5.jpg");

        //  Trackbar

namedWindow("ErodedImage",1);
createTrackbar("Erode", "ErodedImage", &val, 50);

cvtColor(im_rgb, im_gray,CV_RGB2GRAY);
threshold(im_gray, bin, 128.0, 255.0, THRESH_BINARY_INV);
//imwrite("bnasir.jpg", img_bw);
namedWindow("Binary",1);
imshow("Binary", bin);

while (true)
{

Mat erodeElement = getStructuringElement( MORPH_CROSS,Size(val*3,val*3));   
Mat dilateElement = getStructuringElement( MORPH_RECT,Size(val*8,val*8));
Mat eroded; // the destination image
erode(bin,eroded,erodeElement+50);
dilate(eroded,eroded,dilateElement);    
std::vector<std::vector<cv::Point>> contours;       
findContours(eroded, contours, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE);  
// Draw black contours on a white image
Mat result(eroded.size(),CV_8U,cv::Scalar(255));
drawContours(result,contours,-1, cv::Scalar(0), 2); // with a thickness of 2
imshow("ErodedImage",(eroded));
waitKey(10);

}

}

4

1 に答える 1

0

VS2012 から VS2010 に切り替えたところ、すべて正常に動作するようになりました。VS2013 も VS2010 として結果を提供するため、VS2012 の何が問題なのかわかりませんが、VS2013 を使用するには Windows 8 OS が必要です。したがって、Windows 7 OSを使用しているため、古いバージョンに戻りました!

于 2014-07-23T00:52:13.120 に答える