简体   繁体   中英

tensorflow + opencv webcam hangs

Environment: MAC machine, running my code inside virtual machine with guest OS: Ubuntu 14.4 LTS.

I am compiling openCV within tensorflow workspace under examples. My WORKSPACE and opencv.BUILD file look similar to the one mentioned here

My BUILD file for the opencv + tensorflow project looks like following:

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__"],
)

If i disable tensorflow dependences (and also comment the tensorflow related code). I can see that the webcam is captures properly. like this:

deps = [
            #"//tensorflow/cc:cc_ops",
            #"//tensorflow/core:framework_internal",
            #"//tensorflow/core:tensorflow",
            "@opencv//:opencv"
        ],

But if i still keep the code commented/uncommented and also keep the tensorflow dependences my webcam hangs at VideoCapture::read()

By default, opencv use FFMPEG codec and i tried enabling and disabling FFMPEG. Can someone please help me why when tensorflow library is compiled in the project makes my openCV read() hangs?

The OpenCV Bazel build configuration you linked above appears to just glob all the .so files that CMake built. Maybe you need to pass the -DWITH_FFMPEG=OFF cflag to CMake? If you pass it to Bazel as you did above, it's only going to apply to the compilation of main.cc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM