[ Video ]
[ About ]
Noise to R/G/B.
Split Display.
[ 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 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 |
#pragma once #include "ofMain.h" #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #ifdef _DEBUG #pragma comment(lib,"opencv_calib3d310d.lib") #pragma comment(lib,"opencv_core310d.lib") #pragma comment(lib,"opencv_features2d310d.lib") #pragma comment(lib,"opencv_flann310d.lib") #pragma comment(lib,"opencv_highgui310d.lib") #pragma comment(lib,"opencv_imgcodecs310d.lib") #pragma comment(lib,"opencv_imgproc310d.lib") #pragma comment(lib,"opencv_ml310d.lib") #pragma comment(lib,"opencv_objdetect310d.lib") #pragma comment(lib,"opencv_photo310d.lib") #pragma comment(lib,"opencv_shape310d.lib") #pragma comment(lib,"opencv_stitching310d.lib") #pragma comment(lib,"opencv_superres310d.lib") #pragma comment(lib,"opencv_video310d.lib") #pragma comment(lib,"opencv_videoio310d.lib") #pragma comment(lib,"opencv_videostab310d.lib") #else #pragma comment(lib,"opencv_calib3d310.lib") #pragma comment(lib,"opencv_core310.lib") #pragma comment(lib,"opencv_features2d310.lib") #pragma comment(lib,"opencv_flann310.lib") #pragma comment(lib,"opencv_highgui310.lib") #pragma comment(lib,"opencv_imgcodecs310.lib") #pragma comment(lib,"opencv_imgproc310.lib") #pragma comment(lib,"opencv_ml310.lib") #pragma comment(lib,"opencv_objdetect310.lib") #pragma comment(lib,"opencv_photo310.lib") #pragma comment(lib,"opencv_shape310.lib") #pragma comment(lib,"opencv_stitching310.lib") #pragma comment(lib,"opencv_superres310.lib") #pragma comment(lib,"opencv_video310.lib") #pragma comment(lib,"opencv_videoio310.lib") #pragma comment(lib,"opencv_videostab310.lib") #endif 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) {}; cv::Mat frame; ofImage frame_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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(0); ofSetWindowTitle("Insta"); this->frame_image.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR); this->frame = cv::Mat(ofGetHeight(), ofGetWidth(), CV_MAKETYPE(CV_8UC3, this->frame_image.getPixels().getNumChannels()), this->frame_image.getPixels().getData(), 0); } //-------------------------------------------------------------- void ofApp::update() { float noise_value_r, noise_value_g, noise_value_b; float r, g, b; for (int x = 0; x < ofGetWidth(); x++) { for (int y = 0; y < ofGetHeight(); y++) { r = 0; g = 0; b = 0; if (x < ofGetWidth() / 2) { r = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 0) * 0.05); g = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 15) * 0.05); b = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 30) * 0.05); } else { if (y <= ofGetHeight() / 3) { r = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 0) * 0.05); } else if (y <= ofGetHeight() / 3 * 2) { g = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 15) * 0.05); } else { b = 255 * ofNoise(x * 0.005, y * 0.005, (ofGetFrameNum() + 30) * 0.05); } } this->frame.at<cv::Vec3b>(y, x) = cv::Vec3b(r, g, b); } } } //-------------------------------------------------------------- void ofApp::draw() { this->frame_image.update(); this->frame_image.draw(0, 0); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |