opencv에 익숙하지 않지만 'remap'기능을 사용하여 이미지를 수정해야합니다. 따르면OpenCV 매개 변수를 다시 매핑하고 사용하는 방법
Applies a generic geometrical transformation to an image.
C++: void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
map1 – The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1 , or CV_32FC2 . See convertMaps() for details on converting a floating point representation to fixed-point for speed.
map2 – The second map of y values having the type CV_16UC1 , CV_32FC1 , or none (empty map if map1 is (x,y) points), respectively.
; I는 960x1280 갖는 화상 및 9.8MB (한 위치 (x, y)에있는 두 개의 플로트를 의미 960x1280x4x2으로 같게된다)와 'remap.bin'라는 리맵 파일이 에 대한 설명, I의이 같은 코드 :
int main(int argc, char* argv[]){
if(argc != 3){
printf("Please enter one path of image and one path of mapdata!\n");
return 0;
}
std::string image_path = argv[1];
char* remap_path = argv[2];
cv::Mat src = cv::imread(image_path);
cv::Mat dst;
dst.create(src.size(), src.type());
cv::Mat map2;
map2.create(src.size(), CV_32FC1);
map2.data = NULL;
cv::Mat mapXY;
mapXY.create(src.rows, src.cols, CV_64FC1);
FILE *fp;
fp = fopen(remap_path, "rb");
fread(mapXY.data, sizeof(float), mapXY.cols*mapXY.rows*2, fp);
fclose(fp);
imshow("src", src);
printf("remap!\n");
cv::remap(src, dst, mapXY, map2, cv::INTER_LINEAR);
imshow("dst", dst);
cv::waitKey(0);
return 0;
그러나 나는이 오류가 프로그램을 실행하면
OpenCV Error: Assertion failed (((map1.type() == CV_32FC2 || map1.type() == CV_16SC2) && !map2.data) || (map1.type() == CV_32FC1 && map2.type() == CV_32FC1)) in remap, file /home/liliming/opencv-2.4.13/modules/imgproc/src/imgwarp.cpp, line 3262 terminate called after throwing an instance of 'cv::Exception' what(): /home/liliming/opencv-2.4.13/modules/imgproc/src/imgwarp.cpp:3262: error: (-215) ((map1.type() == CV_32FC2 || map1.type() == CV_16SC2) && !map2.data) || (map1.type() == CV_32FC1 && map2.type() == CV_32FC1) in function remap Aborted (core dumped)
을 내가 그것에 대해 아무 생각이 없습니다. 도와 주시겠습니까? 아니면 샘플 코드를 제공 할 수 있습니까? 대단히 감사합니다.
당신은 [이 답변을] 볼 수 있습니다 (http://stackoverflow.com/questions/10364201/image-transformation-in-opencv) –
고마워, 나는 두 개의 매개 변수 (mapX 및 mapY)를 사용하는 방법을 모르지만 하나의 매개 변수 (mapXY)로지도. –