java 读取com口数据,在Java中从COM7端口读取图像数据

I am doing a project in which I have to display the image captured from a camera chip on to the PC.

The image data is being sent through the COM7 port to the computer. (I have checked it using a dumb terminal program). Basically what I want to do is to develop a Java program that will read the COM port, get the image data, process it and display it on the screen.

What I want to know is how to read this image data from COM7 port in my Java program.

解决方案

For the serial port portion of the problem, read the serial port like any other file.

On 'nix, serial ports are named /dev/ttySn where n 0-3 for COM1 to COM4. I'm guessing that if more serial ports exist, appropriately named files will exist on your system to access these too.

on Windows you can just use the special file names COM1, COM2, etc.

As for actually reading the image data, as mentioned by others, you will need to know what format it is in. You can try using ImageIO.read() if it is in one of Java's known file formats. If it is in a raw bitmap format, you could try constructing a buffered image from the raw data by creating a BufferedImage from a Raster, and a Raster from an appropriate SampleModel and DataBuffer. You will need to know the format of the bitmap data to do this, however.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值