我在评估Java / Scala的OpenCV 4.1.0中的多个神经网络时遇到问题。网络会返回fish-bike图片以及其他图片的全零。我在以下情况中观察到了这一点:
检测与YOLOv3-spp和YOLOv3-tiny https://pjreddie.com/darknet/yolo/一起使用。
这种dnn烹饪有什么问题?
// The reproduce in Scala REPL you need a hack:
def loadLibraryScalaREPL(libraryName: String): Unit = {
val loadLibrary0 = Runtime.getRuntime.getClass.getDeclaredMethods()(4)
loadLibrary0.setAccessible(true)
loadLibrary0.invoke(Runtime.getRuntime, scala.tools.nsc.interpreter.IMain.getClass, libraryName)
}
loadLibraryScalaREPL(org.opencv.core.Core.NATIVE_LIBRARY_NAME)
// To load in Java/Scala application just use System.loadLibrary.
import org.opencv.core.{Scalar, Size}
import org.opencv.dnn.Dnn
import org.opencv.imgcodecs.Imgcodecs
val image = Imgcodecs.imread("/root/fish-bike.jpg")
val net = Dnn.readNetFromCaffe("/tmp/VGG_coco_SSD_512x512_iter_360000.prototxt", "/tmp/VGG_coco_SSD_512x512_iter_360000.caffemodel")
val blob = Dnn.blobFromImage(image, 1/125.0, new Size(512, 512), new Scalar(104,117,123), true)
net.setInput(blob)
val layer = net.forward()
val values = new Array[Float](layer.total().toInt)
layer.get(0,0, values)
values.grouped(7).foreach(x => println(x.toList))