Skip to content

Conversation

@garfeng
Copy link

@garfeng garfeng commented Aug 2, 2021

F:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.3.0/../../../../i686-w64-mingw32/bin/ld.exe: ../../lib/libcorrespondence.a(nRobustViewMatching.cc.obj):nRobustViewMatching.cc:(.text$_ZN5libmv14correspondence19nRobustViewMatching11computeDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3b): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)'

The sfm uses imread, but opencv_imgcodecs was not added to it's CMakeLists.txt

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

F:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.3.0/../../../../i686-w64-mingw32/bin/ld.exe: ../../lib/libcorrespondence.a(nRobustViewMatching.cc.obj):nRobustViewMatching.cc:(.text$_ZN5libmv14correspondence19nRobustViewMatching11computeDataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x3b): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
@alalek
Copy link
Member

alalek commented Aug 2, 2021

imread usage should be removed instead.
Generic OpenCV modules should not depend on I/O modules.

@garfeng
Copy link
Author

garfeng commented Aug 2, 2021

Will anyone fix the issue ?

nRobustViewMatching.cc in sfm still uses imread.

File: opencv_contrib-4.5.3\modules\sfm\src\libmv_light\libmv\correspondence\nRobustViewMatching.cc

Line: 53

Use param of cv::Mat instead ?

/**
 * Compute the data and store it in the class map<string,T>
 *
 * \param[in] filename   The file from which the data will be extracted.
 *
 * \return True if success.
 */
bool nRobustViewMatching::computeData(const string & filename)
{
  cv::Mat im_cv = cv::imread(filename, 0);
  if (im_cv.empty()) {
    LOG(FATAL) << "Failed loading image: " << filename;
    return false;
  }
  else
  {
    libmv::vector<libmv::Feature *> features;
    std::vector<cv::KeyPoint> features_cv;
    m_pDetector->detect( im_cv, features_cv );
    features.resize(features_cv.size());
    for(size_t i=0; i<features_cv.size(); ++i)
      features[i] = new libmv::PointFeature(features_cv[i]);

    cv::Mat descriptors;
    m_pDescriber->compute(im_cv, features_cv, descriptors);

    // Copy data.
    m_ViewData.insert( make_pair(filename,FeatureSet()) );
    FeatureSet & KeypointData = m_ViewData[filename];
    KeypointData.features.resize(descriptors.rows);
    for(int i = 0;i < descriptors.rows; ++i)
    {
      KeypointFeature & feat = KeypointData.features[i];
      descriptors.row(i).copyTo(feat.descriptor);
      *(PointFeature*)(&feat) = *(PointFeature*)features[i];
    }

    DeleteElements(&features);

    return true;
  }
}

@alalek
Copy link
Member

alalek commented Aug 2, 2021

Use param of cv::Mat instead

Right.
Computer Vision library should not be limited on work with files only.
Usually data comes from cameras or other sources. cv::Mat is a generic type to handle any input.


But it is a separate big enough task ("string" is a part of public API for now so it can't be easily changed for now - breaking change).

add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src/libmv_light" "${CMAKE_CURRENT_BINARY_DIR}/src/libmv")

ocv_target_link_libraries(${the_module} ${LIBMV_LIGHT_LIBS})
ocv_target_link_libraries(${the_module} ${LIBMV_LIGHT_LIBS} opencv_imgcodecs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the line 114 there is already included opencv_imgcodecs dependency of the module. No need to duplicate that.

More details are required:

  • failed command line via make VERBOSE=1 (without any -j option)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we need dependency for libmv library instead of opencv sfm module.

Try to modify this line instead:
https://github.com/opencv/opencv_contrib/blob/4.5.3/modules/sfm/CMakeLists.txt#L98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants