prabindh / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
122 stars 46 forks source link

Image format provide to the network_predict() function #43

Closed arikga closed 7 years ago

arikga commented 7 years ago

Hello, my goal is to capture images from my camera and send them to direct to the network_predict() function.

In the original C code the format was XY3 normalize floats rgb (when X & Y are the sizes of the network), but on the CPP version the input image memory alignment have change to R pixel following the G pixels and the B pixels. Am I right?, if true then why to do this?

prabindh commented 7 years ago

What is the latest commit in the branch you are using ? Is it not fixed in the issue per - https://github.com/prabindh/darknet/issues/35

arikga commented 7 years ago

I'm using the last master commit, My question is not about those lines: //Convert to rgb cv::Mat inputRgb; cvtColor(inputMat, inputRgb, CV_BGR2RGB);

those are the lines thats interesting me : //Get the image to suit darknet std::vector floatMatChannels(3); split(floatMat, floatMatChannels); vconcat(floatMatChannels, floatMat);

why the memory alignment of the image is changed?

prabindh commented 7 years ago

Both versions have planar RGB input. Please confirm where you observed interleaved RGB being input ?

arikga commented 7 years ago

In the file https://github.com/prabindh/darknet/blob/master/arapaho/arapaho.cpp#L238 the class ArapahoV2 Detect method gets cv::Mat, the input mat is

  1. converted to RGB
  2. converted to float + normalized
  3. resized to the network size
  4. splits into 3 cv::Mat R, G, B
  5. concatenation vertical to the final cv::Mat (this is the input to the private __Detect method)

My question is why do we need stages 4 + 5?

prabindh commented 7 years ago

Because Darknet takes planar RGB data, not interleaved. Please confirm where you observed interleaved RGB being input.

arikga commented 7 years ago

OK, so let me get it straight: 'planar RGB' data memory alignment is : RRRR....GGGG...BBBB... and 'interleaved' memory alignment is : RGBRGB....RGB ?

prabindh commented 7 years ago

Yes..

prabindh commented 7 years ago

@arikga do you have any inputs ? Is this issue closed ? Thx

arikga commented 7 years ago

Thank You!