opencv - save an image in a complete path -
i using opencv library , visual studio 2013. save result image in complete path. it's ok same path c:\\...
doesn't work. tried use both forward \
, /
, result looked same. here code:
#include<iostream> #include<opencv2/imgproc/imgproc.hpp> #include<opencv2/highgui/highgui.hpp> using namespace std; using namespace cv; int main() { mat src, dst; float sum; /// load image src = imread("lena.jpg", cv_load_image_grayscale); if (!src.data) { return -1; } // define kernel float kernel[3][3] = { { 1 / 9.0, 1 / 9.0, 1 / 9.0 }, { 1 / 9.0, 1 / 9.0, 1 / 9.0 }, { 1 / 9.0, 1 / 9.0, 1 / 9.0 } }; dst = src.clone(); (int y = 0; y < src.rows; y++) (int x = 0; x < src.cols; x++) dst.at<uchar>(y, x) = 0.0; //convolution operation (int y = 1; y < src.rows - 1; y++){ (int x = 1; x < src.cols - 1; x++){ sum = 0.0; (int k = -1; k <= 1; k++){ (int j = -1; j <= 1; j++){ sum = sum + kernel[j + 1][k + 1] * src.at<uchar>(y - j, x - k); } } dst.at<uchar>(y, x) = sum; } } namedwindow("final"); imshow("final", dst); namedwindow("initial"); imshow("initial", src); vector<int> compression_params; //vector stores compression parameters of image compression_params.push_back(cv_imwrite_jpeg_quality); //specify compression technique compression_params.push_back(100); //specify compression quality bool bsuccess = imwrite("filtre.jpg", dst, compression_params);//ok bool bsucccess = imwrite("d:/trunk/jpwl/release/nouveau_dossier/filtre.jpg", dst, compression_params);// not ok bool bsuccces = imwrite("d:\trunk\jpwl\release\nouveau_dossier\filtre.jpg", dst, compression_params);// not ok waitkey(); return 0; }
use: "d:\trunk\jpwl\release\nouveau_dossier\filtre.jpg" (with double backslash, stackoverflow shows single backslash)
or
@"d:/trunk/jpwl/release/nouveau_dossier/filtre.jpg" instead. single \ esc character.
dick
Comments
Post a Comment