openCV 3.1.0을 사용하고 있습니다 (동일한 문제가있는 2.4.9로 시도 함). 난 그냥 inRange
, 프로그램 작업을 제거한 경우inRange를 사용한 후 HSV에서 BGR로, HSV에서 JPEG로 JPEG을 변환 할 때 오류가 발생했습니다.
OpenCV Error: Assertion failed (scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /home/pi/opencv/src/opencv-3.1.0/modules/imgproc/src/color.cpp, line 8176
terminate called after throwing an instance of 'cv::Exception' what(): /home/pi/opencv/src/opencv-3.1.0/modules/imgproc/src/color.cpp:8176: error: (-215) scn == 3 && (dcn == 3 || dcn == 4) && (depth == CV_8U || depth == CV_32F) in function cvtColor
: 내가 inRange
으로, 내 프로그램이 실패합니다 cvtColor(tmp, imgMat, CV_HSV2BGR)
할 때,
// .. Getting JPEG content into memory
// JPEG to mat
Mat imgBuf=Mat(1, jpegContent, CV_8UC3, jpegSize);
Mat imgMat=imdecode(imgBuf, CV_LOAD_IMAGE_COLOR);
free(jpegContent);
if(imgMat.data == NULL) {
// Some error handling
}
// Now the JPEG is decoded and reside in imgMat
cvtColor(imgMat, imgMat, CV_BGR2HSV); // Converting to HSV
Mat tmp;
inRange(imgMat, Scalar(0, 0, 0), Scalar(8, 8, 8), tmp); // Problem goes here
cvtColor(tmp, imgMat, CV_HSV2BGR);
// Mat to JPEG
vector<uchar> buf;
imencode(".jpg", imgMat, buf, std::vector<int>());
outputJPEG=(unsigned char*)malloc(buf.size());
memcpy(outputJPEG, &buf[0], buf.size());
// ... Output JPEG
문제가있다 : I는 이미지 (JPEG)로하는 HSV 매트 출력하고자 벌금. imencode
에 작업을 수행하고 HSV를 BGR로 자동 변환 한 다음 JPEG로 변환하여 cvtColor 호출을 제거하려고했습니다. 이번에는 더 이상 주장은 실패했지만있는 GStreamer는 불평으로 나는, JPEG 이미지를 손상있어 :
gstrtpjpegpay.c(581): gst_rtp_jpeg_pay_read_sof(): /GstPipeline:pipeline0/GstRtpJPEGPay:rtpjpegpay0 WARNING: from element /GstPipeline:pipeline0/GstRtpJPEGPay:rtpjpegpay0: Wrong SOF length 11.
는 다시 inRange
을 제거하면이 문제가, 그것은 좋은 JPEG 데이터를 생성 해결합니다.
그래서, 제가 부당하게 그 이미지 데이터를 손상시킬 inRange
을 호출하는 것입니까? 그렇다면 inRange
을 사용하는 올바른 방법은 무엇입니까?
'inRange'는'CV_8UC1' 타입의 2 진 행렬을 제공합니다. HSV – Miki
으로 변환 할 수 없습니다. 이제 꽤 잘되었습니다. 감사합니다. –