Skip to content

opencv cannot read any image with tensorflow #14267

@stereomatchingkiss

Description

@stereomatchingkiss

It is the same issue as #1924, since the bug is closed, I open a new one, because this bug haven't been solved yet.

From subashp

I am using the TF 1.4 and linking against C++ code. Below code always says it failed to read the file. I have incorporated above suggestions and it doesnt make any difference. Thoughts/suggestions?

cv::String pathImg = argv[1];
cv::Mat img = cv::imread(pathImg, CV_LOAD_IMAGE_COLOR | CV_LOAD_IMAGE_ANYDEPTH);
if (img.empty()) {
error("Failed to read the file {}", argv[1]);
return -1;
}

From rmmal

we cloned the latest version of tensorflow and still there is a problem of reading images using opencv , everytime i initiate a TENSOR object the opencv doesn't work.

From me, using tensor1.4, build from source

#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>

//unable to read any image if I include this header, no matter
//it before or after opencv
#include <tensorflow/cc/ops/const_op.h>

#include <iostream>

int main(int argc, char *argv[])
{
    cv::Mat input_mat = cv::imread(argv[1], cv::IMREAD_COLOR);
    std::cout<<argv[1]<<", size:"<<input_mat.size()<<std::endl;    
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions