hi i'm a beginner trying to learn openFrameworks and I get this error when I run my code. I've been looking around and cannot find a solution, please help. It is running on xcode and I have managed to run previous apps before.
ofApp.h
#pragma once
#include "ofMain.h"
#include "opencv2/opencv.hpp"
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void keyPressed(int key) {};
void keyReleased(int key) {};
void mouseMoved(int x, int y) {};
void mouseDragged(int x, int y, int button) {};
void mousePressed(int x, int y, int button) {};
void mouseReleased(int x, int y, int button) {};
void windowResized(int w, int h) {};
void dragEvent(ofDragInfo dragInfo) {};
void gotMessage(ofMessage msg) {};
ofEasyCam cam;
cv::VideoCapture cap;
cv::Size cap_size;
int number_of_frames;
vector<cv::Mat> frame_list;
ofImage image;
cv::Mat frame;
vector<ofMesh> mesh_list;
};
ofApp.cpp
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup() {
ofSetFrameRate(60);
ofSetWindowTitle("openFrameworks");
ofBackground(239);
ofSetColor(255);
ofEnableDepthTest();
this->cap.open("D:\\video\\image51.mp4");
this->cap_size = cv::Size(256, 144);
this->image.allocate(this->cap_size.width, this->cap_size.height, OF_IMAGE_COLOR);
this->frame = cv::Mat(cv::Size(this->image.getWidth(), this->image.getHeight()), CV_MAKETYPE(CV_8UC3, this->image.getPixels().getNumChannels()), this->image.getPixels().getData(), 0);
this->number_of_frames = 25 * 27;
for (int i = 0; i < this->number_of_frames; i++) {
cv::Mat src, tmp;
this->cap >> src;
if (src.empty()) {
return;
}
cv::resize(src, tmp, this->cap_size);
cv::cvtColor(tmp, tmp, cv::COLOR_BGR2RGB);
this->frame_list.push_back(tmp);
}
for (int i = 0; i < 128; i++) {
ofMesh mesh;
mesh.addVertex(glm::vec3(-128, -72, 0));
mesh.addVertex(glm::vec3(128, -72, 0));
mesh.addVertex(glm::vec3(128, 72, 0));
mesh.addVertex(glm::vec3(-128, 72, 0));
mesh.addTexCoord(glm::vec3(0, 0, 0));
mesh.addTexCoord(glm::vec3(256, 0, 0));
mesh.addTexCoord(glm::vec3(256, 144, 0));
mesh.addTexCoord(glm::vec3(0, 144, 0));
mesh.addIndex(0); mesh.addIndex(1); mesh.addIndex(2);
mesh.addIndex(0); mesh.addIndex(2); mesh.addIndex(3);
this->mesh_list.push_back(mesh);
}
}
//--------------------------------------------------------------
void ofApp::update() {
ofSeedRandom(39);
}
//--------------------------------------------------------------
void ofApp::draw() {
this->cam.begin();
ofRotateX(180);
ofRotateY(ofGetFrameNum() * 0.5);
for (auto& mesh : this->mesh_list) {
auto location = glm::vec3(ofRandom(-500, 500), ofRandom(-500, 500), ofRandom(-500, 500));
//int n = ofMap(ofNoise(glm::vec4(location, ofGetFrameNum() * 0.005)), 0, 1, 0, this->number_of_frames);
int n = int(ofRandom(1000) + ofGetFrameNum()) % this->number_of_frames;
this->frame_list[n].copyTo(this->frame);
this->image.update();
ofPushMatrix();
ofTranslate(location);
this->image.bind();
mesh.draw();
this->image.unbind();
ofPopMatrix();
}
this->cam.end();
}
main.cpp
#include "ofApp.cpp"
#include "ofApp.h"
//========================================================================
int main() {
ofSetupOpenGL(1280, 720, OF_WINDOW);
ofRunApp(new ofApp());
}
I get 2 errors: "No matching function for call to 'ofRunApp'" and "No type named 'VideoCapture' in namespace 'cv'"
I have sourced the code from https://github.com/junkiyoshi/Insta20200217 as I am trying to learn and develop an art project similar to this. Any help will be very much appreciated
请将#include "highgui.h"
添加到您的 main.cpp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.