Ask Your Question
0

About GpuMat

asked 2013-01-15 01:56:35 -0500

light gravatar image

updated 2013-01-15 02:02:59 -0500

Hi all,

I wonder to know that is there a way to set a GpuMatrix elements to specified value?Just like CV_MAT_ELEM in cpu.I read the documentation,but cannot solve it.Can someone help me with it,Your help is much appreciated!

Best regards,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-01-15 02:05:44 -0500

Vladislav Vinogradov gravatar image

You can't access GpuMat element in cpu code. You should create Mat object first, fill it and upload it to gpu memory:

Mat host_mat(rows, cols, type);
// fill host_mat
GpuMat dev_mat;
dev_mat.upload(host_mat);

If you want to fill GpuMat with some value (ex. zero) you can use setTo method:

GpuMat dev_mat(rows, cols, type);
dev_mat.setTo(Scalar::all(0));
edit flag offensive delete link more

Comments

But if I want to sets dev_mat[0,0] to 0 and dev_mat[0,0] to 1 in gpu what should I do.

light gravatar imagelight ( 2013-01-15 02:22:43 -0500 )edit

Fill Mat object and upload it to gpu

Vladislav Vinogradov gravatar imageVladislav Vinogradov ( 2013-01-15 02:34:16 -0500 )edit

The code like this: for(...) { CV_MAT_ELEM(A0,float,0,0) = u1ProjectMatrixPara1[8] - ProjectMatrixPara1[0]; ....... CV_MAT_ELEM(B0,float,0,0) = ProjectMatrixPara1[3] - u1ProjectMatrixPara1[11]; ....... cvSolve(A0,B0,X0,CV_SVD); ResultPt3D.x = CV_MAT_ELEM( *X0, float, 0, 0 ) ; ..... Pts3D.push_back(ResultPt3D); }

I want put it into gpu,is there any way to solve it?

light gravatar imagelight ( 2013-01-15 02:43:12 -0500 )edit

LeftPoint = LeftPoints.at(i); u1 = (LeftPoint.x-cx1)/sx1;

light gravatar imagelight ( 2013-01-15 02:45:12 -0500 )edit

What if I have to access elements of GpuMat frequently? Upload Mat to GpuMat is too slow... I would appreciate if you could have a look at this question.

Summer Sun gravatar imageSummer Sun ( 2017-08-01 07:11:00 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-01-15 01:56:35 -0500

Seen: 2,267 times

Last updated: Jan 15 '13