Ask Your Question
0

How do I compile a C program that contains a OPENCV header file?h

asked 2018-08-07 09:54:59 -0600

What can I do to include a custom OPENCV and then use EMCC to package it into a wasm file?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-08-08 03:45:42 -0600

Jendker gravatar image

I am doing it pretty normally with CMake build system. Just rember to compile OpenCV also with emcc and you will be fine.

edit flag offensive delete link more

Comments

Thank you for your reply.Could you tell you the step?
this is my command

emcc -O2 ss.bc -o project.js -s WASM=1 -O3 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap']" -s EXPORTED_FUNCTIONS="['_int_sqrt']"

#include "opencv2/imgcodecs/imgcodecs.hpp"
#include <emscripten/emscripten.h>
using namespace cv;
extern "C" {
int int_sqrt(int x) {
  IplImage *src = cvLoadImage("./a.png", 1);
  IplImage *dst = cvCreateImage(CvSize(src->width, src->height), src->depth, src->nChannels);
    //cvSobel(src, dst, 0, 1, 7);
    cvSobel(src, dst, 0, 1, CV_SCHARR);
    cvShowImage("dst", dst);
  return 0;
}
}

error info:warning: unresolved symbol: cvCreateImage

tangtao gravatar imagetangtao ( 2018-08-09 02:34:03 -0600 )edit

Did you compile OpenCV with emcc? https://docs.opencv.org/3.4.0/d4/da1/... Besides loading with cvLoadImage will probably not work so easily with WebAssmebly. You need to take care of the filesystem virtualization https://kripken.github.io/emscripten-...

Jendker gravatar imageJendker ( 2018-08-13 03:53:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-08-07 09:54:59 -0600

Seen: 534 times

Last updated: Aug 08 '18