How can I change the following functions to opencv in java verison

asked 2016-02-29 02:05:11 -0500

cv_new gravatar image
Mat src = imread(argv[1], CV_LOAD_IMAGE_COLOR); 
Mat padded; 
int padding = 5;
padded.create(src.rows + 2 * padding, src.cols + 2 * padding, src.type());
padded.setTo(Scalar::all(255));
src.copyTo(padded(Rect(padding, padding, src.cols, src.rows)));
edit retag flag offensive close merge delete

Comments

sturkmen gravatar imagesturkmen ( 2016-02-29 02:37:20 -0500 )edit

It is in C++ verison. I want to know how to change this "src.copyTo(padded(Rect(padding, padding, src.cols, src.rows)));" to that of java verison. Thanks in advance.

cv_new gravatar imagecv_new ( 2016-02-29 02:47:51 -0500 )edit

example usage :

Core.copyMakeBorder(src, padded, 5, 5, 5, 5,Imgproc.BORDER_CONSTANT, Scalar.all(0));
sturkmen gravatar imagesturkmen ( 2016-02-29 03:02:37 -0500 )edit

I found it with Imgproc.copyMakeBorder(source,destination,top,bottom,left,right,borderType).

cv_new gravatar imagecv_new ( 2016-02-29 19:27:06 -0500 )edit