Repository: opencv
Issue: Ptr_CalibrateDebevec is not defined in the generated file by matlab code generator
Labels: bug,auto-transferred,priority: normal,affected: 3.4,category: matlab bindings

Transferred from http://code.opencv.org/issues/3445

```
|| Yantao Xie on 2013-12-19 06:57
|| Priority: Normal
|| Affected: branch 'master' (3.0-dev)
|| Category: matlab bindings
|| Tracker: Bug
|| Difficulty: 
|| PR: 
|| Platform: x64 / Linux
```
## Ptr_CalibrateDebevec is not defined in the generated file by matlab code generator

```
I compiled the current master branch on Linux. I've got the following errors during compiling the matlab module,
<pre>
CMake Error at /home/xxx/hisstone/opencv/modules/matlab/compile.cmake:47 (message):
  Failed to compile createCalibrateDebevec:
  /home/xxx/hisstone/opencv/build/modules/matlab/src/createCalibrateDebevec.cpp:
  In function ‘void mexFunction(int, mxArray**, int, const mxArray**)’:


  /home/xxx/hisstone/opencv/build/modules/matlab/src/createCalibrateDebevec.cpp:46:3:
  error: ‘Ptr_CalibrateDebevec’ was not declared in this scope
</pre>
I think there missing a statement before the mex function,
@
typedef Ptr<CalibrateDebevec> Ptr_CalibrateDebevec;
@
But this file is generated by python generator and I don't know how to update it.
```
## History
##### Alexander Shishkov on 2013-12-20 12:37

```
-   Assignee set to Alexander Shishkov
-   Category set to photo
```
##### Sergey Zagoruyko on 2013-12-22 14:52

```
brigde.hpp misses photo typedefs and operators.
I did not know how to edit python generator code too so I tried to add the following:

@typedef cv::Ptr<cv::CalibrateDebevec> Ptr_CalibrateDebevec;
    typedef cv::Ptr<cv::CalibrateRobertson> Ptr_CalibrateRobertson;
    typedef cv::Ptr<cv::LineSegmentDetector> Ptr_LineSegmentDetector;
    typedef cv::Ptr<cv::MergeDebevec> Ptr_MergeDebevec;
    typedef cv::Ptr<cv::MergeMertens> Ptr_MergeMertens;
    typedef cv::Ptr<cv::MergeRobertson> Ptr_MergeRobertson;
    typedef cv::Ptr<cv::Tonemap> Ptr_Tonemap;
    typedef cv::Ptr<cv::TonemapDrago> Ptr_TonemapDrago;
    typedef cv::Ptr<cv::TonemapDurand> Ptr_TonemapDurand;
    typedef cv::Ptr<cv::TonemapMantiuk> Ptr_TonemapMantiuk;
    typedef cv::Ptr<cv::TonemapReinhard> Ptr_TonemapReinhard;@

and

@    Bridge& operator=(const Ptr<AlignMTB>& ) { return *this; }
Bridge& operator=(const Ptr<CalibrateDebevec>& ) { return *this; }
Bridge& operator=(const Ptr<CalibrateRobertson>& ) { return *this; }
Bridge& operator=(const Ptr<LineSegmentDetector>& ) { return *this; }
Bridge& operator=(const Ptr<MergeDebevec>& ) { return *this; }
Bridge& operator=(const Ptr<MergeMertens>& ) { return *this; }
Bridge& operator=(const Ptr<MergeRobertson>& ) { return *this; }
Bridge& operator=(const Ptr<Tonemap>& ) { return *this; }
Bridge& operator=(const Ptr<TonemapDrago>& ) { return *this; }
Bridge& operator=(const Ptr<TonemapDurand>& ) { return *this; }
Bridge& operator=(const Ptr<TonemapMantiuk>& ) { return *this; }
Bridge& operator=(const Ptr<TonemapReinhard>& ) { return *this; }@

Reported on Mac OS 10.9 and Ubuntu 12.10

It worked and now I some new errors in findCirclesGrid, but it looks unrelated to this issue
```
##### Donald Venable on 2013-12-23 22:49

