cvg / pyceres Goto Github PK
View Code? Open in Web Editor NEWFactor graphs with Ceres in Python
License: Apache License 2.0
Factor graphs with Ceres in Python
License: Apache License 2.0
Thanks for this awesome wrapping library for ceres.
In #20, you said:
We don't provide any way to write cost functions in Python.
However, I have noticed that PyCostFunction
already provides the corresponding trampoline functionality. The only thing that needs to be added is the encapsulation of set_num_residuals()
. Which is done as follows:
.def("set_num_residuals", &PyCostFunction::set_num_residuals)
After adding it, I tested the helloworld CostFunction in Python. It seems ok.
class HelloworldCost(pyceres.CostFunction):
def __init__(self):
pyceres.CostFunction.__init__(self)
self.set_num_residuals(1)
self.set_parameter_block_sizes([1])
def Evaluate(self, parameters, residuals, jacobians):
# ref: examples/helloworld_analytic_diff.cc
x = parameters[0][0]
residuals[0] = 10. - x
if jacobians is not None:
jacobians[0][0] = -1.
return True
def test_python_cost():
x = np.array(5.0)
prob = pyceres.Problem()
cost = HelloworldCost()
loss = pyceres.TrivialLoss()
prob.add_residual_block(cost, loss, [x])
opts = pyceres.SolverOptions()
opts.minimizer_progress_to_stdout = True
summary = pyceres.SolverSummary()
pyceres.solve(opts, prob, summary)
print(summary.BriefReport())
print(x)
The output is:
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 1.250000e+01 0.00e+00 5.00e+00 0.00e+00 0.00e+00 1.00e+04 0 4.41e-05 1.08e-04
1 1.249750e-07 1.25e+01 5.00e-04 5.00e+00 1.00e+00 3.00e+04 1 6.51e-05 2.06e-04
2 1.388518e-16 1.25e-07 1.67e-08 5.00e-04 1.00e+00 9.00e+04 1 2.88e-05 2.45e-04
Ceres Solver Report: Iterations: 3, Initial cost: 1.250000e+01, Final cost: 1.388518e-16, Termination: CONVERGENCE
9.999999983335556
I am not sure if this approach has any issues or if it can be scaled to larger problems.
Looking forward to your comments.
Hi, i've installed Ceres,Colmap,and met this error:
pip install -e .
× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [145 lines of output]
running develop
/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running egg_info
writing pyceres.egg-info/PKG-INFO
writing dependency_links to pyceres.egg-info/dependency_links.txt
writing requirements to pyceres.egg-info/requires.txt
writing top-level names to pyceres.egg-info/top_level.txt
reading manifest file 'pyceres.egg-info/SOURCES.txt'
writing manifest file 'pyceres.egg-info/SOURCES.txt'
running build_ext
-- Found METIS: /usr/include (found suitable version "5.1.0", minimum required is "5.1.0")
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found SPQR headers in: /usr/include/suitesparse
-- Found SPQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Config headers in: /usr/include/suitesparse
-- Found Config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found Intel Thread Building Blocks (TBB) library (2020.1 / 11101) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS: /usr/include (found version "5.1.0")
-- Found required Ceres dependency: Eigen version 3.4.0 in /usr/local/share/eigen3/cmake
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, SchurSpecializations, Multithreading]
-- Found METIS: /usr/include (found suitable version "5.1.0", minimum required is "5.1.0")
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found SPQR headers in: /usr/include/suitesparse
-- Found SPQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Config headers in: /usr/include/suitesparse
-- Found Config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found Intel Thread Building Blocks (TBB) library (2020.1 / 11101) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS: /usr/include (found version "5.1.0")
-- Found required Ceres dependency: Eigen version 3.4.0 in /usr/local/share/eigen3/cmake
CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library):
add_library cannot create imported target "glog::glog" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:248 (find_package)
/usr/local/share/colmap/COLMAPConfig.cmake:92 (find_package)
CMakeLists.txt:14 (find_package)
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, SchurSpecializations, Multithreading]
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: program_options filesystem system unit_test_framework
-- Found Eigen
-- Includes : /usr/local/include/eigen3
-- Found FreeImage
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
CMake Warning (dev) at /usr/local/share/cmake-3.21/Modules/FindOpenGL.cmake:315 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
FindOpenGL found both a legacy GL library:
OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so
and GLVND libraries for OpenGL and GLX:
OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so
OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
/usr/local/share/colmap/COLMAPConfig.cmake:109 (find_package)
CMakeLists.txt:14 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Glew
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Using gcc version 4 or later. Adding -frounding-math
-- pybind11 v2.8.1
-- Configuring incomplete, errors occurred!
See also "/home/xxx/pyceres/build/temp.linux-x86_64-cpython-39/CMakeFiles/CMakeOutput.log".
See also "/home/xxx/pyceres/build/temp.linux-x86_64-cpython-39/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/home/xxx/pyceres/setup.py", line 80, in <module>
setup(
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
self.run_command(cmd)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/command/develop.py", line 34, in run
self.install_for_development()
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/command/develop.py", line 114, in install_for_development
self.run_command('build_ext')
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/home/xxx/pyceres/setup.py", line 34, in run
self.build_extension(ext)
File "/home/xxx/pyceres/setup.py", line 76, in build_extension
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
File "/home/xxx/anaconda3/envs/torch/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/home/xxx/pyceres', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/xxx/pyceres', '-DPYTHON_EXECUTABLE=/home/xxx/anaconda3/envs/torch/bin/python', '-DVERSION_INFO=0.0.0', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
['cmake', '/home/xxx/pyceres', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/xxx/pyceres', '-DPYTHON_EXECUTABLE=/home/xxx/anaconda3/envs/torch/bin/python', '-DVERSION_INFO=0.0.0', '-DCMAKE_BUILD_TYPE=Release']
[end of output]
Enviroment:
Ubuntu20.04
cmake 3.21.6
gcc 9.4.0(out of conda)
gcc 12.2.0(conda)
CMake Error at CMakeLists.txt:7 (find_package):
Found package configuration file:
/usr/local/share/colmap/COLMAPConfig.cmake
but it set COLMAP_FOUND to FALSE so package "COLMAP" is considered to be
NOT FOUND.
Thanks for the nice project! I am trying to follow examples/test_BA.ipynb
, but it seems that cost_functions
is not pycolmap
attribute anymore (I install pycolmap through pip install pycolmap
directly, in a clean python 3.10 conda environment).
I tried to look around in the pycolmap repo, and I didn't see cost_functions
in it. I'd appreciate it if you could help me to find those pre-defined cost functions. Thanks in advance!
Hello,
Could you add a LICENSE file please? Thank you
I installed gflags (sudo), and glog (version 0.6.0, installed using source code compilation), then installed Ceres Solver (latest) using source code compilation, and then installed pyceres (clone and python -m pip install .) then installed colmap (latest version) and finally pycolmap. I ran the test_BA.ipynb of examples in pycharm, and the following error occurred:
ImportError Traceback (most recent call last)
Cell In[1], line 3
1 get_ipython().run_line_magic('load_ext', 'autoreload')
2 get_ipython().run_line_magic('autoreload', '2')
----> 3 import pyceres
4 import pycolmap
5 import numpy as np
ImportError: libglog.so.1: cannot open shared object file: No such file or directory
A recent commit to COLMAP moved colmap/base/camera_models.h
to colmap/camera/models.h
, breaking bundle.cc. Modifying pyceres/_pyceres/factors/bundle.cc
from
#include <colmap/base/camera_models.h>
to
#include <colmap/camera/models.h>
Allows installation to proceed.
hello, the sixth line of the 'examples/test_BA.ipynb' is 'from hloc.utils import viz_3d',I would like to ask, where is the hloc?
Hello, thanks for sharing your code.
I've tried to install pyceres but got next output
Obtaining file:///home/daddywesker/3rdPrtyLibs/pyceres
Requirement already satisfied: numpy in /home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages (from pyceres==0.0.0) (1.21.5)
Installing collected packages: pyceres
Running setup.py develop for pyceres
ERROR: Command errored out with exit status 1:
command: /home/daddywesker/anaconda3/envs/AvatarCLIP/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/daddywesker/3rdPrtyLibs/pyceres/setup.py'"'"'; __file__='"'"'/home/daddywesker/3rdPrtyLibs/pyceres/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
cwd: /home/daddywesker/3rdPrtyLibs/pyceres/
Complete output (181 lines):
running develop
running egg_info
creating pyceres.egg-info
writing pyceres.egg-info/PKG-INFO
writing dependency_links to pyceres.egg-info/dependency_links.txt
writing requirements to pyceres.egg-info/requires.txt
writing top-level names to pyceres.egg-info/top_level.txt
writing manifest file 'pyceres.egg-info/SOURCES.txt'
reading manifest file 'pyceres.egg-info/SOURCES.txt'
writing manifest file 'pyceres.egg-info/SOURCES.txt'
running build_ext
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found METIS: /usr/include (found suitable version "5.1.0", minimum required is "5.1.0")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found SPQR headers in: /usr/include/suitesparse
-- Found SPQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Config headers in: /usr/include/suitesparse
-- Found Config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found Intel Thread Building Blocks (TBB) library (2020.1 / 11101) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS: /usr/include (found version "5.1.0")
-- Looking for cholmod_metis
-- Looking for cholmod_metis - found
-- Found SuiteSparse: /usr/include/suitesparse (found suitable version "5.7.1", minimum required is "5.7.1") found components: AMD CAMD CCOLAMD CHOLMOD COLAMD SPQR Config
-- Found CUDAToolkit: /usr/local/cuda-11.3/include (found suitable version "11.3.58", minimum required is "11.3.58")
-- Found required Ceres dependency: Eigen version 3.3.7 in /usr/lib/cmake/eigen3
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, SchurSpecializations, Multithreading]
-- Found METIS: /usr/include (found suitable version "5.1.0", minimum required is "5.1.0")
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found SPQR headers in: /usr/include/suitesparse
-- Found SPQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Config headers in: /usr/include/suitesparse
-- Found Config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found Intel Thread Building Blocks (TBB) library (2020.1 / 11101) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS: /usr/include (found version "5.1.0")
-- Found required Ceres dependency: Eigen version 3.3.7 in /usr/lib/cmake/eigen3
CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library):
add_library cannot create imported target "glog::glog" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:248 (find_package)
/usr/local/share/colmap/COLMAPConfig.cmake:92 (find_package)
CMakeLists.txt:14 (find_package)
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, SchurSpecializations, Multithreading]
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: program_options filesystem system unit_test_framework
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0")
-- Found Eigen
-- Includes : /usr/include/eigen3
-- Found FreeImage
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
CMake Warning (dev) at /opt/cmake-3.22.0-linux-x86_64/share/cmake-3.22/Modules/FindOpenGL.cmake:315 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
FindOpenGL found both a legacy GL library:
OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so
and GLVND libraries for OpenGL and GLX:
OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so
OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
/usr/local/share/colmap/COLMAPConfig.cmake:109 (find_package)
CMakeLists.txt:14 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found Glew
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Found GMP: /usr/local/lib/libgmp.so
-- Found MPFR: /usr/local/lib/libmpfr.so
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.48")
-- Boost include dirs: /usr/include
-- Boost libraries:
-- Using gcc version 4 or later. Adding -frounding-math
-- pybind11 v2.8.1
-- Found PythonInterp: /home/daddywesker/anaconda3/envs/AvatarCLIP/bin/python (found version "3.7.13")
-- Found PythonLibs: /home/daddywesker/anaconda3/envs/AvatarCLIP/lib/libpython3.7m.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Configuring incomplete, errors occurred!
See also "/home/daddywesker/3rdPrtyLibs/pyceres/build/temp.linux-x86_64-3.7/CMakeFiles/CMakeOutput.log".
See also "/home/daddywesker/3rdPrtyLibs/pyceres/build/temp.linux-x86_64-3.7/CMakeFiles/CMakeError.log".
['cmake', '/home/daddywesker/3rdPrtyLibs/pyceres', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/daddywesker/3rdPrtyLibs/pyceres', '-DPYTHON_EXECUTABLE=/home/daddywesker/anaconda3/envs/AvatarCLIP/bin/python', '-DVERSION_INFO=0.0.0', '-DCMAKE_BUILD_TYPE=Release']
/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/command/easy_install.py:147: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
EasyInstallDeprecationWarning,
/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/daddywesker/3rdPrtyLibs/pyceres/setup.py", line 91, in <module>
install_requires=['numpy'],
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/dist.py", line 1214, in run_command
super().run_command(command)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/command/develop.py", line 34, in run
self.install_for_development()
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/command/develop.py", line 114, in install_for_development
self.run_command('build_ext')
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/dist.py", line 1214, in run_command
super().run_command(command)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/home/daddywesker/3rdPrtyLibs/pyceres/setup.py", line 34, in run
self.build_extension(ext)
File "/home/daddywesker/3rdPrtyLibs/pyceres/setup.py", line 76, in build_extension
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
File "/home/daddywesker/anaconda3/envs/AvatarCLIP/lib/python3.7/subprocess.py", line 363, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/home/daddywesker/3rdPrtyLibs/pyceres', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/daddywesker/3rdPrtyLibs/pyceres', '-DPYTHON_EXECUTABLE=/home/daddywesker/anaconda3/envs/AvatarCLIP/bin/python', '-DVERSION_INFO=0.0.0', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
----------------------------------------
ERROR: Command errored out with exit status 1: /home/daddywesker/anaconda3/envs/AvatarCLIP/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/daddywesker/3rdPrtyLibs/pyceres/setup.py'"'"'; __file__='"'"'/home/daddywesker/3rdPrtyLibs/pyceres/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
In one of the logs error mentioned
/usr/bin/ld: CMakeFiles/cmTC_29694.dir/CheckFunctionExists.c.o: in function `main':
CheckFunctionExists.c:(.text+0x14): undefined reference to `sgemm_'
I've tried to add
find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED)
target_link_libraries(pyceres PRIVATE ${PYCERES_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
in CMakeLists.txt as it suggested on some sites for this problem but it doesn't help. Any suggestions?
I'm on Linux Mint 20, forgot to say.
Describe the bug
Pyceres build fails in dockerfile
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Pyceres successfully builds.
Additional context
Running on Ubuntu 22.04 Server with RTX 3060. NVCTK is installed along with appropriate CUDA toolkit and NVIDIA drivers.
See Log for full error here
Dockerfile_log.txt
I build the latest versions of pyceres (pyceres-2.2) and pycolmap (pycolmap-3.10.dev0) from source. When I import both packages I get: F0530 14:42:58.538602 578096 utilities.cc:346] Check failed: !IsGoogleLoggingInitialized() You called InitGoogleLogging() twice!
.
I'm very sorry to bother you, but I encountered an error while Cmake, indicating that it's related to CUDA. However, I've been searching for a long time but still can't solve this problem. Does anyone know how to solve it?
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found METIS: /usr/include (found suitable version "5.1.0", minimum required is "5.1.0")
-- Found AMD headers in: /usr/include/suitesparse
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found CAMD headers in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CCOLAMD headers in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CHOLMOD headers in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found COLAMD headers in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found SPQR headers in: /usr/include/suitesparse
-- Found SPQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found Config headers in: /usr/include/suitesparse
-- Found Config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found Intel Thread Building Blocks (TBB) library (2020.1 / 11101) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Adding librt to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Found METIS: /usr/include (found version "5.1.0")
-- Looking for cholmod_metis
-- Looking for cholmod_metis - found
-- Found SuiteSparse: /usr/include/suitesparse (found suitable version "5.7.1", minimum required is "5.7.1") found components: AMD CAMD CCOLAMD CHOLMOD COLAMD SPQR Config
-- Found required Ceres dependency: Eigen version 3.4.0 in /usr/local/share/eigen3/cmake
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, SchurSpecializations]
-- Found Python: /home/tang/anaconda3/envs/colmap/bin/python3.8 (found version "3.8.19") found components: Interpreter Development.Module
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Found pybind11: /usr/local/include (found version "2.13.0dev1")
-- Configuring done (1.4s)
CMake Error at /usr/local/lib/cmake/Ceres/CeresTargets.cmake:59 (set_target_properties):
The link interface of target "Ceres::ceres" contains:
CUDA::cublas
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:272 (include)
CMakeLists.txt:11 (find_package)
-- Generating done (0.0s)
CMake Generate step failed. Build files cannot be regenerated correctly.
Hi,
Is there a way to create own class of costFunction? I tried but it seems there is no set_num_residuals member function.
May I know if it is possible?
now colmap updated so need modification in bundle.cc
for example,
colmap/camera/models.h isn't in that directory but in colmap/sensor/models.h
because of that pyceres build error i currently can't build pixel-perfect-sfm :(
Hi @sarlinpe,
I run into this compile issue when trying to compile for glog 0.7 (I saw #36 and we use pyceres 2.1.0):
2024-02-18T23:39:35.0878726Z [ 50%] Building CXX object CMakeFiles/pyceres.dir/_pyceres/bindings.cc.o
2024-02-18T23:39:39.6546867Z In file included from /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/helpers.h:3,
2024-02-18T23:39:39.6548492Z from /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/core/cost_functions.h:3,
2024-02-18T23:39:39.6549613Z from /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/core/bindings.h:4,
2024-02-18T23:39:39.6551543Z from /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/bindings.cc:1:
2024-02-18T23:39:39.6552850Z /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/logging.h: In instantiation of 'LogMessageFatalThrow<T>::LogMessageFatalThrow(const char*, int, const google::logging::internal::CheckOpString&) [with T = std::invalid_argument]':
2024-02-18T23:39:39.6553874Z /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/core/cost_functions.h:116:13: required from here
2024-02-18T23:39:39.6554416Z /home/conda/feedstock_root/build_artifacts/pyceres_1708299340532/work/_pyceres/logging.h:119:19: error: type 'const class std::unique_ptr<std::__cxx11::basic_string<char> >' argument given to 'delete', expected pointer
2024-02-18T23:39:39.6554750Z 119 | delete result.str_;
2024-02-18T23:39:39.6554890Z | ~~~~~~~^~~~
Do you have any idea how to resolve this?
Hello, thanks for sharing your code.
I tried to use this project to optimize some parameters, the cost function is the distance from the point to the line.However, some werid phenomena were found. After adding log output to the cost function, the iteration speed slowed down. But the optimized result is far better than no logging.Any suggestions on this werid phenomena .
My environment is ubuntu 18,python 3.8 .Thanks
Lines 57 to 59 in 08ab2e7
I saw there are many properties were bound with setters and getters. However, it seems these setters and getters were just get and set value without doing other thing. In this way, why not using def_readwrite
or def_readwrite_static
?
Hi,
Does this package bind these 2 functions into python? I failed to find them. if it is not included, is there any replacement methods recommended in python?
Thank you for help!
Hi,
Is it possible to create a release for pyceres so that it can be added to conda-forge? It will be much easier to install and manage pyceres that way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.