Page 343 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 343
* URL("http://192.168.0.23:8082/?action=stream"))); } catch
* (IOException e) { // TODO Auto-generated catch block
* e.printStackTrace(); } webCam.start();
*/
}
//센서값 수신
class Sensor implements Runnable {
Thread beepThread;
@Override
public void run() {
try {
bufferedReader = new BufferedReader(new InputStreamReader(ETCSocket.getInput
Stream())); //소켓으로부터 필터스트림을 받아옴
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String tmp = "";
while (Strigger) {
try {
tmp = bufferedReader.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (tmp.equals("LOW")) { //센서에서 감지가 됬을시 비프음과 화면에 표시
System.out.println("low");
SensorLabel.setText("Metal Detect : O");
Toolkit.getDefaultToolkit().beep();
} else
SensorLabel.setText("Metal Detect : X");
Btrigger=false;
}
}
}
// 이미지 수신
class Webcam implements Runnable {
private static final String CONTENT_LENGTH = "Content-Length:";
private InputStream urlStream;
private StringWriter stringWriter;
private boolean processing = true;
public Webcam(URL url) throws IOException {
URLConnection urlConn = url.openConnection();
urlConn.setReadTimeout(10000);
urlConn.connect();
urlStream = urlConn.getInputStream();
stringWriter = new StringWriter(128);
}
private byte[] retrieveNextImage() throws IOException {
boolean haveHeader = false;
- 336 -