Ask Your Question
0

C++ Function Declaration for Matrix

asked 2014-09-06 06:34:36 -0600

Icetray gravatar image

Hi Guys,

I tend to write my functions at the end of my main functions. I'm having a little trouble making my function declarations a little neater.

Lets say my function is:

void function(int height, int width, Mat matrix, Mat  matrix2, string stringName){
//code
}

I tried declaring

void function(int, int, Mat, Mat, string);

but this doesn't work. How do you put the argument for a matrix?

Thanks in advance guys!

edit retag flag offensive close merge delete

Comments

what are you using? windows? On ubuntu 14, kdevelop it works nice with function(1,2,cv::Mat(),cv::Mat(),""); Is it a function in a class? How do you call it? Is it called in another part of the code where you have not include the header where the function is declared?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-09-08 04:58:31 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-09-08 04:45:04 -0600

jamesnzt gravatar image

updated 2014-09-08 04:46:05 -0600

You can define it as

void func(int, int, Mat, Mat, string);

I tried it works.The error may be due to the function name dont use "function" instead use another name. i tried

"void func(int,int,mat,mat);"

it works!!!

edit flag offensive delete link more

Comments

Strange doesn't work for me. I keep getting the error messages: Error 16 error LNK1120: 1 unresolved externals C:\Users\Administrator\Robot.exe Robot Error 15 error LNK2019: unresolved external symbol "void __cdecl identifyObject(int,int,class cv::Mat,class cv::Mat,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?identifyObject@@YAXHHVMat@cv@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main C:\Users\Administrator\Robot\main.obj Robot

I'm using Visual Studio on Windows 7 if it makes a difference. :) The function name was just an example...all my functions can't be made neater when a Mat is one of the variables. It's not that important but it just bugs my inner OCD haha

Icetray gravatar imageIcetray ( 2014-09-17 23:29:27 -0600 )edit

if you post the code may be some can give idea

jamesnzt gravatar imagejamesnzt ( 2014-09-18 01:13:58 -0600 )edit

Just wanted to drop you guys an update. Worked for me on another program I was working on. Strange. Must have been Visual Studio being difficult.

Icetray gravatar imageIcetray ( 2014-12-03 04:58:43 -0600 )edit
2

answered 2014-09-06 09:42:53 -0600

"but this doesn't work."

is the WORST error description. What happens? Which error messages do you get? It is possible to pass a Matrix as you write it (assuming you have an "using namespace cv;" somewhere). Your declaration is however rather bad style, I'd suggest to change it to const&, so that your matrices won't be copied.

edit flag offensive delete link more

Comments

Error Messages: Error 16 error LNK1120: 1 unresolved externals Error 15 error LNK2019: unresolved external symbol "void __cdecl identifyObject(int,int,class cv::Mat,class cv::Mat,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?identifyObject@@YAXHHVMat@cv@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

My question is not how to write my functions but how to do function declarations before my main program when Mat is one of the arguments.

Icetray gravatar imageIcetray ( 2014-09-07 03:26:00 -0600 )edit

Could you show your original code?

FooBar gravatar imageFooBar ( 2014-09-07 07:17:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-06 06:34:36 -0600

Seen: 509 times

Last updated: Sep 08 '14