image - opencv setting submat of Mat to another Mat -


i having problems using setto() method. code follows:

arraylist<mat> someimagesofsamesize = new arraylist<mat>; someimagesofsamesize.add(img1); someimagesofsamesize.add(img3); someimagesofsamesize.add(img3); mat combinedimagesofsamesize = new mat(new range(0,30), new range(0,100*someimagesofsamesize.size()),3); mat tempimage = null; for(int = 0; someimagesofsamesize.size();i++){     tempimage = someimagesofsamesize.get(i);     combinedimagesofsamesize.submat(new range(0,30), new range(i*100,(i+1)*100)).setto(tempimage) } 

it gives me following opencv error:

*opencv error: assertion failed (checkscalar(value, type(), _value.kind(), _inputarray::mat )) in
unknown function, file ......\src\opencv\modules\core\src\copy.cpp, line 348 exception in thread "main" cvexception [org.opencv.core.cvexception: ......\src\opencv\modules\core\src\copy.cpp:348: error: (-215) checkscalar(value, type(), _value.kind(), _inputarray::mat )] @ org.opencv.core.mat.n_setto(native method) @ org.opencv.core.mat.setto(mat.java:2164)*

what want simple: take 1 image @ time, write combined image, shift columns right , on. since have same size should possible. point out why doesn't work ?

having studied opencv java api more thoroughly found out that, contructor mat(range rowrange, range colrange, int type) misused code, because "type" here refers cvtype. means have supply image type mat going resemble. set value "cvtype.cv_8uc3", since "someimagesofsamesize"-images 3-channel 8-bit png-files.

another thing, have changed is, using copyto()-method write submatrix of combined-image, code inside loop changes to:

tempsamesizeimage.copyto(combinedsamesizeimages.submat(                 new range(0, 61), new range(i * 160, (i + 1) * 160))); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -