[ Video ]
[ About ]
動画を円状に配置して、それぞれの再生フレームを位置情報を引数にしたNoise関数で変化させてみました
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#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> cap_frames; vector<cv::Mat> frames; vector<ofImage*> images; }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("Insta"); ofBackground(239); ofEnableDepthTest(); ofSetRectMode(ofRectMode::OF_RECTMODE_CENTER); this->cap.open("D:\\video\\image19.mp4"); this->cap_size = cv::Size(320, 180); this->number_of_frames = this->cap.get(CV_CAP_PROP_FRAME_COUNT); for (int i = 0; i < number_of_frames; i++) { cv::Mat src, mini_src; this->cap >> src; cv::resize(src, mini_src, this->cap_size); cv::cvtColor(mini_src, mini_src, CV_BGR2RGB); ofImage* image = new ofImage(); image->allocate(this->cap_size.width, this->cap_size.height, OF_IMAGE_COLOR); this->images.push_back(image); cv::Mat frame = cv::Mat(cv::Size(image->getWidth(), image->getHeight()), CV_MAKETYPE(CV_8UC3, image->getPixels().getNumChannels()), image->getPixels().getData(), 0); this->frames.push_back(frame); mini_src.copyTo(frame); image->update(); } } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateX(270); int radius = 930; int deg_span = 20; for (int z = -200; z <= 200; z += 200) { int noise_deg = ofMap(ofNoise(z * 0.005, ofGetFrameNum() * 0.003), 0, 1, -360, 360); for (int deg = 0; deg < 360; deg += deg_span) { ofPoint point(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), z); ofPushMatrix(); ofTranslate(point); ofRotateX(90); ofRotateY(deg + 90); int images_index = ofMap(ofNoise(point.x * 0.0005, point.y * 0.0005, point.z * 0.0005, ofGetFrameNum() * 0.005), 0, 1, 0, this->number_of_frames); this->images[images_index]->draw(0, 0); ofPopMatrix(); } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(1280, 720, OF_WINDOW); ofRunApp(new ofApp()); } |