Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class filesen{
- static IplImage bimg;
- public static void main(String ar[])throws Exception{
- Socket clientSocket=new Socket("localhost",1234);
- CanvasFrame canvas = new CanvasFrame("sending");
- //int i=1;
- FrameGrabber grabber = new OpenCVFrameGrabber("");
- try {
- grabber.start();
- IplImage img;
- while (true) {
- OutputStream out=clientSocket.getOutputStream();
- img = grabber.grab();
- if (img != null) {
- opencv_highgui.cvSaveImage("a.jpg", img);
- FileInputStream fis=new FileInputStream("a.jpg");
- System.out.println(fis);
- int x=0;
- while(true){
- x=fis.read();
- if(x==-1)break;
- out.write(x);
- }
- bimg = opencv_highgui.cvLoadImage("a.jpg");
- canvas.showImage(bimg);
- // out.close();
- //canvas.showImage(img);
- i++;
- System.out.println(i);
- }
- }
- }
- catch (Exception e) {
- }
- }
- public class filere extends Applet {
- //static IplImage bimg;
- public static void main(String ar[]) throws Exception{
- CanvasFrame canvas = new CanvasFrame("Webcam");
- ServerSocket ss=new ServerSocket(1234);
- while(true){
- Socket clientSocket=ss.accept();
- InputStream in=clientSocket.getInputStream();
- //OutputStream out=clientSocket.getOutputStream();
- FileOutputStream fos=new FileOutputStream("b.jpg");
- int x=0;
- while(true){
- x=in.read();
- if(x==-1)break;
- fos.write(x);
- }
- bimg = opencv_highgui.cvLoadImage("b.jpg");
- canvas.showImage(bimg);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement