OpenCV and WebAssembly

907 views
Skip to first unread message

Arvind Arya

unread,
Nov 10, 2021, 7:32:49 AM11/10/21
to emscripten-discuss
I have a c++ program of openCV where I open an image and do Manipulations on it and write it back the header files I use are

#include<opencv2/imgcodecs.hpp>

#include <opencv2/highgui.hpp>

#include <opencv2/imgproc.hpp>

#include <opencv2/shape/shape_transformer.hpp>

I want to run this file in WebAssembly I am really lost.I am new how do I go about doing it. how do I link the libraries what libraries should I link. How does Emscripten goes about compiling my C++ program how and where I link libraries. Do I need to make an executable first. Please can someone give me steps.

Thank You So Much,

Arvind

Shlomi Fish

unread,
Nov 11, 2021, 1:04:53 AM11/11/21
to emscripte...@googlegroups.com
Hi Arvind!
I suggest you start by reading the intro documentation at
https://emscripten.org/ . I think building [parts of] opencv using emcc may not
be trivial.

> Thank You So Much,
>
> Arvind
>



--

Shlomi Fish https://www.shlomifish.org/
Humanity - Parody of Modern Life - https://shlom.in/humanity

The Knights Who Say “Ni” once said “Ni” to Chuck Norris. They are now no longer
The Knights Who Say “Ni”.
https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

Arvind Arya

unread,
Nov 11, 2021, 2:19:46 AM11/11/21
to emscripten-discuss
Thank You for the reply loved the jokes Chuck Norris jokes are like Rajnikanth jokes if you had seen his movies he actually is the GOAT in that genre.
I want to know how do I make object(.o) file from my project and then link it with a static library(.a) file which there are multiple of in my project.
# Compile libstuff to libstuff.a emconfigure ./configure emmake make # Compile project to project.o emconfigure ./configure emmake make # Link the library and code together. emcc project.o libstuff.a -o final.html
This is what I want to run. How do I go about it.

Shlomi Fish

unread,
Nov 11, 2021, 4:38:30 AM11/11/21
to emscripte...@googlegroups.com
Hi Arvind!

On Wed, 10 Nov 2021 23:19:46 -0800 (PST)
Arvind Arya <iamarv...@gmail.com> wrote:

> Thank You for the reply loved the jokes Chuck Norris jokes are like
> Rajnikanth jokes if you had seen his movies he actually is the GOAT in that
> genre.

I'm glad you did. I didn't watch Rajnikanth's films.

> I want to know how do I make object(.o) file from my project and then link
> it with a static library(.a) file which there are multiple of in my project.
> # Compile libstuff to libstuff.a emconfigure ./configure emmake make #
> Compile project to project.o emconfigure ./configure emmake make # Link the
> library and code together. emcc project.o libstuff.a -o final.html
> This is what I want to run. How do I go about it.

I didn't get too far with emconfigure and emmake (I use this instead:
https://github.com/shlomif/fc-solve/blob/master/fc-solve/scripts/Makefile.to-javascript.mak
).

Did you install emsdk yet: https://github.com/emscripten-core/emsdk ?

What did you run and what were the errors:

* https://github.com/shlomif/writing-the-perfect-question

* https://github.com/shlomif/how-to-share-code-online

Thanks!
Star Trek: “We, the Living Dead” - https://shlom.in/st-wtld

For every A, Chuck Norris is both A and not-A.
Chuck Norris is freaking everything.

Arvind Arya

unread,
Nov 11, 2021, 6:19:22 AM11/11/21
to emscripten-discuss
Screenshot 2021-11-11 at 4.01.41 PM.png
Screenshot 2021-11-11 at 4.04.29 PM.pngrojects but here is the issue.Screenshot 2021-11-11 at 4.01.13 PM.png
I have used Emscripten to compile basic c++ program how do I get these libraries and header file in the mix. So that they can work in WebAssembly or in the browser. People said that I need to link these .a files with the project. How do I go about doing it.  I cannot even get this code to run in Visual studio code. Cannot link libraries there. Please tell me how to move forward. Library linking is the main issue I am facing.

Shlomi Fish

unread,
Nov 11, 2021, 9:49:12 AM11/11/21
to emscripte...@googlegroups.com
Hi Arvind!

You need to prepare emscripten-friendly versions of the opencv libraries , by
compiling them from their C++ sources using emcc.

emcc *cannot* utilise native x86-64 machine code libraries.

perhaps one of the links here will help:

https://duckduckgo.com/?q=opencv+emscripten&atb=v140-1&ia=web

https://www.google.com/search?hl=en&q=opencv%20emscripten

And please avoid sending people 2MB-sized emails.

On Thu, 11 Nov 2021 03:19:22 -0800 (PST)
Interview with Ben Collins-Sussman - https://shlom.in/sussman

The Angel of Death cannot keep up with Chuck Norris’s throughput of killing.

Shlomi Fish

unread,
Nov 18, 2021, 7:02:06 AM11/18/21
to emscripte...@googlegroups.com, Arvind Arya, Shlomi Fish
Hi Arvind!

Ping! Why didn't you reply?

On Thu, 11 Nov 2021 16:46:46 +0200
Shlomi Fish <shl...@shlomifish.org> wrote:

> Hi Arvind!
>
> You need to prepare emscripten-friendly versions of the opencv libraries , by
> compiling them from their C++ sources using emcc.
>
> emcc *cannot* utilise native x86-64 machine code libraries.
>
> perhaps one of the links here will help:
>
> https://duckduckgo.com/?q=opencv+emscripten&atb=v140-1&ia=web
>
> https://www.google.com/search?hl=en&q=opencv%20emscripten
>
> And please avoid sending people 2MB-sized emails.
>
> On Thu, 11 Nov 2021 03:19:22 -0800 (PST)
> Arvind Arya <iamarv...@gmail.com> wrote:
>
> > [image: Screenshot 2021-11-11 at 4.01.41 PM.png]I
> > [image: Screenshot 2021-11-11 at 4.04.29 PM.png]rojects but here is the
> > issue.[image: Screenshot 2021-11-11 at 4.01.13 PM.png]
> > I have used Emscripten to compile basic c++ program how do I get these
> > libraries and header file in the mix. So that they can work in WebAssembly
> > or in the browser. People said that I need to link these .a files with the
> > project. How do I go about doing it. I cannot even get this code to run in
> > Visual studio code. Cannot link libraries there. Please tell me how to move
> > forward. Library linking is the main issue I am facing.
> > On Thursday, November 11, 2021 at 3:08:30 PM UTC+5:30 Shlomi Fish wrote:
> >
> > > Hi Arvind!



Let’s talk about restores instead of backups - https://is.gd/WatQqu

<mst> I find it’s usually safe to assume that whatever shlomif’s doing, there
isn’t a good reason for it.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages