justadudewhohacks / opencv4nodejs

Nodejs bindings to OpenCV 3 and OpenCV 4
MIT License
4.92k stars 813 forks source link

Add dnn darknet support #372

Open marcinpastuszka opened 5 years ago

marcinpastuszka commented 5 years ago

Hello, Please add bindings for dnn darknet support: Commit (changes based on caffe bindings)

Example in cpp/python Works fine, but to be honest I don't understand how this module works, so if you can prepare an example for using it in node.js it will be great.

Thanks, Marcin

justadudewhohacks commented 5 years ago

Does one have to compile OpenCV with darknet support in order to import darknet models? If not then feel free to open a PR for your changes and I will try it out some time.

marcinpastuszka commented 5 years ago

Hello, compilation of the whole OpenCV is not needed. I used the 3.4.2 one and with this bindings. Reading from darknet files is working fine and native method runs correctly, so I will open PR ;) I just have problem to use the output from this net (to be honest I'm really noob in OpenCV)

Sorry, I'm using 3.4.2 version :)

justadudewhohacks commented 5 years ago

Okay. Which model are you importing, yolo v1, v2, v3?

marcinpastuszka commented 5 years ago

Yolov3

justadudewhohacks commented 5 years ago

Okay, I will try it out once you submitted a PR. Not sure about yolo v3, but v2 should return a Matrix of batchSize x gridX x gridY x number of anchors * (5 + numClasses).

An image is divided into a grid of gridX x gridY number of cells, where a cell is usually of size 32 x 32. For each cell you have N bounding box predictions (where N is the number of anchors). A bounding box prediction is encoded by center x, center y (relative to the cell position), width, height(relative to the anchor box size), confidence score, + class scores for each class.

Not sure if OpenCV is doing something under the hood here for post processing, I will have to try it out.

marcinpastuszka commented 5 years ago

Thanks for explanation :)