# Conflicting libraries (YOLO comp vision)

**URL:** <https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812>\
**Category:** Libraries\
**Created:** [December 21, 2018, 11:37am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812 "2018-12-21T11:37:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [December 21, 2018, 11:37am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/1 "2018-12-21T11:37:05Z")

</div>

Hi team, i seem not to be able to get YOLO working despite some step by step guidance stated on:

> **[chungbwc/Magicandlove](https://github.com/chungbwc/Magicandlove/tree/master/ml20180808a)**
>
> Source code for the tutorials and demonstrations in my website http://www.magicandlove.com - chungbwc/Magicandlove

  
from mr MagicandLove. I removed libraries and replaced them to try get the error removed.  
Is there a tip that can steer me in the correct direction?

I did import the required files in the locations as the site stated, the CVImage file seems to keep conflicting (i do restart pc to refresh )

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f06b6a25ff01c6ddce0d9cb0313203a5b6a3ab3d.png)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d8a603296eb385b072e5122bc289266228651708.png)

help to tackle this last step would be helped

basic code from site:

```auto
import cvimage.*;
import ipcapture.*;
 
IPCapture cap;
import processing.video.*;
//import CVImage.*;
import org.opencv.core.*;
import org.opencv.core.Core;
import org.opencv.core.Core.MinMaxLocResult;
import org.opencv.dnn.*;
import org.opencv.core.MatOfDouble;
import java.util.*;

final int CAPW = 640, CAPH = 360;
final int W = 416, H = 416;
final float THRESH = 0.85;
private Net net;
//private Capture cap;
private CVImage cv;
private String [] labels;
private ArrayList<String> names;

public void settings() {
  size(CAPW, CAPH);
}

public void setup() {
  System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
  println(Core.VERSION);
  // printArray(Capture.list());
 // cap = new Capture(this, CAPW, CAPH);
 cap = new IPCapture(this, "http://DESKTOP-1QTI31N:8080/cx","","");
  cap.start();
  cv = new CVImage(W, H);
  loadYOLO();
  getOutputsNames(net);
}

private void getOutputsNames(Net n) {
  int [] outLayers = n.getUnconnectedOutLayers().toArray();
  ArrayList<String> layers = (ArrayList)n.getLayerNames();
  names = new ArrayList<String>(outLayers.length);
  for (int i=0; i<outLayers.length; i++) {
    names.add(layers.get(outLayers[i]-1));
  }
  for (String s : names) {
    println(s);
  }
}

private void loadYOLO() {
  net = Dnn.readNetFromDarknet(dataPath("yolov3.cfg"), 
    dataPath("yolov3.weights"));

  //net.setPreferableBackend(Dnn.DNN_BACKEND_DEFAULT);
  //net.setPreferableTarget(Dnn.DNN_TARGET_OPENCL);
  String [] labelFile = loadStrings("object_detection_classes_yolov3.txt");
  labels = new String[labelFile.length];
  println("Class size: " + labelFile.length);
  for (int i=0; i<labelFile.length; i++) {
    labels[i] = trim(labelFile[i]);
    println(labels[i]);
  }
}

public void draw() {
  if (cap.available()) {
    return;
  cap.read();
  }
  background(0);
  cv.copy(cap, 0, 0, cap.width, cap.height, 
    0, 0, cv.width, cv.height);
  cv.copyTo();
  image(cap, 0, 0);
  Mat blob = Dnn.blobFromImage(cv.getBGR(), 1.0f/255.0f, 
    new Size(cv.width, cv.height), 
    new Scalar(0, 0, 0), true, false);
  net.setInput(blob);

  Mat result = net.forward(names.get(0));

  pushStyle();
  for (int i=0; i<result.rows(); i++) {
    Mat scores = result.row(i).colRange(5, result.cols());
    MinMaxLocResult mm = Core.minMaxLoc(scores);
    Point classIdPoint = mm.maxLoc;
    double confidence = mm.maxVal;
    if (confidence > THRESH) {
      int idx = (int)classIdPoint.x;
      int x = (int)(result.get(i, 0)[0]*cap.width);
      int y = (int)(result.get(i, 1)[0]*cap.height);
      int w = (int)(result.get(i, 2)[0]*cap.width);
      int h = (int)(result.get(i, 3)[0]*cap.height);
      noFill();
      stroke(255, 0, 0);
      rect(x-w/2.0, y-h/2.0, w, h);
      noStroke();
      fill(255, 0, 0, 200);
      rect(x-w/2.0, y-h/2.0, w, 18);
      fill(255, 255, 255);
      text(labels[idx], x+5-w/2.0, y+12-h/2.0);
    }
  }
  popStyle();
}

```

error:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/87ef28feb4fbca130300b1b672fa31a1d7470f36.png)

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 22, 2018, 5:44pm UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/2 "2018-12-22T17:44:24Z")

</div>

The little popup box error seems to be telling you what you need. You have two library folders installed that both provide opencv – one is libraries/CVImage, the other is libraries\opencv\_processing. It looks like you need to uninstall one of them – e.g. move one of those folders out of your libraries path – so that when you import org.opencv, there is only one match, not two matches.

---

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [December 22, 2018, 6:15pm UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/3 "2018-12-22T18:15:34Z")

</div>

> [@jeremydouglass](#):
>
> atch, not t

`Jeremy,

thank you for taking time. I indeed removed one of them, in different orders and variants. each time restarting pc. no positive result, i do a new testround tomorrow , toady the pc beat me though, getting energy to fight it again and get it solved 🙂

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 23, 2018, 5:35am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/4 "2018-12-23T05:35:03Z")

</div>

You should not need to restart your PC – and skipping that step will greatly speed up your testing. I’d suggest removing them both and restarting PDE. The sketch should fail with library not found. If it doesn’t you have a bigger problem.

Also note that you need to completely remove those folders from your library path. You can’t just rename them or put them in a subfolder – they will still be found and your problem won’t go away.

---

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [December 23, 2018, 12:05pm UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/5 "2018-12-23T12:05:10Z")

</div>

Thank you for pointing out only all P3 windows needs to be closed, not restarting helps indeed 🙂  
I completely removed one (in a few variants), it gets me in an error which marks

`net = Dnn.readNetFromDarknet(dataPath("yolov3.cfg"),`

also refers to a library still: `No library found for org.opencv.core.Core`

and gives the message that is above my understanding:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a6a2db9d5352425678751639cda4fd9787083c06.png)

i am diving in the matter to see if i can make baby steps, if there is an obvious tip though, it would make my sunday real good.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [December 25, 2018, 1:29am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/6 "2018-12-25T01:29:48Z")

</div>

I was able to reproduce your problem and then I fixed it. I guess you forgot to download files into `data` folder as written in readme [https://github.com/chungbwc/Magicandlove/blob/master/ml20180808a/README.md](https://github.com/chungbwc/Magicandlove/blob/master/ml20180808a/README.md)

But be careful, 1st `cfg` file and 3rd `txt` files are not direct link to raw files, so you need to follow the link and then download raw files from Github. The 2nd weight file is a direct link.

---

<div class="post-metadata">

**Author:** ![TTG](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ttg/32/983_2.png) [@TTG](https://discourse.processing.org/u/TTG)\
**Post date:** [December 25, 2018, 10:13am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/7 "2018-12-25T10:13:04Z")

</div>

Micuat, very grateful you point out that the yolov3.cfg was the issue, i indeed placed the file wrongly in the datafolder, putting a copied raw as replacement fixed that part.

it is running, very slow, now trying to get it to run smooth and correct, helped a lot

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2f9516b38a1aa89005de3f5fc440ef94d927e423.jpeg)

---

<div class="post-metadata">

**Author:** ![liuxuezhi](https://avatars.discourse-cdn.com/v4/letter/l/74df32/32.png) [@liuxuezhi](https://discourse.processing.org/u/liuxuezhi)\
**Post date:** [September 30, 2019, 1:24am UTC](https://discourse.processing.org/t/conflicting-libraries-yolo-comp-vision/6812/8 "2019-09-30T01:24:48Z")

</div>

Hello, I have the same problem, but I don’t know how to solve it. Can you tell me how to solve it? T

 ![22](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/0/0b1010226deb83681f73ff86712ff39029aed8cf.png) hanks
