Ask Your Question

jrobble's profile - activity

2017-10-04 11:03:43 -0500 marked best answer Is the swapRB value in the example GoogLeNet DNN code wrong?

Hi All, I'm confused. The "Load Caffe framework models" example code for OpenCV 3.3 reads:

//GoogLeNet accepts only 224x224 RGB-images
Mat inputBlob = blobFromImage(img, 1, Size(224, 224), Scalar(104, 117, 123));   //Convert Mat to batch of images

The last parameter swapRB isn't provided, so the default value of true is used. My understanding is that OpenCV imread() and video capture read data in as BGR, so if that comment is to be believed, then the code is doing the right thing by converting the image data to RGB. However, I can't find any evidence that the GoogLeNet model actually accepts RGB images.

We've found several places where the BGR color scheme for Caffe is explicitly called out, including this one.

This example on the BVLC github website shows how they preprocess the data, when the image is read with OpenCV. We're not seeing where they performed the swap. It reads:

/* This operation will write the separate BGR planes directly to the
  * input layer of the network because it is wrapped by the cv::Mat
  * objects in input_channels. */

Any and all help would be greatly appreciated!

Furthermore, in the OpenCV 3.1 example code in Step 4 it reads:

resize(img, img, Size(224, 224));       //GoogLeNet accepts only 224x224 RGB-images
dnn::Blob inputBlob = dnn::Blob(img);   //Convert Mat to dnn::Blob image batch

Firstly, we resize the image and change its channel sequence order.

I'm not sure what actually changes the channel sequence order there.

2017-10-04 11:03:43 -0500 received badge  Scholar (source)
2017-09-26 05:26:10 -0500 received badge  Nice Answer (source)
2017-09-25 16:44:16 -0500 received badge  Teacher (source)
2017-09-25 12:45:38 -0500 received badge  Self-Learner (source)
2017-09-25 12:28:04 -0500 answered a question Is the swapRB value in the example GoogLeNet DNN code wrong?

To answer my own question: Yes, the swapRB value in the example GoogLeNet DNN code was wrong. This issue is now fixed pe

2017-09-19 23:07:14 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, you're welcome. Thanks for the info. Let's land the PRs through GitHub. Then I'll answer this question.

2017-09-19 01:47:08 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, I created two PRs for your issue. I updated all instances of blobFromImage and blobFromImages for the caffe fram

2017-09-19 01:36:02 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, I created two PRs for your issue. I updated all instances of blobFromImage and blobFromImages for the caffe fram

2017-09-19 01:22:34 -0500 received badge  Enthusiast
2017-09-17 05:01:54 -0500 received badge  Student (source)
2017-09-16 19:18:38 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@vludv, thanks for looking into it. I will submit a PR on Monday.

2017-09-14 08:19:33 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

I recently reached out to Vitaliy Lyudvichenko via email. He made some recent commits to that code and is going to revie

2017-09-13 16:32:00 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, we're on the same page. We also thought that using the white space shuttle test image might not reveal BGR vs. R

2017-09-13 16:31:25 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, we're on the same page. We also thought that using the white space shuttle test image might not reveal BGR vs. R

2017-09-13 15:05:41 -0500 commented question Is the swapRB value in the example GoogLeNet DNN code wrong?

@dkurt, we're in the same page. We also thought that using the white space shuttle test image might not reveal BGR vs. R

2017-09-12 20:29:16 -0500 asked a question Is the swapRB value in the example GoogLeNet DNN code wrong?

swapRB value in example GoogLeNet DNN code wrong? Hi All, I'm confused. The "Load Caffe framework models" example code f