how to use yolov3 with opencv.js in browser

asked 2020-09-12 00:29:22 -0600

freeheartsz gravatar image

I'm new to opencv.js and have a trouble with is as below:

let utils = new Utils('errorMessage');
let cfg = 'yolo_file/test.cfg';
let weights = 'yolo_file/test.weights';
utils.createFileFromUrl('cfg', cfg, () => {
  utils.createFileFromUrl('weights', weights, () => {
    let img=cv.imread('imageSrc');
    let blob = cv.blobFromImage(img, 1/255, new cv.Size(800, 800), new cv.Scalar(0, 0, 0),true,false);
    let net = cv.readNet('cfg','weights');
    net.setInput(blob);
    let prob = net.forward();
    console.log(prob);
    //console.log(blob);
    //net.setInput(blob);
    //outs = net.forward(['yolo_82', 'yolo_94', 'yolo_106']);
  });

This code will get an error on this line let prob = net.forward();. The error detail is "Uncaught 6575912".

Can you suggest me how to resolve it?

edit retag flag offensive close merge delete

Comments

1

dig around here

but this already looks wrong:

cv.readNet('cfg','weights');

did you mean this ??:

cv.readNet(cfg,weights);

also, yolo3 has indeed 3 outputs, so a simple net.forward() won't do.

berak gravatar imageberak ( 2020-09-12 01:41:12 -0600 )edit

sir,can you give me a simple code?

freeheartsz gravatar imagefreeheartsz ( 2020-09-12 04:15:10 -0600 )edit