Java 将图像中的像素复制到网络摄像头
我想做的是把摄像机上的像素转换成图像 为了解释它,最好想象一个三维模型。。像素是每个多边形,我想做的是将每个多边形转换成一个图像 到目前为止,我得到的是:Java 将图像中的像素复制到网络摄像头,java,image,converter,pixel,processing,Java,Image,Converter,Pixel,Processing,我想做的是把摄像机上的像素转换成图像 为了解释它,最好想象一个三维模型。。像素是每个多边形,我想做的是将每个多边形转换成一个图像 到目前为止,我得到的是: ** import processing.video.*; PImage hoja; Capture cam; boolean uno, dos, tres, cuatro; import ddf.minim.*; Minim minim; AudioPlayer audio; float set; void setup() {
**
import processing.video.*;
PImage hoja;
Capture cam;
boolean uno, dos, tres, cuatro;
import ddf.minim.*;
Minim minim;
AudioPlayer audio;
float set;
void setup() {
//audio
minim = new Minim(this);
// audio = minim.loadFile("audio");
// audio.loop();
//
uno=false;
dos=false;
tres=false;
cuatro=true;
size(640, 480);
hoja=loadImage("hoja.gif");
cam = new Capture(this, width, height);
cam.start();
}
void draw() {
if (cam.available() == true) {
cam.read();
if (uno==true) {
filtroUno();
image(cam, 0, 0, 640, 480);
}
if (dos==true) {
filtroDos();
}
if(tres==true){
filtroTres();
}
if(cuatro==true){
filtroCuatro();
image(cam, set, 0,640,480);
}
}
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(0, 0, cam);
}
void filtroUno() {
cam.loadPixels();
hoja.loadPixels();
for (int i=0;i<cam.pixels.length;i++) {
if (brightness(cam.pixels[i])>110) {
cam.pixels[i]=color(0, 255, 255);
}
else {
cam.pixels[i]=color(255, 0, 0);
}
}
for (int i=0;i<cam.width;i+=10) {
for (int j=0;j<cam.height;j+=10) {
int loc=i+(j*cam.width);
if (cam.pixels[loc]==color(255, 0, 0)) {
for (int x=i;x<i+10;x++) {
for (int y=j;y<j+10;y++) {
// println("bla");
int locDos=i+(j*cam.width);
cam.pixels[locDos]=hoja.get(x, y);
}
}
}
}
}
cam.updatePixels();
}
**
**
导入处理。视频。*;
皮马杰·霍亚;
捕捉凸轮;
布尔uno、dos、tres、cuatro;
进口ddf.微量。*;
极小极小;
音频播放器音频;
浮动装置;
无效设置(){
//音频
最小值=新的最小值(本);
//音频=最小加载文件(“音频”);
//loop();
//
uno=假;
dos=假;
tres=假;
cuatro=真;
尺寸(640480);
hoja=loadImage(“hoja.gif”);
cam=新捕获(此、宽度、高度);
cam.start();
}
作废提款(){
if(cam.available()==true){
cam.read();
如果(uno==true){
filtroUno();
图像(cam,0,0,640,480);
}
如果(dos==true){
filtroDos();
}
如果(tres==true){
filterotres();
}
如果(cuatro==真){
filterocuatro();
图像(cam,set,0640480);
}
}
//以下操作与此相同,并且在仅绘制图像时速度更快
//无需任何额外的大小调整、变换或着色。
//设置(0,0,凸轮);
}
void filtroUno(){
cam.loadPixels();
hoja.loadPixels();
对于(int i=0;i110){
凸轮像素[i]=颜色(0,255,255);
}
否则{
凸轮像素[i]=颜色(255,0,0);
}
}
对于(int i=0;i我认为您所做的是在网络摄像头图像中每10个像素循环一次,如果像素为红色,则将10x10px gif的内容放置在网络摄像头图像上,gif的左上角位于红色像素处
// loop through each 10th column in the camera
for (int i=0;i<cam.width;i+=10) {
// loop through each 10th row in the camera
for (int j=0;j<cam.height;j+=10) {
// calculate the pixel location at (i, j)
int loc=i+(j*cam.width);
// check the pixel is red
if (cam.pixels[loc]==color(255, 0, 0)) {
// loop through each column in the gif image
for (int x=0;x<10;x++) {
// loop through each row in the gif image
for (int y=0;y<10;y++) {
int locDos = (i + x) + ((j + y) * cam.width);
cam.pixels[locDos]=hoja.get(x, y);
}
}
}
}
}
//在相机中的第10列中循环
对于(int i=0;i我认为您所做的是在网络摄像头图像中每10个像素循环一次,如果像素为红色,则将10x10px gif的内容放置在网络摄像头图像上,gif的左上角位于红色像素处
// loop through each 10th column in the camera
for (int i=0;i<cam.width;i+=10) {
// loop through each 10th row in the camera
for (int j=0;j<cam.height;j+=10) {
// calculate the pixel location at (i, j)
int loc=i+(j*cam.width);
// check the pixel is red
if (cam.pixels[loc]==color(255, 0, 0)) {
// loop through each column in the gif image
for (int x=0;x<10;x++) {
// loop through each row in the gif image
for (int y=0;y<10;y++) {
int locDos = (i + x) + ((j + y) * cam.width);
cam.pixels[locDos]=hoja.get(x, y);
}
}
}
}
}
//在相机中的第10列中循环
对于(int i=0;i