Results 1 to 4 of 4
  1. #1
    ZinoKinG is offline Member
    Join Date
    Feb 2015
    Posts
    2
    Rep Power
    0

    Default Sending a BufferedImage of webcam in a Socket - Jmyron

    0
    down vote
    favorite
    I'm trying to send a video captured by a webcam from a server to a client.

    I'm using Jmyron in netbeans to get the camera.

    First, I used BufferedImage.toString() and tried to send the string I was getting over a socket. I also tried to turn the BufferedImage into a byte array and send it so I can do the reverse process in the other side. It seems that the Socket is sending one line and then stopping. So could you tell me if there is another way to do this. Or maybe I'm doing something wrong ?

    Also is RTP available in Jmyron? Because I want to send the video in real time.

    I'm sending this from the server : BufferedImage captureImage

    Java Code:
      boolean Test= true;
            while (Test) {
            ServerSocket ser = new ServerSocket(25000);
            Socket sock = ser.accept();
    
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
             ImageIO.write( captureImage, "jpg", baos );
             baos.flush();
             byte[] imageInByte = baos.toByteArray();
             baos.close(); 
    
             DataOutputStream dOut = new DataOutputStream(sock.getOutputStream());
             dOut.write(imageInByte);
    
          }

    receiving from the client :

    Java Code:
    boolean Test = true ;
    
    public Clientcam() throws IOException {
        initComponents();
    
       while (Test) { 
    
              Socket ser = new Socket("localhost",25000);
    
              byte[] b = null ;  
            DataInputStream dIn = new DataInputStream(ser.getInputStream());
            dIn.readFully(b);
            InputStream in = new ByteArrayInputStream(b);
            newImage = ImageIO.read(in);
            newlbl.setIcon(new ImageIcon(newImage));
    
        }
    
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Sending a BufferedImage of webcam in a Socket - Jmyron

    Can you add links to the other sites where this question is posted?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: Sending a BufferedImage of webcam in a Socket - Jmyron

    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    ZinoKinG is offline Member
    Join Date
    Feb 2015
    Posts
    2
    Rep Power
    0

    Default Re: Sending a BufferedImage of webcam in a Socket - Jmyron

    Quote Originally Posted by Norm View Post
    Can you add links to the other sites where this question is posted?
    I've only posted this question here , and in Stackoverflow

    Sending a BufferedImage of webcam in a Socket

Similar Threads

  1. BufferedImage Distortion Over Socket?
    By Incisus in forum Advanced Java
    Replies: 3
    Last Post: 12-14-2012, 02:28 PM
  2. Sending files over socket
    By m_james22 in forum Networking
    Replies: 1
    Last Post: 04-26-2012, 10:14 AM
  3. Sending BufferedImage through socket
    By Desh Banks in forum Networking
    Replies: 9
    Last Post: 01-30-2011, 05:05 PM
  4. Sending object through socket
    By Alexandrinne in forum New To Java
    Replies: 0
    Last Post: 11-15-2010, 07:03 AM
  5. Sending a file through socket
    By sureshkumarcs88 in forum Networking
    Replies: 2
    Last Post: 03-14-2009, 07:32 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •