Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error about cvtColor

Hello, I am using the opencv to compare images with the code compareHist_Demo.cpp, here is my code

`#include <iostream>

include <ctime>

include <cstdlib>

include <fstream>

include <sstream>

include "raspicam_cv.h"

//#include "opencv2/imgcodecs.hpp"

include "opencv2/highgui/highgui.hpp"

include "opencv2/imgproc/imgproc.hpp"

//#include "opencv2/opencv.hpp" //editted

include <stdio.h>

include <string.h>

include <errno.h>

include <wiringserial.h>

include <wiringpi.h>

using namespace cv; using namespace std; bool doTestSpeedOnly=false; //parse command line //returns the index of a command line param in argv. If not found, return -1 int findParam ( string param,int argc,char **argv ) { int idx=-1; for ( int i=0; i<argc &amp;&amp;="" idx="=-1;" i++="" )="" if="" (="" string="" (="" argv[i]="" )="=param" )="" idx="i;" return="" idx;<="" p="">

} //parse command line //returns the value of a command line param. If not found, defvalue is returned float getParamVal ( string param,int argc,char **argv,float defvalue=-1 ) { int idx=-1; for ( int i=0; i<argc &amp;&amp;="" idx="=-1;" i++="" )="" if="" (="" string="" (="" argv[i]="" )="=param" )="" idx="i;" if="" (="" idx="=-1" )="" return="" defvalue;="" else="" return="" atof="" (="" argv[="" idx+1]="" );="" }<="" p="">

void processCommandLine ( int argc,char **argv,raspicam::RaspiCam_Cv &Camera ) { Camera.set ( CV_CAP_PROP_FRAME_WIDTH, getParamVal ( "-w",argc,argv,192 ) ); Camera.set ( CV_CAP_PROP_FRAME_HEIGHT, getParamVal ( "-h",argc,argv,144 ) ); Camera.set ( CV_CAP_PROP_BRIGHTNESS,getParamVal ( "-br",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_CONTRAST ,getParamVal ( "-co",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_SATURATION, getParamVal ( "-sa",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_GAIN, getParamVal ( "-g",argc,argv ,50 ) ); if ( findParam ( "-gr",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_FORMAT, CV_8UC1 ); if ( findParam ( "-test_speed",argc,argv ) !=-1 ) doTestSpeedOnly=true; if ( findParam ( "-ss",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_EXPOSURE, getParamVal ( "-ss",argc,argv ) ); if ( findParam ( "-wb_r",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_WHITE_BALANCE_RED_V,getParamVal ( "-wb_r",argc,argv ) ); if ( findParam ( "-wb_b",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_WHITE_BALANCE_BLUE_U,getParamVal ( "-wb_b",argc,argv ) );

// Camera.setSharpness ( getParamVal ( "-sh",argc,argv,0 ) ); // if ( findParam ( "-vs",argc,argv ) !=-1 ) // Camera.setVideoStabilization ( true ); // Camera.setExposureCompensation ( getParamVal ( "-ev",argc,argv ,0 ) );

}

void showUsage() { cout<<"Usage: "<<endl; cout&lt;&lt;"[-gr="" set="" gray="" color="" capture]\n";="" cout&lt;&lt;"[-test_speed="" use="" for="" test="" speed="" and="" no="" images="" will="" be="" saved]\n";="" cout&lt;&lt;"[-w="" width]="" [-h="" height]="" \n[-br="" brightness_val(0,100)]\n";="" cout&lt;&lt;"[-co="" contrast_val="" (0="" to="" 100)]\n[-sa="" saturation_val="" (0="" to="" 100)]";="" cout&lt;&lt;"[-g="" gain_val="" (0="" to="" 100)]\n";="" cout&lt;&lt;"[-ss="" shutter_speed="" (0="" to="" 100)="" 0="" auto]\n";="" cout&lt;&lt;"[-wb_r="" val="" (0="" to="" 100),0="" auto:="" white="" balance="" red="" component]\n";="" cout&lt;&lt;"[-wb_b="" val="" (0="" to="" 100),0="" auto:="" white="" balance="" blue="" component]\n";<="" p="">

cout<<endl;

}

int main ( int argc,char **argv ) { int fd; int a; int b; if ((fd = serialOpen("/dev/ttyAMA0", 9600)) < 0) { fprintf(stderr, "unable to open serial device; %s\n", strerror(errno)); return 1; } if ( argc==1 ) { cerr<<"Usage (-help for help)"<<endl; }="" if="" (="" findparam="" (="" "-help",argc,argv="" )="" !="-1" )="" {="" showusage();="" return="" -1;="" }="" raspicam::raspicam_cv="" camera;="" camera.set(cv_cap_prop_fps,="" 30);="" processcommandline(argc,="" argv,="" camera);="" cout="" &lt;&lt;="" "connecting="" to="" camera"="" &lt;&lt;="" endl;="" if="" (!camera.open())="" {="" cerr="" &lt;&lt;="" "error="" opening="" camera"="" &lt;&lt;="" endl;="" return="" -1;="" }="" cout="" &lt;&lt;="" "connected="" to="" camera=" &lt;&lt; Camera.getId() &lt;&lt; endl;&lt;/p&gt; &lt;pre&gt;&lt;code&gt;cv::Mat image; vector&lt;Mat&gt; Concat; //int nCount = 70; cout &lt;&lt; " capturing"="" &lt;&lt;="" endl;="" for="" (int="" i="0;" i="" &lt;="3;" i++){="" camera.grab();="" camera.retrieve(image);="" concat.push_back(image.clone());="" cv::imwrite("image"+std::to_string(i)+".jpg",image);="" delay(150);="" }="" mat="" src_base,="" hsv_base;="" mat="" src_test1,="" hsv_test1;="" mat="" src_test2,="" hsv_test2;="" mat="" hsv_half_down;="" load="" three="" images="" with="" different="" environment="" settings="" if="" (argc="" &lt;="" 4)="" {="" printf("**="" error.="" usage:="" .="" comparehist_demo="" &lt;image_settings0&gt;="" &lt;image_setting1&gt;="" &lt;image_settings2&gt;\n");="" return="" -1;="" }="" src_base="imread("image0"," 1);="" src_test1="imread("image1"," 1);="" src_test2="imread("image2"," 1);="" convert="" to="" hsv="" cvtcolor(src_base,="" hsv_base,="" color_bgr2hsv);="" cvtcolor(src_test1,="" hsv_test1,="" color_bgr2hsv);="" cvtcolor(src_test2,="" hsv_test2,="" color_bgr2hsv);="" hsv_half_down="hsv_base(Range(hsv_base.rows" 2,="" hsv_base.rows="" -="" 1),="" range(0,="" hsv_base.cols="" -="" 1));="" using="" 50="" bins="" for="" hue="" and="" 60="" for="" saturation="" int="" h_bins="50;" int="" s_bins="60;" int="" histsize[]="{" h_bins,="" s_bins="" };="" hue="" varies="" from="" 0="" to="" 179,="" saturation="" from="" 0="" to="" 255="" float="" h_ranges[]="{" 0,="" 180="" };="" float="" s_ranges[]="{" 0,="" 256="" };="" const="" float*="" ranges[]="{" h_ranges,="" s_ranges="" };="" use="" the="" o-th="" and="" 1-st="" channels="" int="" channels[]="{" 0,="" 1="" };="" histograms="" matnd="" hist_base;="" matnd="" hist_half_down;="" matnd="" hist_test1;="" matnd="" hist_test2;="" calculate="" the="" histograms="" for="" the="" hsv="" images="" calchist(&amp;hsv_base,="" 1,="" channels,="" mat(),="" hist_base,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_base,="" hist_base,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_half_down,="" 1,="" channels,="" mat(),="" hist_half_down,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_half_down,="" hist_half_down,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_test1,="" 1,="" channels,="" mat(),="" hist_test1,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_test1,="" hist_test1,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_test2,="" 1,="" channels,="" mat(),="" hist_test2,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_test2,="" hist_test2,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" apply="" the="" histogram="" comparison="" methods="" for="" (int="" i="0;" i="" &lt;="" 4;="" i++)="" {="" int="" compare_method="i;" double="" base_base="compareHist(hist_base," hist_base,="" compare_method);="" double="" base_half="compareHist(hist_base," hist_half_down,="" compare_method);="" double="" base_test1="compareHist(hist_base," hist_test1,="" compare_method);="" double="" base_test2="compareHist(hist_base," hist_test2,="" compare_method);="" printf("="" method="" [%d]="" perfect,="" base-half,="" base-test(1),="" base-test(2)="" :="" %f,="" %f,="" %f,="" %f="" \n",="" i,="" base_base,="" base_half,="" base_test1,="" base_test2);="" }="" printf("done="" \n");="" camera.release();="" <="" code="">

}`

I use the raspberry pi to take images and then compare them. But when I run this code, the camera take pictures, but it gave this error information `OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/imgproc/src/color.cpp, line 3344 terminate called after throwing an instance of 'cv::Exception' what(): /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/imgproc/src/color.cpp:3344: error: (-215) (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor

Aborted` Could anyone help me with this? In addition, my opencv version is 2.4.1

error about cvtColor

Hello, I am using the opencv to compare images with the code compareHist_Demo.cpp, here is my code

`#include <iostream>

include <ctime>

include <cstdlib>

include <fstream>

include <sstream>

include "raspicam_cv.h"

//#include "opencv2/imgcodecs.hpp"

include "opencv2/highgui/highgui.hpp"

include "opencv2/imgproc/imgproc.hpp"

//#include "opencv2/opencv.hpp" //editted

include <stdio.h>

include <string.h>

include <errno.h>

include <wiringserial.h>

include <wiringpi.h>

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include "raspicam_cv.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <wiringSerial.h> 
#include <wiringPi.h>
 using namespace cv;
using namespace std;
bool doTestSpeedOnly=false;
//parse command line
//returns the index of a command line param in argv. If not found, return -1
 int findParam ( string param,int argc,char **argv ) {
 int idx=-1;
 for ( int i=0; i<argc &amp;&amp;="" idx="=-1;" i++="" )="" if="" (="" string="" (="" argv[i]="" )="=param" )="" idx="i;" return="" idx;<="" p="">

} && idx==-1; i++ ) if ( string ( argv[i] ) ==param ) idx=i; return idx; } //parse command line //returns the value of a command line param. If not found, defvalue is returned float getParamVal ( string param,int argc,char **argv,float defvalue=-1 ) { int idx=-1; for ( int i=0; i<argc &amp;&amp;="" idx="=-1;" i++="" )="" if="" (="" string="" (="" argv[i]="" )="=param" )="" idx="i;" if="" (="" idx="=-1" )="" return="" defvalue;="" else="" return="" atof="" (="" argv[="" idx+1]="" );="" }<="" p="">

&& idx==-1; i++ ) if ( string ( argv[i] ) ==param ) idx=i; if ( idx==-1 ) return defvalue; else return atof ( argv[ idx+1] ); } void processCommandLine ( int argc,char **argv,raspicam::RaspiCam_Cv &Camera ) { Camera.set ( CV_CAP_PROP_FRAME_WIDTH, getParamVal ( "-w",argc,argv,192 ) ); Camera.set ( CV_CAP_PROP_FRAME_HEIGHT, getParamVal ( "-h",argc,argv,144 ) ); Camera.set ( CV_CAP_PROP_BRIGHTNESS,getParamVal ( "-br",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_CONTRAST ,getParamVal ( "-co",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_SATURATION, getParamVal ( "-sa",argc,argv,50 ) ); Camera.set ( CV_CAP_PROP_GAIN, getParamVal ( "-g",argc,argv ,50 ) ); if ( findParam ( "-gr",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_FORMAT, CV_8UC1 ); if ( findParam ( "-test_speed",argc,argv ) !=-1 ) doTestSpeedOnly=true; if ( findParam ( "-ss",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_EXPOSURE, getParamVal ( "-ss",argc,argv ) ); if ( findParam ( "-wb_r",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_WHITE_BALANCE_RED_V,getParamVal ( "-wb_r",argc,argv ) ); if ( findParam ( "-wb_b",argc,argv ) !=-1 ) Camera.set ( CV_CAP_PROP_WHITE_BALANCE_BLUE_U,getParamVal ( "-wb_b",argc,argv ) );

// Camera.setSharpness ( getParamVal ( "-sh",argc,argv,0 ) ); // if ( findParam ( "-vs",argc,argv ) !=-1 ) // Camera.setVideoStabilization ( true ); // Camera.setExposureCompensation ( getParamVal ( "-ev",argc,argv ,0 ) );

}

} void showUsage() { cout<<"Usage: "<<endl; cout&lt;&lt;"[-gr="" set="" gray="" color="" capture]\n";="" cout&lt;&lt;"[-test_speed="" use="" for="" test="" speed="" and="" no="" images="" will="" be="" saved]\n";="" cout&lt;&lt;"[-w="" width]="" [-h="" height]="" \n[-br="" brightness_val(0,100)]\n";="" cout&lt;&lt;"[-co="" contrast_val="" (0="" to="" 100)]\n[-sa="" saturation_val="" (0="" to="" 100)]";="" cout&lt;&lt;"[-g="" gain_val="" (0="" to="" 100)]\n";="" cout&lt;&lt;"[-ss="" shutter_speed="" (0="" to="" 100)="" 0="" auto]\n";="" cout&lt;&lt;"[-wb_r="" val="" (0="" to="" 100),0="" auto:="" white="" balance="" red="" component]\n";="" cout&lt;&lt;"[-wb_b="" val="" (0="" to="" 100),0="" auto:="" white="" balance="" blue="" component]\n";<="" p="">

"<<endl;
cout<<"[-gr set gray color capture]\n";
cout<<"[-test_speed use for test speed and no images will be saved]\n";
cout<<"[-w width] [-h height] \n[-br brightness_val(0,100)]\n";
cout<<"[-co contrast_val (0 to 100)]\n[-sa saturation_val (0 to 100)]";
cout<<"[-g gain_val (0 to 100)]\n";
cout<<"[-ss shutter_speed (0 to 100) 0 auto]\n";
cout<<"[-wb_r val (0 to 100),0 auto: white balance red component]\n";
cout<<"[-wb_b val (0 to 100),0 auto: white balance blue component]\n";
cout<<endl;

}

} int main ( int argc,char **argv ) { int fd; int a; int b; if ((fd = serialOpen("/dev/ttyAMA0", 9600)) < 0) { fprintf(stderr, "unable to open serial device; %s\n", strerror(errno)); return 1; } } if ( argc==1 ) { cerr<<"Usage (-help for help)"<<endl; }="" if="" (="" findparam="" (="" "-help",argc,argv="" )="" !="-1" )="" {="" showusage();="" return="" -1;="" }="" raspicam::raspicam_cv="" camera;="" camera.set(cv_cap_prop_fps,="" 30);="" processcommandline(argc,="" argv,="" camera);="" cout="" &lt;&lt;="" "connecting="" to="" camera"="" &lt;&lt;="" endl;="" if="" (!camera.open())="" {="" cerr="" &lt;&lt;="" "error="" opening="" camera"="" &lt;&lt;="" endl;="" return="" -1;="" }="" cout="" &lt;&lt;="" "connected="" to="" camera=" &lt;&lt; help)"<<endl; } if ( findParam ( "-help",argc,argv ) !=-1 ) { showUsage(); return -1; } raspicam::RaspiCam_Cv Camera; Camera.set(CV_CAP_PROP_FPS, 30); processCommandLine(argc, argv, Camera); cout << "Connecting to camera" << endl; if (!Camera.open()) { cerr << "Error opening camera" << endl; return -1; } cout << "Connected to camera =" << Camera.getId() &lt;&lt; endl;&lt;/p&gt; &lt;pre&gt;&lt;code&gt;cv::Mat << endl; cv::Mat image; vector&lt;Mat&gt; vector<Mat> Concat; //int nCount = 70; cout &lt;&lt; " capturing"="" &lt;&lt;="" endl;="" for="" (int="" i="0;" i="" &lt;="3;" i++){="" camera.grab();="" camera.retrieve(image);="" concat.push_back(image.clone());="" cv::imwrite("image"+std::to_string(i)+".jpg",image);="" delay(150);="" }="" mat="" src_base,="" hsv_base;="" mat="" src_test1,="" hsv_test1;="" mat="" src_test2,="" hsv_test2;="" mat="" hsv_half_down;="" load="" three="" images="" with="" different="" environment="" settings="" if="" (argc="" &lt;="" 4)="" {="" printf("**="" error.="" usage:="" .="" comparehist_demo="" &lt;image_settings0&gt;="" &lt;image_setting1&gt;="" &lt;image_settings2&gt;\n");="" return="" -1;="" }="" src_base="imread("image0"," 1);="" src_test1="imread("image1"," 1);="" src_test2="imread("image2"," 1);="" convert="" to="" hsv="" cvtcolor(src_base,="" hsv_base,="" color_bgr2hsv);="" cvtcolor(src_test1,="" hsv_test1,="" color_bgr2hsv);="" cvtcolor(src_test2,="" hsv_test2,="" color_bgr2hsv);="" hsv_half_down="hsv_base(Range(hsv_base.rows" 2,="" hsv_base.rows="" -="" 1),="" range(0,="" hsv_base.cols="" -="" 1));="" using="" 50="" bins="" for="" hue="" and="" 60="" for="" saturation="" int="" h_bins="50;" int="" s_bins="60;" int="" histsize[]="{" h_bins,="" s_bins="" };="" hue="" varies="" from="" 0="" to="" 179,="" saturation="" from="" 0="" to="" 255="" float="" h_ranges[]="{" 0,="" 180="" };="" float="" s_ranges[]="{" 0,="" 256="" };="" const="" float*="" ranges[]="{" h_ranges,="" s_ranges="" };="" use="" the="" o-th="" and="" 1-st="" channels="" int="" channels[]="{" 0,="" 1="" };="" histograms="" matnd="" hist_base;="" matnd="" hist_half_down;="" matnd="" hist_test1;="" matnd="" hist_test2;="" calculate="" the="" histograms="" for="" the="" hsv="" images="" calchist(&amp;hsv_base,="" 1,="" channels,="" mat(),="" hist_base,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_base,="" hist_base,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_half_down,="" 1,="" channels,="" mat(),="" hist_half_down,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_half_down,="" hist_half_down,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_test1,="" 1,="" channels,="" mat(),="" hist_test1,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_test1,="" hist_test1,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" calchist(&amp;hsv_test2,="" 1,="" channels,="" mat(),="" hist_test2,="" 2,="" histsize,="" ranges,="" true,="" false);="" normalize(hist_test2,="" hist_test2,="" 0,="" 1,="" norm_minmax,="" -1,="" mat());="" apply="" the="" histogram="" comparison="" methods="" for="" (int="" i="0;" i="" &lt;="" 4;="" i++)="" {="" int="" compare_method="i;" double="" base_base="compareHist(hist_base," hist_base,="" compare_method);="" double="" base_half="compareHist(hist_base," hist_half_down,="" compare_method);="" double="" base_test1="compareHist(hist_base," hist_test1,="" compare_method);="" double="" base_test2="compareHist(hist_base," hist_test2,="" compare_method);="" printf("="" method="" [%d]="" perfect,="" base-half,="" base-test(1),="" base-test(2)="" :="" %f,="" %f,="" %f,="" %f="" \n",="" i,="" base_base,="" base_half,="" base_test1,="" base_test2);="" }="" printf("done="" \n");="" camera.release();="" <="" code="">

}`

