现在的位置: 首页 > 综合 > 正文

关于” Assertion failed:src_picture->width%2== 0 && src——picture-》height%2== 0”的问题(还未决解)

2013年01月01日 ⁄ 综合 ⁄ 共 1254字 ⁄ 字号 评论关闭

在使用PyrSegmentation领域分割函数时出现的问题出现Assertionfailed:src_picture->width%2== 0 && src——picture-height%2==
0…….

还有提示:Thisapplication has requested the Runtime to terminate it in an lead the way. BothPlease contact the application 's support team for more information. (PressRetry to debug the application)

 

经过多次尝试,发现输入的图像有些可以通过,有些却不能通过。(求高手解释,谢谢)

#include "stdafx.h"
#include"opencv2/opencv.hpp"
#include "legacy.hpp"

int _tmain(int argc, _TCHAR* argv[])
{
    cvNamedWindow("src");
    cvNamedWindow("PyrSegmentation");
	//加载图像
	IplImage* src_picture= cvLoadImage("F://Opencv_picture//2.jpg");
    IplImage* dst_picture= cvCreateImage(cvGetSize(src_picture), src_picture->depth, src_picture->nChannels);
	
     
	assert(src_picture->width%2 == 0 && src_picture->height%2 == 0);
	//分配内存
	CvMemStorage* storage= cvCreateMemStorage(0);
	if(!storage)
	{
	     printf("Storage Errors!\n");
	}

	 //分割部件的输出序列的指针
	CvSeq* comp= NULL;   
	 //建立金字塔的最大层数
	int levels =2;
	 //建立连接的错误阈值
	double threshold1= 150;
	 //分割簇的错误阈值
	double threshold2= 30;
     //金字塔图像分割
	cvPyrSegmentation(src_picture, dst_picture, storage, &comp, levels, threshold1, threshold2);

	cvShowImage("src", src_picture);
	cvShowImage("PyrSegmentation", dst_picture);

	cvWaitKey(0);
    
	cvReleaseImage(&src_picture);
	cvReleaseImage(&dst_picture);

	cvDestroyWindow("src");
	cvDestroyWindow("PyrSegMentation");
	return 0;
}

能通过的结果图



希望大牛们告诉我为什么有些图片(如下面的)不能通过?在这先谢谢啦^_^

     

这两图就是不能通过

【上篇】
【下篇】

抱歉!评论已关闭.