```
I was having the same issue, Sergey's fix got me to the same point that he's at. Im compiling on OS X 10.9 (Mavericks), XCode 5. 

Here's my current Error Set: 

<pre>
  Failed to compile findCirclesGrid:
  /Users/venabled/Downloads/opencv/build/modules/matlab/src/findCirclesGrid.cpp:46:56:
  error: conditional expression is ambiguous; 'Ptr<class
  cv::SimpleBlobDetector>' can be converted to 'Ptr<cv::FeatureDetector>' and
  vice versa

    Ptr_FeatureDetector blobDetector = inputs[3].empty() ? makePtr<SimpleBlobDetector>() : inputs[3].toPtrFeatureDetector();
                                                         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  In file included from
  /Users/venabled/Downloads/opencv/build/modules/matlab/src/findCirclesGrid.cpp:14:


  In file included from
  /Users/venabled/Downloads/opencv/modules/matlab/include/opencv2/matlab/bridge.hpp:49:


  In file included from
  /Users/venabled/Downloads/opencv/modules/core/include/opencv2/core.hpp:52:

  In file included from
  /Users/venabled/Downloads/opencv/modules/core/include/opencv2/core/base.hpp:54:


  In file included from
  /Users/venabled/Downloads/opencv/modules/core/include/opencv2/core/cvstd.hpp:906:



  /Users/venabled/Downloads/opencv/modules/core/include/opencv2/core/ptr.inl.hpp:139:48:
  error: cannot initialize a member subobject of type 'cv::SimpleBlobDetector
  *' with an lvalue of type 'cv::FeatureDetector *const'

  Ptr<T>::Ptr(const Ptr<Y>& o) : owner(o.owner), stored(o.stored)

                                                 ^      ~~~~~~~~


  /Users/venabled/Downloads/opencv/build/modules/matlab/src/findCirclesGrid.cpp:46:90:
  note: in instantiation of function template specialization
  'cv::Ptr<cv::SimpleBlobDetector>::Ptr<cv::FeatureDetector>' requested here

    Ptr_FeatureDetector blobDetector = inputs[3].empty() ? makePtr<SimpleBlobDetector>() : inputs[3].toPtrFeatureDetector();
                                                                                           ^

  2 errors generated.



      mex: compile of ' "/Users/venabled/Downloads/opencv/build/modules/matlab/src/findCirclesGrid.cpp"' failed.
</pre>
```
##### Sergey Zagoruyko on 2013-12-27 13:19

```
Fixed it by editing modules/matlab/src/findCirclesGrid.cpp

@//  Ptr_FeatureDetector blobDetector = inputs[3].empty() ? makePtr<SimpleBlobDetector>() : inputs[3].toPtrFeatureDetector();
  Ptr_FeatureDetector blobDetector;
  if (inputs[3].empty())
    blobDetector = makePtr<SimpleBlobDetector> ();
  else
    blobDetector = inputs[3].toPtrFeatureDetector();@

was able to compile but now I have a new error

@>> cv.Rodrigues(eye(3))
Error using cv.Rodrigues
Invalid MEX-file '/opt/opencv/modules/matlab/+cv/Rodrigues.mexa64':
/opt/local/MATLAB/R2013a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by
/opt/opencv/lib/libopencv_calib3d.so.3.0)@
```
##### Hilton Bristow on 2013-12-29 14:28

```
I think that type is new in 3.0, and as such I haven't added a definition for it yet (See #3465). 

Sergey, that libc++ error that you're seeing is non-trivial to solve. Matlab ships its own versions of the standard library (and OpenCV), and preferences them over your system versions in almost all cases. This can cause some dynamically-loaded library hell, and I'm yet to find a bulletproof method of fixing this on all platforms.
```
##### Sergey Zagoruyko on 2013-12-31 12:44

