- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
基本上我有一个摄像头芯片(摄像头模块:C3038,使用 OmniVision 的 CMOS 图像传感器 OV6630)通过 RS232 链路连接到 PC。我想在 Java 程序中读取这种格式的图像数据(根据相机规范):
数据格式——YCrCb 4:2:2、GRB 4:2:2、RGB 原始数据
关于如何操作的任何提示?
我的实现:
import gnu.io.CommPortIdentifier;
import gnu.io.PortInUseException;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import gnu.io.UnsupportedCommOperationException;
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.imageio.*;
public class SimpleRead1 implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
byte [] readBuffer;
static byte [] storeBuffer;
public SimpleRead1() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
}catch (PortInUseException e) {System.out.println(e);}
try {
inputStream = serialPort.getInputStream();
}catch (IOException e) {System.out.println(e);}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {System.out.println(e);}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {System.out.println(e);}
readThread = new Thread(this);
readThread.start();
}
public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {System.out.println(e);}
}
@Override
public void serialEvent(SerialPortEvent event){
switch(event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
readBuffer = new byte[Integer.MAX_VALUE];
try {
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
}
} catch (IOException e) {e.printStackTrace();}
InputStream in = new ByteArrayInputStream(readBuffer);
BufferedImage image = null;
try {
image = ImageIO.read(in);
} catch (IOException e) {e.printStackTrace();}
//GUI for displaying image
ImageIcon imageIcon = new ImageIcon(image);
JLabel label = new JLabel();
label.setIcon(imageIcon);
JFrame frame = new JFrame("image display");
frame.getContentPane().add(label,BorderLayout.CENTER);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
break;
}
}
public static void main(String[] args) throws Exception {
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals("COM7")) {
// if (portId.getName().equals("/dev/term/a")) {
SimpleRead1 reader = new SimpleRead1();
}
}
}
}
}
最佳答案
不幸的是,Java 本身不支持串行端口——为此您需要一个外部库。我建议看看 the RXTX library ,这似乎是如今的事实标准。
视频传感器芯片本身通常具有相对简单的通信接口(interface)(即没有桥接芯片)。通常它归结为设置图像参数,启动实际的图像数据传输,然后将一些字节读入缓冲区。有时可能涉及图像数据开始或结束签名,但仅此而已。
如果手边有芯片的所有文档,应该不会太难 - 我偶尔会在没有任何文档的情况下用 C 做类似的事情...
编辑:
将图像读取为字节数组后,您可以使用 the BufferedImage class使其可用于 Java。也就是说,我无法确定 Java 是否支持 ARGB 变体以外的任何东西——如果你想使用非-传感器中的 RGB 模式。
关于java - 相机图像处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10151822/
我只是想知道需要什么样的计算/编程语言/框架来生成图像,例如 http://www.erdas.com/ 中的图像。 ? 以编程方式,如何生成一般空间分析图像? ps:我大部分时间都在使用java。
我尝试在我的 grails 项目(Mac OS X 上的 1.1.1)中使用一些图像处理插件或 java 库:imageTools 插件、imageJ、awt 库等。每次我从路径打开/获取图像以启动进
我有一个项目,我必须以多种方式处理图像。我陷入了像素化的困境。 对于像素化,我必须采用一组 10x10 像素并返回一个单独平均 RGB 颜色的单元格。目前我在运行程序中得到的只是一个红色图像。谢谢您的
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
这是一项作业,因为我是Python编程新手,所以我付出了很大的努力: 我正在运行以下函数,它接受图像和短语(空格将被删除,因此只有文本)作为参数,我已经获得了所有导入和预处理代码,我只需要实现这个函数
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我需要一种简单易学且快速的方法来从背景图像、文本生成图像,然后保存为 JPEG 格式。 您有什么建议?有关于此的任何图书馆或教程吗?重要的标准是简单。 最佳答案 在 .Net 3.5/4 中,您还可以
我正在构建一个夜视应用程序,但我没有找到任何有用的算法可以应用于黑暗图像以使其清晰。任何人请给我一些好的算法。 提前致谢 最佳答案 由于 iphone 镜头和传感器的尺寸,无论您做什么,都会有很多噪音
所以我为游戏制作了这个程序,需要帮助让它更自动化一些。 程序接收图像然后显示它。我正在对 OpenGL 中的纹理执行此操作。当我截取游戏截图时,它通常约为 700x400。我将高度和宽度输入到我的程序
我想更改图像中像素的值,为此我需要将图像存储为矩阵。我怎样才能完成这项工作?请指导。 最佳答案 BufferedImage image = ImageIO.read(..); image.setRGB
概述: 我正在做一个视频创作项目。我使用的技术有:imageMagick、php、ffmpeg。 当前状态: 目前,该项目能够使用图像和文本以及很少的基本过渡来创建视频。我这样做的方式是使用 imag
我正在创建 facebook 应用程序,其中我将用户图像作为背景图像,并有一个用户可以四处移动的默认大写图像。用户将叠加图像(一顶帽子)放在正确的位置后,他点击保存 这就是我感到震惊的地方,我想知道如
我正在尝试编写一个 JavaScript 程序,通过在图像上放置三个垂直条纹来修改图像。左边三分之一是红色条纹,中间是绿色条纹,右边三分之一是蓝色条纹。 这是我试图实现的算法:1. 从您要更改的图像开
目前,我正在尝试通过图像分割方法将面部和头发修剪在一起,然后将所有非彩色像素设置为透明,然后尝试使用Binary Threshold技术和Adaptive Threshold。但是我得到了不希望的结果
我必须使此图像Book Image To Process的页面标题为:“单元3:主动学习的秘诀”,使其成为图像中的唯一页面 为此,我需要删除也在图像中的其他页面的一部分 我需要编写一个通用代码,可以对
我正在研究一个问题,其中我缩小图像的尺寸,在缩小图像中找到类似于二进制图像的有趣点。现在我只想放大在缩小图像中找到的有趣点(即白色像素点),而不是放大整个图像然后找到有趣的点。哪种技术可以最好地用于此
Closed. This question needs debugging details。它当前不接受答案。 想改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。 上个月关闭。 I
嗨,我需要编写一个程序,从灰度图像中删除分界(图像中带有文本) 我阅读了有关阈值和模糊的信息,但我仍然不知道该怎么做。 我的图像是这样的希伯来文本图像: 我需要删除分界线(假设分界线是图像中的最小元素
我正在做一个带有深度图像的项目。但是我的深度相机有噪音和像素读取失败的问题。有一些点和轮廓(尤其是边缘)的值为零。如何忽略这个零值并将其与周围的值混合? 我试过 dilation和 erosion (
我正在做一个大学项目,我需要在java中处理图像。前段时间我在数学实验室工作,这很容易,所以我想知道是否存在任何可以让我玩像素值、颜色(按像素)、RGB 模型、灰度图像等的 java 库。 最佳答案
我是一名优秀的程序员,十分优秀!