<< "Capturing" << endl; for (int i = 0; i <= 3; i++){ Camera.grab(); Camera.retrieve(image); Concat.push_back(image.clone()); cv::imwrite("image"+std::to_string(i)+".jpg",image); //delay(150); } Mat src_base, hsv_base; Mat src_test1, hsv_test1; Mat src_test2, hsv_test2; Mat hsv_half_down; /// Load three images with different environment settings if (argc < 4) { printf("** Error. Usage: ./compareHist_Demo <image_settings0> <image_setting1> <image_settings2>\n"); return -1; } src_base = imread("image0", 1); src_test1 = imread("image1", 1); src_test2 = imread("image2", 1); /// Convert to HSV cvtColor(src_base, hsv_base, COLOR_BGR2HSV); cvtColor(src_test1, hsv_test1, COLOR_BGR2HSV); cvtColor(src_test2, hsv_test2, COLOR_BGR2HSV); hsv_half_down = hsv_base(Range(hsv_base.rows / 2, hsv_base.rows - 1), Range(0, hsv_base.cols - 1)); /// Using 50 bins for hue and 60 for saturation int h_bins = 50; int s_bins = 60; int histSize[] = { h_bins, s_bins }; // hue varies from 0 to 179, saturation from 0 to 255 float h_ranges[] = { 0, 180 }; float s_ranges[] = { 0, 256 }; const float* ranges[] = { h_ranges, s_ranges }; // Use the o-th and 1-st channels int channels[] = { 0, 1 }; /// Histograms MatND hist_base; MatND hist_half_down; MatND hist_test1; MatND hist_test2; /// Calculate the histograms for the HSV images calcHist(&hsv_base, 1, channels, Mat(), hist_base, 2, histSize, ranges, true, false); normalize(hist_base, hist_base, 0, 1, NORM_MINMAX, -1, Mat()); calcHist(&hsv_half_down, 1, channels, Mat(), hist_half_down, 2, histSize, ranges, true, false); normalize(hist_half_down, hist_half_down, 0, 1, NORM_MINMAX, -1, Mat()); calcHist(&hsv_test1, 1, channels, Mat(), hist_test1, 2, histSize, ranges, true, false); normalize(hist_test1, hist_test1, 0, 1, NORM_MINMAX, -1, Mat()); calcHist(&hsv_test2, 1, channels, Mat(), hist_test2, 2, histSize, ranges, true, false); normalize(hist_test2, hist_test2, 0, 1, NORM_MINMAX, -1, Mat()); /// Apply the histogram comparison methods for (int i = 0; i < 4; i++) { int compare_method = i; double base_base = compareHist(hist_base, hist_base, compare_method); double base_half = compareHist(hist_base, hist_half_down, compare_method); double base_test1 = compareHist(hist_base, hist_test1, compare_method); double base_test2 = compareHist(hist_base, hist_test2, compare_method); printf(" Method [%d] Perfect, Base-Half, Base-Test(1), Base-Test(2) : %f, %f, %f, %f \n", i, base_base, base_half, base_test1, base_test2); } printf("Done \n"); Camera.release(); }

I use the raspberry pi to take images and then compare them. But when I run this code, the camera take pictures, but it gave this error information `OpenCV information

OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/imgproc/src/color.cpp, line 3344
 terminate called after throwing an instance of 'cv::Exception'
   what():  /usr/src/packages/BUILD/opencv-2.4.1+dfsg/modules/imgproc/src/color.cpp:3344: error:  (-215)  (scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColorcvtColor

Aborted

Aborted` Could anyone help me with this? In addition, my opencv version is 2.4.1