我在我们的论文(文凭)中使用了 OpenCV 的 MeanShift 算法。QT4.6中的示例效果很好。仅在我们自己的 GUI 应用程序中,我们收到 320x3x240 RGB 流时,才会给出以下错误消息:
OpenCV Error: Assertion failed (j < nimages) in histPrepareImages, file /home/luca/OpenCvSDK/opencv-src/modules/imgproc/src/histogram.cpp, line 148
terminate called after throwing an instance of 'cv::Exception'
what(): /home/luca/OpenCvSDK/opencv-src/modules/imgproc/src/histogram.cpp:148: error: (-215) j < nimages in function histPrepareImages
Run Code Online (Sandbox Code Playgroud)
GUI是在Ubuntu下使用Eclipse/QT4.6进行编程的。这是代码:
// Mean Shift Algorithm On
minSat=65;
ch[1]={0};
if (m_meanShiftAlgoOn)
{
if (m_firstFrame)
{
m_firstFrame = false;
// Define ROI
imageROI= m_currentFrame( cv::Rect(m_meanShift_xPos,m_meanShift_yPos,
m_meanShift_width,m_meanShift_height));
cv::rectangle(m_currentFrame, cv::Rect(m_meanShift_xPos,m_meanShift_yPos,m_meanShift_width,
m_meanShift_height),cv::Scalar(0,0,255));
// Get the Hue histogram
ColorHistogram hc;
cv::MatND colorhist= hc.getHueHistogram(imageROI,minSat);
finder.setHistogram(colorhist);
finder.setThreshold(0.2f); …Run Code Online (Sandbox Code Playgroud) opencv ×1