2012-01-17 3 views
9

내가 다음 코드를 사용하여 이미지의 특정 위치에 검소한 연산자를 적용하려고 addWeighted addWeighted가 실행됩니다.OpenCV의은 - - 입력 인수의 크기가 일치하지 않습니다

 
OpenCV Error: Sizes of input arguments do not match (The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array') in arithm_op, file C:\OpenCV2.3\ opencv\modules\core\src\arithm.cpp, line 1227 
terminate called after throwing an instance of 'cv::Exception' 
what(): C:\OpenCV2.3\opencv\modules\core\src\arithm.cpp:1227: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function arithm_op 

문제점의 원인을 알려주십시오. 나는 오랫동안이 일에 매달 렸습니다 ...

고마워요.

+0

특히 어떤 줄로 오류가 발생합니까? - 걱정하지 마라, 나는 그것이'addWeighted'라고 본다. –

+0

@ mathematical.coffee addWeighted, 질문을 편집했습니다. 감사. – mrcaramori

답변

9

쉬운. 병합 할 2 개의 이미지에는 동일한 수의 채널이 없습니다.

cvtColor(devilROI, canny, CV_RGB2GRAY); 

3 채널 이미지를 1 채널 그레이 스케일 이미지로 변환합니다. addWeighted를 사용하려면 동일한 채널 수가 필요합니다.

2

좋아, 알았어.

(scn ==1 && (dcn == 3 || dcn == 4)) 

오류 :

내가 매트 :: 사항 copyTo를 사용하여 시도, 나는이 있어요.

그럼 내가 RGB로 다시 변환하는 나에게 아이디어를 준, this Stackoveflow 항목을 발견 한 후 나는 다음을 시도하고 일 : 사람이 어떤 다른 제안이있는 경우

Mat devilROI = img(Rect(r->x+lowerRect.x, 
         r->y + lowerRect.y, 
         lowerRect.width, 
         lowerRect.height)); 
Mat canny; 
cvtColor(devilROI, canny, CV_BGR2GRAY); 
Canny(canny, canny, low_threshold, high_threshold); 
cvtColor(canny, canny, CV_GRAY2BGR); 
addWeighted(devilROI, 1.0, canny, 0.3, 0., devilROI); 

그래서, 나는 것 기분 좋은.

감사합니다.

+0

파이썬 코드는 어떻습니까 ?? – Allan

관련 문제