2

I'm trying to make an iOS app that can detect Aruco markers. So, I downloaded opencv2.framework for iOS, but I realized that Aruco is not included in that. Following this page, I compiled manually adding opencv_contrib (https://github.com/opencv/opencv_contrib.git) module folder into the opencv module folder. This process worked fine and in Xcode I can access Aruco functions. But I also get this strange error: functional-style cast xcode error

I've tried debugging and runtime v is passed as a double variable. The explicit cast (double)v is not valid too. How can I fix this?

iehrlich
  • 3,572
  • 4
  • 34
  • 43
keyblade95
  • 329
  • 3
  • 11
  • The type `id` is a pointer to an Objective-C object (class); What are you trying to accomplish by casting it to the scalar type `double`? – Nicolas Miari Apr 17 '17 at 08:18
  • I think _Tp() expects a double type as argument, but I don't know why the param is declared as generic T2 – keyblade95 Apr 17 '17 at 08:55
  • I don't know anything about generics in C++, but yeah, there's a type mismatch between `id` and `double` (or at least that's what Xcode thinks)... perhaps an error on the side of the code that uses this template? Wild guess... It's not your code anyway, right? – Nicolas Miari Apr 17 '17 at 08:58
  • Yep, the code is right from this file: [mat.inl.hpp](https://github.com/opencv/opencv/blob/master/modules/core/include/opencv2/core/mat.inl.hpp) and I suppose that only Xcode treat it like a cast error... I get this error without any lines of code that uses that operator. – keyblade95 Apr 17 '17 at 09:20

1 Answers1

0

I found the problem. It was another piece of code that called the operator, without explicit casting the params. It was:

NSArray *camMatrix = ...
...
Mat cameraMatrix = (Mat_<double>(3,3) << camMatrix[0], camMatrix[1], camMatrix[2],
                camMatrix[3], camMatrix[4], camMatrix[5],
                camMatrix[6], camMatrix[7], camMatrix[8] );

Just casted [camMatrix[0] doubleValue] like so:

NSArray *camMatrix = ...
...
Mat cameraMatrix = (Mat_<double>(3,3) << [camMatrix[0] doubleValue], [camMatrix[1] doubleValue], [camMatrix[2] doubleValue],
                [camMatrix[3] doubleValue], [camMatrix[4] doubleValue], [camMatrix[5] doubleValue],
                [camMatrix[6] doubleValue], [camMatrix[7] doubleValue], [camMatrix[8] doubleValue] );
keyblade95
  • 329
  • 3
  • 11