[ Video ]
[ About ]
プログラミングでの落書きを毎日アップロードして2年が経過。明日から3年目がスタート!
Upload videos of creative coding every day for 2 years. The 3rd year starts from tomorrow.
[ 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  | 
						#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) {}; 	vector<cv::VideoCapture> caps; 	vector<cv::Mat> mats; 	vector<unique_ptr<ofImage>> images; 	cv::VideoWriter writer; 	vector<glm::vec2> locations; 	int rect_size; };  | 
					
| 
					 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  | 
						#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofSetWindowTitle("openFrameworks"); 	ofBackground(239); 	ofNoFill(); 	this->locations.push_back(glm::vec2(110, 110)); 	this->locations.push_back(glm::vec2(210, 10)); 	this->locations.push_back(glm::vec2(310, 10)); 	this->locations.push_back(glm::vec2(410, 10)); 	this->locations.push_back(glm::vec2(510, 110)); 	this->locations.push_back(glm::vec2(510, 210)); 	this->locations.push_back(glm::vec2(410, 310)); 	this->locations.push_back(glm::vec2(310, 410)); 	this->locations.push_back(glm::vec2(210, 510)); 	this->locations.push_back(glm::vec2(110, 610)); 	this->locations.push_back(glm::vec2(210, 610)); 	this->locations.push_back(glm::vec2(310, 610)); 	this->locations.push_back(glm::vec2(410, 610)); 	this->locations.push_back(glm::vec2(510, 610)); 	this->rect_size = 100; 	for (int i = 0; i < this->locations.size(); i++) { 		cv::VideoCapture cap = cv::VideoCapture(); 		cap.open("C:\\Develop\\video\\" + to_string(i) + ".mp4"); 		auto image = make_unique<ofImage>(); 		image->allocate(this->rect_size, this->rect_size, OF_IMAGE_COLOR); 		cv::Mat mat = cv::Mat(cv::Size(image->getWidth(), image->getHeight()), CV_MAKETYPE(CV_8UC3, image->getPixels().getNumChannels()), image->getPixels().getData(), 0); 		this->caps.push_back(cap); 		this->images.push_back(move(image)); 		this->mats.push_back(mat); 	} } //-------------------------------------------------------------- void ofApp::update() { 	for (int i = 0; i < this->mats.size(); i++) { 		cv::Mat src; 		this->caps[i] >> src; 		if (src.empty()) { 			this->caps[i].set(cv::CAP_PROP_POS_FRAMES, 1); 			continue; 		} 		cv::resize(src, this->mats[i], cv::Size(this->rect_size, this->rect_size)); 		cv::cvtColor(this->mats[i], this->mats[i], cv::COLOR_BGR2RGB); 		this->images[i]->update(); 	} } //-------------------------------------------------------------- void ofApp::draw() { 	for (int i = 0; i < this->images.size(); i++) { 		ofSetColor(255); 		this->images[i]->draw(this->locations[i]); 		ofSetColor(0); 		ofDrawRectangle(this->locations[i], this->rect_size, this->rect_size); 	} } //-------------------------------------------------------------- int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); }  | 
					
[ Link ]
https://github.com/junkiyoshi/Insta20181215