← index
glitch.gui/examples/line_collection06/plugin.cpp
Source: glitch.gui/examples/line_collection06/plugin.cpp
#include "acidcam/ac.h"

static constexpr int MAX = 8;
static ac::MatrixCollection<MAX> collection;

extern "C" void init() {
    std::cout << "line_collection06 initialized...\n";
    srand(static_cast<unsigned int>(time(0)));
}

extern "C" void rls() {
    ac::release_all_objects();
}

extern "C" void clear() {
    std::cout << "Clear called..\n";
    ac::release_all_objects();
}

extern "C" void proc(cv::Mat  &frame) {
    if(collection.empty()) {
        srand(static_cast<unsigned int>(time(0)));
        collection.shiftFrames(frame);
    }
    else if(rand()%3 == 0)
        collection.shiftFrames(frame);
    
    
    for(int z = 0; z < frame.rows; ++z) {
        
        int cnt = 0;
        int offset = rand()%(MAX-1);
      
        for(int i = 0; i < frame.cols; ++i) {
            cv::Vec3b &pixel = ac::pixelAt(frame, z, i);
            cv::Vec3b pix = collection.frames[offset].at<cv::Vec3b>(z, i);
            pixel = pix;
            
            if(++cnt > rand()%50) {
                cnt = 0;
                if(++offset > MAX-1)
                    offset = 0;
            }
        }
    }
}