3

I'm trying to use this library https://github.com/dom96/nim-opencv a wrapper for OpenCV.

After running nimble install opencv I can see the package in ~/.nimble/pkgs/opencv-0.1.0/

But when attempting to use I get a compile error

Error: cannot open 'opencv/highgui'

import opencv/highgui
const fileName = "g.jpg"
let img_colr = loadImage(fileName, 1)
echo img_colr.width
echo img_colr.height

Not sure what the problem is something to do with Nim import paths?...

Lex
  • 4,749
  • 3
  • 45
  • 66

1 Answers1

2

Are you compiling with nimble or nim? If the former then make sure you've got requires "opencv" in your .nimble file.

dom96
  • 1,012
  • 1
  • 9
  • 22
  • Thanks for the response @dom96 I tried with both... But I don't recall adding opencv in the .nimble file. I'll have another go soon. I thought it was a problem with the brew install of opencv, so I installed from source using opencv 4.0.1 but got the same issue – Lex Mar 13 '19 at 23:39
  • So I had copied your opencv source into my project, which started compiling. Adding `requires "opencv"` into the nimble config solved this mess. Now when I try to run I get `could not import: cvLoadImage`, my opencv can't be install correctly. I need to figure out how to link highguidll properly – Lex Mar 14 '19 at 00:48
  • 1
    Yeah, that's a DLL issue. Either that or my wrapper is so old now that the ``cvLoadImage`` no longer exists as a function in opencv. If you're on Windows make sure to get a 64bit DLL if you're compiling a 64bit binary. – dom96 Mar 16 '19 at 10:33