Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. public class filesen{
  2. static IplImage bimg;
  3. public static void main(String ar[])throws Exception{
  4. Socket clientSocket=new Socket("localhost",1234);
  5. CanvasFrame canvas = new CanvasFrame("sending");
  6. //int i=1;
  7. FrameGrabber grabber = new OpenCVFrameGrabber("");
  8. try {
  9. grabber.start();
  10. IplImage img;
  11. while (true) {
  12. OutputStream out=clientSocket.getOutputStream();
  13. img = grabber.grab();
  14. if (img != null) {
  15.  
  16. opencv_highgui.cvSaveImage("a.jpg", img);
  17.  
  18. FileInputStream fis=new FileInputStream("a.jpg");
  19. System.out.println(fis);
  20. int x=0;
  21. while(true){
  22. x=fis.read();
  23. if(x==-1)break;
  24. out.write(x);
  25. }
  26. bimg = opencv_highgui.cvLoadImage("a.jpg");
  27. canvas.showImage(bimg);
  28. // out.close();
  29. //canvas.showImage(img);
  30. i++;
  31. System.out.println(i);
  32. }
  33.  
  34. }
  35.  
  36. }
  37. catch (Exception e) {
  38. }
  39. }
  40.  
  41. public class filere extends Applet {
  42. //static IplImage bimg;
  43. public static void main(String ar[]) throws Exception{
  44. CanvasFrame canvas = new CanvasFrame("Webcam");
  45. ServerSocket ss=new ServerSocket(1234);
  46. while(true){
  47. Socket clientSocket=ss.accept();
  48. InputStream in=clientSocket.getInputStream();
  49. //OutputStream out=clientSocket.getOutputStream();
  50. FileOutputStream fos=new FileOutputStream("b.jpg");
  51. int x=0;
  52. while(true){
  53. x=in.read();
  54. if(x==-1)break;
  55. fos.write(x);
  56. }
  57. bimg = opencv_highgui.cvLoadImage("b.jpg");
  58. canvas.showImage(bimg);
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement