0

i have work on code for recognition hand gesture using Hu Moment extraction feature, from here enter link description here but I have a problem for declaring an array

int matchTheState(vector<Point> present_hand_state, vector<vector<Point > > MyContours)
{
double array[MyContours.size()];

while the contents of the vector<vector<point>> MyContours is an image declaration that is used as a comparison value.

the error said:

expression must have constant value (cannot call non-constecxpr function...)
function call must have a constant value in a constant expression

1 Answers1

0

In C++ array bounds must be compile time constants. MyContours.size() is not a compile time constant. Just use a vector instead.

vector<double> array(MyContours.size());
john
  • 85,011
  • 4
  • 57
  • 81
  • yes it work to eliminate the errors. but when i start to debug, a notification appears that Debug Assertion Failed! Vector subscript out of range. – Riris Eka S Apr 28 '20 at 05:04
  • @RirisEkaS OK, well that just means you have a bug in your code. Since I can't see the code I can't say what the bug is. If your can't figure it out make a new question and include the code that crashes. – john Apr 28 '20 at 05:24
  • may I send you the whole code? so you can tell me what the bug is. would be so happy if you want to help me sir:( – Riris Eka S Apr 28 '20 at 05:36
  • Sir, this is my new question about debug problems https://stackoverflow.com/questions/61474002/error-when-debug-debug-assertion-failed-vector-subscript-out-of-range – Riris Eka S Apr 28 '20 at 06:34