简体   繁体   English

使用Java从相机接收图像时的工件

[英]Artifacts when receiving image from camera in Java

Hey all, weird question. 大家好,奇怪的问题。 My company has an application from another company that records an image taken by a camera connected via Ethernet. 我公司有另一家公司的应用程序,该应用程序记录通过以太网连接的摄像机拍摄的图像。 Their app is written in C++ and I've been trying to convert/hack it using Java. 他们的应用是用C ++编写的,我一直在尝试使用Java对其进行转换/修改。

I'm able to receive images, but the quality is not the same. 我可以接收图像,但是质量不一样。 The photo on top is from their app and the photo on bottom is from mine: 顶部的照片来自他们的应用,底部的照片来自我的:

替代文字

替代文字

Any idea why those artifacts are showing up in my version of the app written in Java? 知道为什么这些工件会显示在我用Java编写的应用程序版本中吗? It happens with both BMP and JPG images. BMP和JPG图像均会发生这种情况。

The way it works is just through sockets (both the C++ and Java versions)... a command is sent to capture an image and the camera responds by sending the data (bytes). 它的工作方式仅通过套接字(C ++和Java版本)...发送命令以捕获图像,然后照相机通过发送数据(字节)进行响应。 I save a byte array then create a new BufferedImage from them: 我保存一个字节数组,然后从它们创建一个新的BufferedImage:

// Create buffered image from bytes
image = ImageIO.read(new ByteArrayInputStream(imageBytes));

Thanks for any input or ideas. 感谢您的任何意见或建议。

This looks like a palette problem, ie the numeric values of the individual pixels remain the same, but the table mapping those values onto actual RGB values may be messed up (actually, looking at the specific picture, it might even be that the source is BW and yours is color). 这看起来像一个调色板问题,即各个像素的数值保持不变,但是将这些值映射到实际RGB值的表可能会搞砸(实际上,查看特定的图片,甚至可能是源是BW,您的则是彩色)。 My guess would be that the transmission is not the problem. 我的猜测是传输不是问题。 Try sending a known bytestring to confirm that if you like, but I'd further concentrate on the image encoding. 尝试发送已知的字节串以确认是否愿意,但我将进一步关注图像编码。

Could it be a data type issue? 可能是数据类型问题吗? What is the data format? 数据格式是什么? (ints, shorts, unsigned shorts?) (整数,短裤,无符号短裤?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM