tensorflow: opencv imported after tensorflow can't read jpeg
Environment info
Operating System: Ubuntu 14.04.
If installed from sources, provide the commit hash: f952246b17562
Steps to reproduce
$ python2 -c "import tensorflow; import cv2; print cv2.imread('cat.jpg')"
None
What have you tried?
import cv2 before tensorflow works.
This problem also exists on CentOS 7. It doesn’t happen on a latest ArchLinux. It’s likely due to that tensorflow has it’s own libjpeg that conflicts with opencv on some platforms.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 54 (6 by maintainers)
Commits related to this issue
- Added linker script to limit the symbols that are visible in _pywrap_tensorflow.so. Fixes #1924 Change: 122226376 — committed to qbx2/tensorflow by keveman 8 years ago
- Apply exported symbol filtering to the c++ API analogously to what is filtered for the C API. Fixes bug reported in comments on #1924 PiperOrigin-RevId: 168413719 — committed to drpngx/tensorflow by deleted user 7 years ago
- Merge changes from github. END_PUBLIC I also integrated #13073 by hand to make TAP happy. --- Commit 92362d0f0 authored by Skye Wanderman-Milne<skyewm@google.com> Committed by TensorFlower Gardener<... — committed to drpngx/tensorflow by deleted user 7 years ago
- Branch 168917534 (#13077) * Use HLO name, rather than pointer address, for profile counter name. This removes a source of nondeterminism in IR generation. PiperOrigin-RevId: 168779489 * Eage... — committed to tensorflow/tensorflow by drpngx 7 years ago
- Apply exported symbol filtering to the c++ API analogously to what is filtered for the C API. Fixes bug reported in comments on #1924 PiperOrigin-RevId: 168413719 — committed to codrut3/tensorflow by deleted user 7 years ago
@beniz the linker script defines what symbols in
libtensorflow.sowill be exported: in this case it exports symbols that match the pattern*tensorflow*and keeps everything else (eg. everything fromlibpngandlibjpeg) internal.I think all you need to do is add this to the
libtensorflow.soBazel rule:linkopts = [ "-Wl,--version-script=tensorflow/tf_version_script.lds" ],Then rebuildlibtensorflow.so.Have the same issue with tensorflow1.4 and opencv3.3.1
The problem still exists in 1.4.1. The fix for version 1.3 mentioned above no longer works.
A workaround I’ve done is that I loaded the image with an external library (stb_image) and then fed the data to the
cv::Matlike so:Hope that helps.
@chenbiaolong
coptsis only used when compiling; you need to use the linker script with the linker so it really needs to be inlinkopts. Maybe you can’t have a space between-Wl,and--version-script...