WebAssembly:编译OpenCV C ++代码时未定义符号_ZN2cv12VideoCaptureC1Ev

时间:2019-08-22 18:44:06

标签: opencv webassembly

我试图编译使用VideoCapture进行wasm的C ++代码,基本上,我试图在不使用媒体服务器的情况下在浏览器中显示rtsp,rtmp摄像机的帧。这是在编译OpenCV以获取脚本时启用的构建模块

cmd = ["cmake",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_TOOLCHAIN_FILE='%s'" % self.get_toolchain_file(),
"-DCPU_BASELINE=''",
"-DCPU_DISPATCH=''",
"-DCV_TRACE=OFF",
"-DBUILD_SHARED_LIBS=OFF",
"-DWITH_1394=OFF",
"-DWITH_ADE=OFF",
"-DWITH_VTK=OFF",
"-DWITH_EIGEN=OFF",
"-DWITH_FFMPEG=ON",
"-DWITH_GSTREAMER=ON",
"-DWITH_GTK=ON",
"-DWITH_GTK_2_X=ON",
"-DWITH_IPP=OFF",
"-DWITH_JASPER=OFF",
"-DWITH_JPEG=ON",
"-DWITH_WEBP=OFF",
"-DWITH_OPENEXR=OFF",
"-DWITH_OPENGL=OFF",
"-DWITH_OPENVX=OFF",
"-DWITH_OPENNI=OFF",
"-DWITH_OPENNI2=OFF",
"-DWITH_PNG=ON",
"-DWITH_TBB=OFF",
"-DWITH_PTHREADS_PF=OFF",
"-DWITH_TIFF=ON",
"-DWITH_V4L=ON",
"-DWITH_OPENCL=ON",
"-DWITH_OPENCL_SVM=ON",
"-DWITH_OPENCLAMDFFT=ON",
"-DWITH_OPENCLAMDBLAS=ON",
"-DWITH_GPHOTO2=ON",
"-DWITH_LAPACK=ON",
"-DWITH_ITT=ON",
"-DWITH_QUIRC=ON",
"-DBUILD_ZLIB=ON",
"-DBUILD_opencv_apps=ON",
"-DBUILD_opencv_calib3d=ON",
"-DBUILD_opencv_dnn=ON",
"-DBUILD_opencv_features2d=ON",
"-DBUILD_opencv_flann=ON", # No bindings provided. This module is used as a dependency for other modules.
"-DBUILD_opencv_gapi=ON",
"-DBUILD_opencv_ml=ON",
"-DBUILD_opencv_photo=ON",
"-DBUILD_opencv_imgcodecs=ON",
"-DBUILD_opencv_shape=ON",
"-DBUILD_opencv_videoio=ON",
"-DBUILD_opencv_videostab=ON",
"-DBUILD_opencv_highgui=ON",
"-DBUILD_opencv_superres=ON",
"-DBUILD_opencv_stitching=ON",
"-DBUILD_opencv_java=OFF",
"-DBUILD_opencv_java_bindings_generator=OFF",
"-DBUILD_opencv_js=ON",
"-DBUILD_opencv_python2=OFF",
"-DBUILD_opencv_python3=OFF",
"-DBUILD_opencv_python_bindings_generator=OFF",
"-DBUILD_EXAMPLES=OFF",
"-DBUILD_PACKAGE=OFF",
"-DBUILD_TESTS=OFF",
"-DBUILD_PERF_TESTS=OFF"]

我收到的错误消息是

  

错误:未定义符号:_ZN2cv12VideoCaptureC1Ev警告:禁用   未定义符号的错误使用-s ERROR_ON_UNDEFINED_SYMBOLS=0   错误:未定义符号:_ZN2cv12VideoCaptureD1Ev

这是我的C ++代码:

#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <opencv2/core/mat.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/objdetect.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
using namespace cv;
using namespace emscripten;
class Hello {
private:
std::vector<unsigned char> buffer;
Mat decoded;
cv::VideoCapture capture;
public:
Hello() : buffer{}, decoded{} {};
val allocate(size_t size) {
this->buffer.reserve(size);
unsigned char *byteBuffer = this->buffer.data();
return val(typed_memory_view(size, byteBuffer));
}
bool init(String s){
capture = cv::VideoCapture(s);
capture.set(CAP_PROP_BUFFERSIZE, 1);
// capture.set(CV_CAP_PROP_BUFFERSIZE, 1);
// capture.set(CV_CAP_PROP_FRAME_WIDTH,1280);
// capture.set(CV_CAP_PROP_FRAME_HEIGHT,720);
// capture.set(cv::CAP_PROP_FPS,60);
//capture.set(CV_CAP_PROP_FRAME_HEIGHT,768);
return capture.isOpened();
}
cv::Mat getFrame(){
cv::Mat frame;
if (!capture.read(frame)) {
return frame;
}
return frame;
}
Mat my_imdecode() {
// this->decoded = cv::imdecode(this->buffer, IMREAD_GRAYSCALE);
return this->decoded;
}
};
EMSCRIPTEN_BINDINGS(my_module) {
class_<Mat>("Mat");
class_<Hello>("Hello")
.constructor<>()
.function("imdecode", &Hello::my_imdecode)
.function("allocate", &Hello::allocate)
.function("init", &Hello::allocate).
.function("getFrame", &Hello::allocate);
}

我知道我的代码是正确的,我犯的唯一错误是编译OpenCV,所以我应该编译哪个模块?

0 个答案:

没有答案