[ Video ]
[ About ]
動画の細切れにして円周上に配置、再生フレームと角度をリンクさせたらフィルムみたいになって綺麗じゃね?って思ったら、全然そんな事なかったので、ズラっと並べてました
[ 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 78 79 80 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofSetWindowTitle("Insta"); ofBackground(239); ofEnableDepthTest(); ofSetRectMode(ofRectMode::OF_RECTMODE_CENTER); this->cap.open("D:\\video\\image11.mp4"); this->cap_size = cv::Size(160, 90); for (int i = 0; i < 36; i++) { 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); } 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); this->cap_frames.push_back(mini_src); } } //-------------------------------------------------------------- void ofApp::update() { int capture_span = this->number_of_frames / 36; for (int i = 0; i < this->frames.size(); i++) { int index = (ofGetFrameNum() + i * capture_span) % this->number_of_frames; this->cap_frames[index].copyTo(this->frames[i]); this->images[i]->update(); } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); int radius = 500; for(int i = 0; i < this->images.size(); i++){ int deg = i * 10; ofPoint point(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); ofPushMatrix(); ofTranslate(point); ofRotateY(90); ofRotateY(45); this->images[i]->draw(0, 0); ofPopMatrix(); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |