[ Video ]
[ About ]
GUCCI JAPANさんのツイートを見て面白いなと思いやってみました。
本日、#AlessandroMichele による #GucciFW18 コレクションのファッションショーがミラノのGucci Hubにて開催されます。日本時間23:00より、ランウェイのライブ配信をお楽しみください。#mfwhttps://t.co/aIO47vpHe3 pic.twitter.com/L4CPUwb11Z
— GUCCI JAPAN (@gucci_jp) 2018年2月21日
[ 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 |
#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 mouseEntered(int x, int y) {}; void mouseExited(int x, int y) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofFbo fbo; cv::VideoCapture cap; cv::Size cap_size; cv::Mat frame; ofImage image; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofBackground(0); ofSetWindowTitle("Insta"); this->cap.open(1); this->cap_size = cv::Size(1280, 720); ofSetFrameRate(this->cap.get(CV_CAP_PROP_FPS)); this->image.allocate(this->cap_size.width, this->cap_size.height, OF_IMAGE_COLOR); this->frame = cv::Mat(this->image.getHeight(), this->image.getWidth(), CV_MAKETYPE(CV_8UC3, this->image.getPixels().getNumChannels()), this->image.getPixels().getData(), 0); } //-------------------------------------------------------------- void ofApp::update() { cv::Mat cap_frame, src, blend_frame; this->cap >> cap_frame; if (cap_frame.empty()) { return; } cv::resize(cap_frame, src, this->cap_size); cv::flip(src, src, 1); cv::cvtColor(src, src, CV_RGB2BGR); for (int x = 0; x < src.cols; x++) { for (int y = 0; y < src.rows; y++) { ofVec2f center = ofVec2f(src.cols / 2, src.rows / 2); ofVec2f point = ofVec2f(x, y); float distance = center.distance(point); if (distance < 300) { int angle = distance / 20; point = point - center; point = point.getRotated(angle * ofGetFrameNum()); point = point + center; } float tmp_x = (int)point.x; float tmp_y = (int)point.y; if (tmp_x >= 0 && tmp_x < src.cols && tmp_y >= 0 && tmp_y < src.rows) { this->frame.at<cv::Vec3b>(tmp_y, tmp_x) = src.at<cv::Vec3b>(y, x); } } } this->image.update(); } //-------------------------------------------------------------- void ofApp::draw() { this->image.draw(0, 0); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(1280, 720, OF_WINDOW); ofRunApp(new ofApp()); } |