1
4 채널로 구성된 Mat
에 대한 투명도를 설정하고 있습니다 (일부 계산 기준). 그러나 이미지를 창에 표시 할 때 이미지에 아무런 변화가 없습니다. 어떤 도움이라도 큰 도움이 될 것입니다.OpenCV의 투명도 설정이 작동하지 않습니다.
void feather_touch(Rect enclosingRect, Mat frame){
Point center(frame.size().width * 0.5, frame.size().height * 0.5);
int inclussive_circle_radius = (sqrt((frame.cols * frame.cols + frame.rows * frame.rows)))/2;
for(int i = 0; i < frame.rows; i++){
for(int j = 0; j < frame.cols; j++){
Point point(i, j);
if(!inRect(point, enclosingRect)){
Vec4b channels = frame.at<Vec4b>(i, j);
int dx = center.x - point.x;
int dy = center.y - point.y;
int dist = sqrt((dx * dx) + (dy * dy));
float alpha = (float)dist/(float)inclussive_circle_radius;
int a = (int)((1 - alpha) * 255);
frame.at<Vec4b>(i, j)[3] = a;
}
}
}
}
bool inRect(cv::Point p,Rect rect) {
return p.x >= rect.x && p.x <= (rect.x + rect.width) && p.y >= rect.y && p.y <= (rect.y + rect.height);
}
의 중복 가능성 [OpenCV의 : 픽셀의 알파 투명도를 설정하는 방법 (http://stackoverflow.com/questions/16196312/opencv-how-to-set-alpha - 픽셀 투명성) – Aurelius