C++ 基于形状C++;。OPENCV
此处的彩色图像:此处的多边形近似图像:\n 我得到了54块拼图,我想用每个拼图的形状来解决这些拼图 我所做的是:C++ 基于形状C++;。OPENCV,c++,opencv,image-processing,computer-vision,C++,Opencv,Image Processing,Computer Vision,此处的彩色图像:此处的多边形近似图像:\n 我得到了54块拼图,我想用每个拼图的形状来解决这些拼图 我所做的是: 从背景中分割每一块 获取精明的边缘和轮廓 应用多边形近似 现在,我想应用凸面外壳,但我不知道如何使用opencv获得每个工件的凸面和凹面 puzzle.input_image.copyTo(input_copy); cvtColor(puzzle.input_image,input_image_gray,CV_RGB2GRAY); // convert to gray. Mat
puzzle.input_image.copyTo(input_copy);
cvtColor(puzzle.input_image,input_image_gray,CV_RGB2GRAY); // convert to gray.
Mat thresholded_image=puzzle.get_thresholded_image(input_image_gray);
imshow("thresholded",thresholded_image);
Mat floodfill_image=puzzle.floodfill(thresholded_image);
contours=puzzle.get_contours(floodfill_image);
puzzle.get_puzzle_pieces(thresholded_image,input_copy);
for(int i=0; i< puzzle.pieces_color.size() ; i++){
Mat temp = Mat::zeros(puzzle.pieces_color.at(i).rows,puzzle.pieces_color.at(i).cols,CV_8U);
Mat temp2= Mat::zeros(puzzle.pieces_color.at(i).rows,puzzle.pieces_color.at(i).cols,CV_8U);
Mat temp3= Mat::zeros(puzzle.pieces_color.at(i).rows,puzzle.pieces_color.at(i).cols,CV_8U);
cvtColor(puzzle.pieces_color[i],temp,CV_RGB2GRAY);
temp2=puzzle.get_thresholded_image(temp);
puzzle.pieces_binary.push_back(temp2);
temp3=puzzle.get_canny(temp2);
imshow("temp2",temp3);
imwrite("temp2.jpg",temp3);
// getting the contours.
contours=puzzle.get_contours(temp2);
for(int c=0; c< contours.size() ; c++){ // poly approxamiation for all the contours for every piece.
std::vector<cv::Point> poly;
cv::approxPolyDP(cv::Mat(contours[c]),poly,5,true);
// Iterate over each segment and draw it
std::vector<cv::Point>::const_iterator itp= poly.begin();
while (itp!=(poly.end()-1)) {
cv::line(temp2,*itp,*(itp+1),cv::Scalar(255),2);
++itp;
}
// last point linked to first point
cv::line(temp2,*(poly.begin()),*(poly.end()-1),cv::Scalar(255),2);
}
puzzle.input\u image.copyTo(input\u copy);
CVT颜色(拼图。输入_图像,输入_图像_灰色,CV_RGB2灰色);//转换成灰色。
Mat Threshold_image=拼图。获取_Threshold_image(输入_image_gray);
imshow(“阈值化”,阈值化图像);
Mat floodfill_image=puzzle.floodfill(阈值化_图像);
等高线=拼图。获取等高线(泛光填充图像);
拼图。获取拼图块(阈值图像,输入副本);
对于(int i=0;i
有什么帮助吗?
谢谢。一些图像和一段代码可能有助于更快地获得答案…@tfv图像和代码已添加。谢谢您的帮助。您希望使用凸面外壳实现什么?使用凸面外壳,我假设我可以测量拼图的凹面有多深,或凸面有多高。因此我可以将拼图的一侧与凹面与另一面有凸面。@MidhunHarikumarSome图像和一段代码可能有助于更快地获得答案…@tfv图像和代码已添加。感谢帮助。您希望使用凸面外壳实现什么?使用凸面外壳,我假设我可以测量凹面的深度或凸面的高度拼图。所以我可以将拼图的一面用凹面匹配,另一面用凸面匹配。@MidhunHarikumar