[ Video ]
[ About ]
Noise To R/G/B.
[ 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 64 65 66 |
#pragma once #include "ofMain.h" #include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #ifdef _DEBUG #pragma comment(lib,"opencv_calib3d330d.lib") #pragma comment(lib,"opencv_core330d.lib") #pragma comment(lib,"opencv_dnn330d.lib") #pragma comment(lib,"opencv_features2d330d.lib") #pragma comment(lib,"opencv_flann330d.lib") #pragma comment(lib,"opencv_highgui330d.lib") #pragma comment(lib,"opencv_imgcodecs330d.lib") #pragma comment(lib,"opencv_imgproc330d.lib") #pragma comment(lib,"opencv_ml330d.lib") #pragma comment(lib,"opencv_objdetect330d.lib") #pragma comment(lib,"opencv_photo330d.lib") #pragma comment(lib,"opencv_shape330d.lib") #pragma comment(lib,"opencv_stitching330d.lib") #pragma comment(lib,"opencv_superres330d.lib") #pragma comment(lib,"opencv_video330d.lib") #pragma comment(lib,"opencv_videoio330d.lib") #pragma comment(lib,"opencv_videostab330d.lib") #else #pragma comment(lib,"opencv_calib3d330.lib") #pragma comment(lib,"opencv_core330.lib") #pragma comment(lib,"opencv_dnn330.lib") #pragma comment(lib,"opencv_features2d330.lib") #pragma comment(lib,"opencv_flann330.lib") #pragma comment(lib,"opencv_highgui330.lib") #pragma comment(lib,"opencv_imgcodecs330.lib") #pragma comment(lib,"opencv_imgproc330.lib") #pragma comment(lib,"opencv_ml330.lib") #pragma comment(lib,"opencv_objdetect330.lib") #pragma comment(lib,"opencv_photo330.lib") #pragma comment(lib,"opencv_shape330.lib") #pragma comment(lib,"opencv_stitching330.lib") #pragma comment(lib,"opencv_superres330.lib") #pragma comment(lib,"opencv_video330.lib") #pragma comment(lib,"opencv_videoio330.lib") #pragma comment(lib,"opencv_videostab330.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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(0); ofSetWindowTitle("Insta"); this->frame_image.allocate(720,720, OF_IMAGE_COLOR); this->frame = cv::Mat(720, 720, 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 < 720; x++) { for (int y = 0; y < 720; y++) { r = 255 * ofNoise(x * 0.0025, y * 0.0025, (ofGetFrameNum() + 0) * 0.05); g = 255 * ofNoise(x * 0.0025, y * 0.0025, (ofGetFrameNum() + 15) * 0.05); b = 255 * ofNoise(x * 0.0025, y * 0.0025, (ofGetFrameNum() + 30) * 0.05); this->frame.at<cv::Vec3b>(x, y) = 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()); } |