Я пытаюсь создать обрабатываемую программу, которая принимает видеопоток в реальном времени от SDK Kinect 4win (X-Box) и создает мозаичное представление. Камера может потенциально использоваться для обнаружения светлых и темных участков изображения и отображениясветлые и темные квадраты.Я также исследовал идею создания мозаики из небольших изображений и ссылался на учебник Даниэля Шиффмана (https://www.youtube.com/watch?v=nnlAH1zDBDE),, но он не включает камеру Kinect. Есть ли у кого-нибудь идеи о том, как использовать Kinect дляполучить видео поток и создать мозаику, используя эти данные? Я включил ниже пример кода, который не включает Kinect.
// interactive miror
// Each pixel from the video source is drawn as a
// rectangle with size based on brightness.
import processing.video.*;
// Size of each cell in the grid
int videoScale =10;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;
void setup() {
size(740,580);
// Initialize columns and rows
cols = width/videoScale;
rows = height/videoScale;
smooth();
// Construct the Capture object
video = new Capture(this,cols,rows,15);
}
void draw() {
if (video.available()) {
video.read();
}
background(0);
video.loadPixels();
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Where are we, pixel-wise?
int x = i*videoScale;
int y = j*videoScale;
// Reversing x to mirror the image
// In order to mirror the image, the column is reversed with the following formula:
// mirrored column = width - column - 1
int loc = (video.width - i - 1) + j*video.width;
// Each rect is colored white with a size determined by brightness
color c = video.pixels[loc];
// A rectangle size is calculated as a function of the pixel's brightness.
// A bright pixel is a large rectangle, and a dark pixel is a small one.
float sz = (brightness(c)/255.0)*videoScale;
rectMode(CENTER);
fill(255);
noStroke();
rect(x + videoScale/2,y + videoScale/2,sz,sz);
}
}
}
Я ожидал, что этот код будет выполняться в процессе обработки, но при тестировании были некоторые незначительные ошибкис открытием камеры и получением видеопотока.