Files
2026-01-23 21:46:29 -08:00

69 lines
1.9 KiB
C++

#include "acidcam/ac.h"
static ac::MatrixCollection<32> collection;
extern "C" void init() {
std::cout << "square_block_v2c 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) {
collection.shiftFrames(frame);
static int square_size = 4, square_dir = 1;
static int index = 0;
static int dir = 1;
for(int z = 0; z < frame.rows; z += square_size) {
for(int i = 0; i < frame.cols; i += square_size) {
for(int y = 0; y < square_size; ++y) {
for(int x = 0; x < square_size; ++x) {
if(z+y < (frame.rows-1) && i+x < (frame.cols-1)) {
cv::Vec3b &pixel = ac::pixelAt(frame,z+y, i+x);
cv::Vec3b pix = collection.frames[index].at<cv::Vec3b>(z+y, i+x);
for(int j = 0; j < 3; ++j)
pixel[j] = ac::wrap_cast((0.5 * pixel[j]) + (0.5 * pix[j]));
}
}
}
}
if(dir == 1) {
++index;
if(index > (collection.size()-1)) {
index = collection.size()-1;
dir = 0;
}
} else {
--index;
if(index <= 0) {
index = 0;
dir = 1;
}
}
}
static int square_size_max = rand()%32;
if(square_dir == 1) {
square_size += 2;
if(square_size >= square_size_max) {
square_size = 8;
square_dir = 0;
square_size_max = rand()%32;
}
} else {
square_size -= 2;
if(square_size <= 2) {
square_size = 2;
square_dir = 1;
}
}
}