-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to convert Mat from opencv to caffe format #2598
Comments
Hi mJohn, did you ever resolve this issue? If so, what did you end up doing? Thanks in advance, |
In the training stage, caffe‘s c++ implementation uses imread in OpenCV to read image, which by default reads the color channels in order of B G R. However, in the python interface, caffe uses skimage to read image, which by default reads the color channels in order or R G B. If you are using the python version of OpenCV to read image, you need to do the following conversion: img = cv2.imread(path/to/image) However, it is always better to use caffe’s skimage wrapper: img = caffe.io.load_image(path/to/image) |
@mjohn123 Can you please describe the part:
|
i have meet this issue and i have solved this problem by the inspiration of "examples/cpp_classification/classification.cpp". i think they have did a great job, instead of loading the data into blob pixel by pixel, they use one trick. Here is what they did: std::vectorcv::Mat channels; for (int i = 0; i < num_channels_; ++i) {
Then to load img into, they simply just do this: cv::split(sample_normalized, input_channels); |
Hello all, I am using opencv to crop face from my camera. And then I used caffe to predict that image belongs to male or female. I have a original code that load image from static image. However, I want to use image from camera for it. This is original code in caffe
Now, I will use opencv to capture frame and call predict method
After having resized_image, I will predict that image based on above code. I just replace above predict code by =model.predict([resized_img]). But I got error that is
IndexError: tuple index out of range
How to fix my code? Thank you for help!
The text was updated successfully, but these errors were encountered: