环境:MAC机器,在客户操作系统的虚拟机内运行我的代码:Ubuntu 14.4 LTS。
我正在示例中的tensorflow工作区内编译openCV。我的WORKSPACE和opencv.BUILD文件看起来类似于提到的here
opencv + tensorflow项目的我的BUILD文件如下所示:
package(default_visibility = ["//tensorflow:internal"])
licenses(["notice"]) # Apache 2.0
exports_files(["LICENSE"])
cc_binary(
name = "label_image",
srcs = [
"main.cc",
],
linkopts = ["-lm"],
copts = ["-DWITH_FFMPEG=OFF"],
deps = [
"//tensorflow/cc:cc_ops",
"//tensorflow/core:framework_internal",
"//tensorflow/core:tensorflow",
"@opencv//:opencv"
],
)
filegroup(
name = "all_files",
srcs = glob(
["**/*"],
exclude = [
"**/METADATA",
"**/OWNERS",
"bin/**",
"gen/**",
],
),
visibility = ["//tensorflow:__subpackages__"],
)
如果我禁用张量流依赖(并且还评论张量流相关代码)。我可以看到网络摄像头正确捕获。像这样:
deps = [
#"//tensorflow/cc:cc_ops",
#"//tensorflow/core:framework_internal",
#"//tensorflow/core:tensorflow",
"@opencv//:opencv"
],
但是如果我仍然保持代码注释/取消注释并且还保持张量流依赖性我的摄像头挂起在VideoCapture :: read()
默认情况下,opencv使用FFMPEG编解码器,我尝试启用和禁用FFMPEG。有人可以帮我解释为什么在项目中编译tensorflow库会使我的openCV read()挂起?
答案 0 :(得分:0)
上面链接的OpenCV Bazel构建配置似乎只是为了CMake构建的所有.so文件。也许你需要将-DWITH_FFMPEG = OFF cflag传递给CMake?如果你像上面那样将它传递给Bazel,那么它只适用于main.cc的编译。