Fork me on GitHub
#data-science
<
2023-03-13
>
cdeln16:03:24

I want to try out some computer vision with clojure. First task is ofc to get my hands on opencv. Made a search on clojars, getting 14 different libs. Is there any "official" opencv bindings for clojure? Or any that you recommend to use?

👀 2
Rupert (All Street)17:03:56

I'm not sure which is the best one to go for. But I would usually check github instead of clojars for a library (e.g. search opencv github clojure) then look at recency, completeness, test cases, quality of README etc then try a few and pick a favourite.

cdeln17:03:56

Github search results not very promising either... I'll look into going through python, thanks for the tips!

phronmophobic17:03:24

I'm a little biased, but using search engines or github tends to miss lots of good clojure libraries. I've found https://phronmophobic.github.io/dewey/search.html usually gives better results. Searching for opencv returns https://github.com/techascent/tech.opencv which might be promising. Having said that, looking through python's options might be a good route for opencv.

👀 4
👍 4
clojure-spin 2
aaelony18:03:10

not sure if it is actively maintained, but back in the day https://www.clojure-toolbox.com/ was a nice resource as well for finding libs. There is also a slack channel: find-my-lib

👍 2
Daniel Slutsky20:03:50

Another resource of this kind is https://scicloj.github.io/docs/resources/libs/. Indeed, it does not offer good advice for computer vision. Pull requests to https://github.com/scicloj/scicloj.github.io/blob/master/content/en/docs/resources/model.edn would be welcome. 🙏

chrisn20:03:54

tech.opencv is built upon javacpp's opencv library. I haven't updated tech.opencv in forever so if it doesn't work for you I would myself just use javacpp's bindings directly - https://github.com/bytedeco/javacpp-presets

cdeln06:03:00

@U7RJTCH6J Cool search! I'll tab it. What do you base the search on?

phronmophobic06:03:49

It's more or less substring search of all the fields in the table.

cdeln06:03:08

I mean the table, how do you create it?

phronmophobic06:03:41

Where does the data come from or the js for the table?

phronmophobic06:03:04

The js uses https://datatables.net/ and it does all the work.

phronmophobic06:03:59

The data is queried from github. A brief description is here, https://github.com/phronmophobic/dewey#finding-clojure-libraries-methodology

👍 2
cdeln06:03:23

@U0CDMAKD0 Also a nice search tool, but lib list is a bit outdated. I'll poke the maintainer once I find the libs I like.

cdeln06:03:57

@U066L8B18 I still haven't explored the sci-stack. Maybe it's time for that! Thanks for the pointers.

🙏 2
cdeln06:03:57

@UDRJMEFSN This looks good, but requires me to get into the "sci-stack" (which I don't mind). Any reason why it's not on the "sci-list" yet?

chrisn12:03:48

Because it is too out of date. tech.v2.datatype is years old, the datatype library is version 10 now. opencv's latest javacpp bindings are https://search.maven.org/artifact/org.bytedeco/opencv/4.6.0-1.5.8/jar

👍 2
chrisn13:03:26

Overall the python pathway (libpython-clj) is most likely your best bet by far. I am trying to even use the latest javacpp-opencv and it literally failing at every step so if this isn't something that is going up on a server somewhere pip install opencv-python (or whatever it is) is going to be much faster and better documented.

👍 2
cdeln16:03:47

@UDRJMEFSN I am trying to install libpython-clj. I assume it's this one https://github.com/clj-python/libpython-clj . Is it supposed to be installed from source locally or can I pull from some jar repo? Looking at clojars I find 3 libs: clj-python/libpython-clj 2.024 , cnuernber/libpython-clj 1.36 and libpython-clj 1.6-SNAPSHOT .

chrisn16:03:17

The first one - it is listed at the top of the README

chrisn17:03:04

Then you have to have a working python installation which ideally has a verison of python the initialize method can find.

cdeln19:03:17

Ah missed the deprecation notice of cnuernber/libpython-clj 1.36 . What about clj-python/libpython-clj 2.024 ? The git repo does not have a project.clj but the README tells me to run lein install. What am I missing?

cdeln07:03:24

Ah with "first one" you mean clj-python/libpython-clj 2.024 , not source installation? I did try that one and got a horrendous crash, so I just want to make sure I am following the correct installation method before debugging further.

Rupert (All Street)10:03:26

I've used versions of clj-python/libpython-clj and they worked very well just by adding them to project.clj /`deps.edn` running on a linux machine. > got a horrendous crash, so I just want to make sure I am following the correct installation method before debugging further. Maybe try adding it as as dependency to a completely fresh project first (no other dependencies) to see if it works better there. If it does, then you may have had a dependency conflict which you can investigate a bit using lein deps :tree or similar deps.edn functionality

cdeln06:03:46

Just wanna round up this thread. The "horrendous crash" only happens in emacs cider, running lein run on command line gives reasonable error messages. The issue was (as pointed out in the project readme) that my python was statically linked (using pyenv). Installed dynamic library using the following command: PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --verbose 3.7.15 . Once that was fixed I got an jdk.incubator.foreign.MemoryAddress exception, which also was fixed by looking at some nice error messages by adding some JVM options to project.clj (`--add-modules jdk.incubator.foreign,jdk.incubator.vector --enable-native-access=ALL-UNNAMED` ).