```
Hi Hilton,
Could you please add it?
Finally I was able to run bindings on Mac OS 10.9 & Xcode 5, Ubuntu is still stuck. Anyways it looks impossible to compile bindings in UNIX without additional mexopts.sh setup and manual fixes.

There is another bug at modules/matlab/CMakeLists.txt:107

@prepend("-L" MEX_LIB_DIR  ${LIBRARY_OUTPUT_PATH}/$<CONFIGURATION>)@

looks like /$<CONFIGURATION> prefix should work in Windows but not UNIX, there should be an if statement for different platforms. Sorry I cannot do pull requests.
```
##### Anna Kogan on 2014-01-13 09:31

```
-   Status changed from New to Open
```
##### Riddhiman Dasgupta on 2014-02-28 10:19

```
Sergey Zagoruyko wrote:
> brigde.hpp misses photo typedefs and operators.
> I did not know how to edit python generator code too so I tried to add the following:
> 
> @typedef cv::Ptr<cv::CalibrateDebevec> Ptr_CalibrateDebevec;
>     typedef cv::Ptr<cv::CalibrateRobertson> Ptr_CalibrateRobertson;
>     typedef cv::Ptr<cv::LineSegmentDetector> Ptr_LineSegmentDetector;
>     typedef cv::Ptr<cv::MergeDebevec> Ptr_MergeDebevec;
>     typedef cv::Ptr<cv::MergeMertens> Ptr_MergeMertens;
>     typedef cv::Ptr<cv::MergeRobertson> Ptr_MergeRobertson;
>     typedef cv::Ptr<cv::Tonemap> Ptr_Tonemap;
>     typedef cv::Ptr<cv::TonemapDrago> Ptr_TonemapDrago;
>     typedef cv::Ptr<cv::TonemapDurand> Ptr_TonemapDurand;
>     typedef cv::Ptr<cv::TonemapMantiuk> Ptr_TonemapMantiuk;
>     typedef cv::Ptr<cv::TonemapReinhard> Ptr_TonemapReinhard;@
> 
> and
> 
> @    Bridge& operator=(const Ptr<AlignMTB>& ) { return *this; }
> Bridge& operator=(const Ptr<CalibrateDebevec>& ) { return *this; }
> Bridge& operator=(const Ptr<CalibrateRobertson>& ) { return *this; }
> Bridge& operator=(const Ptr<LineSegmentDetector>& ) { return *this; }
> Bridge& operator=(const Ptr<MergeDebevec>& ) { return *this; }
> Bridge& operator=(const Ptr<MergeMertens>& ) { return *this; }
> Bridge& operator=(const Ptr<MergeRobertson>& ) { return *this; }
> Bridge& operator=(const Ptr<Tonemap>& ) { return *this; }
> Bridge& operator=(const Ptr<TonemapDrago>& ) { return *this; }
> Bridge& operator=(const Ptr<TonemapDurand>& ) { return *this; }
> Bridge& operator=(const Ptr<TonemapMantiuk>& ) { return *this; }
> Bridge& operator=(const Ptr<TonemapReinhard>& ) { return *this; }@
> 
> Reported on Mac OS 10.9 and Ubuntu 12.10
> 
> It worked and now I some new errors in findCirclesGrid, but it looks unrelated to this issue


I tried this, and it gave rise to a ton of new errors to the tune of:

@TonemapReinhard is not defined in this scope
Bridge& operator=(const int&) cannot be overloaded
error: invalid conversion from ‘cv::MergeMertens*’ to
  ‘cv::bridge::Ptr_MergeMertens {aka int}’ [-fpermissive]@

The findCirclesGrid file also gave a few errors, but they were resolved by using Sergey's suggestions. Compilation did not progress though, due to the above errors.
Is there something I'm doing wrong while compiling the MATLAB module?
```
##### Vadim Pisarevsky on 2015-05-14 16:54

```
-   Category changed from photo to matlab bindings
```