असल में मेरे पास एक कैमरा चिप है (कैमरा मॉड्यूल: सी 3038, ओमनीविजन के सीएमओएस छवि सेंसर ओवी 6630 का उपयोग करता है) एक पीसी से आरएस 232 लिंक के माध्यम से जुड़ा हुआ है। मैं (कैमरा विनिर्देश के अनुसार) एक जावा प्रोग्राम जो इस प्रारूप में में छवि डेटा पढ़ना चाहते हैं:कैमरा छवि प्रसंस्करण
डाटा प्रारूप - YCrCb 4: 2: 2, GRB 4: 2: 2, आरजीबी कच्चे डाटा
इसे कैसे करें इस पर कोई संकेत?
मेरे कार्यान्वयन:
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();
}
}
}
}
}
कैमरा मॉड्यूल: सी 3038, ओमनीविजन के सीएमओएस छवि सेंसर ओवी 6630 का उपयोग करता है। – stud91
धन्यवाद, उस जानकारी को संपादित किया गया। इसे और अधिक प्रमुख बनाने के लिए सवाल में। जवाब नहीं जानते, लेकिन दिलचस्प सवाल है। +1 –