From: <mar...@gm...> - 2007-09-28 18:25:59
|
Hello, I'm having a strange problem with the data from the camera compress device (device index = 1), it is not ready, except for the first time it runs, so I can only see one image in the application and after that the while loop goes forever. When I use the camera device it works fine, there is always data ready, but I don't know how to show that kind of data as an image. Sometimes when the program is in the while loop I get this message: 28/09/2007 01:15:41 PM javaclient2.PlayerClient read WARNING: [PlayerClient]: Unknown message subtype received in read () I also know Player is working fine, I have probed it with playercam. So here is my code: import java.awt.*; import java.awt.image.*; import javax.swing.*; import java.awt.Graphics; import java.io.*; import javax.imageio.*; import javaclient2.CameraInterface; import javaclient2.structures.camera.PlayerCameraData; import javaclient2.PlayerClient; import javaclient2.PlayerException; import javaclient2.structures.PlayerConstants; public class CameraJPEG extends JFrame{ PlayerClient client = null; CameraInterface cami = null; PlayerCameraData camera = null; BufferedImage image = null; static byte[] img; InputStream stream; public CameraJPEG() { super("CameraJPEG"); Container container = getContentPane(); container.setLayout(null); container.setBackground(new Color(201, 199, 192)); setBounds(0,0,500,400); setVisible(true); try{ client = new PlayerClient("192.168.1.101", 6665); cami = client.requestInterfaceCamera(1, PlayerConstants.PLAYER_OPEN_MODE); } catch(PlayerException e) { e.printStackTrace(); } client.setNotThreaded(); camera = new PlayerCameraData(); try { Thread.sleep (1000); } catch (Exception e) {} while (true) { repaint(); client.requestDataDeliveryMode( PlayerConstants.PLAYER_DATAMODE_PULL); client.readAll(); client.requestAddReplaceRule (-1, -1, PlayerConstants.PLAYER_MSGTYPE_DATA, -1, 1); client.readAll(); while (!cami.isDataReady ()); camera = cami.getData(); img = camera.getImage(); stream = new ByteArrayInputStream(img,0, camera.getImage_count ()); try{ image = ImageIO.read(stream); } catch(Exception e) { e.printStackTrace(); } try{ stream.close(); } catch(IOException e) { e.printStackTrace(); } } } public void paint(Graphics g) { if (image != null) { g.drawImage(image, 0, 0, null); } else { g.clearRect(0, 0, getWidth(), getHeight()); g.drawString("Please Wait", 50, 100); } } public static void main(String[] args) { CameraJPEG aplication = new CameraJPEG(); aplication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } So, if anyone can help me i would really appreciate it. Thanks. Marcela |
From: John O. <joh...@gm...> - 2007-10-01 13:19:58
|
I think the problem is that you set PlayerClient to run not threaded, then after the initial client.readAll(); you then enter the infinate loop: while (!cami.isDataReady ()); and since there is no reading inside the loop to check for new data from player once this loop starts it will never end. I think something like: while (!cami.isDataReady ())client.readAll(); may work. thanks John Marcela G=C3=B3mez wrote: >=20 > Hello, > I'm having a strange problem with the data from the camera compress devic= e > (device index =3D 1), it is not ready, except for the first time it runs,= so > I > can only see one image in the application and after that the while loop > goes > forever. When I use the camera device it works fine, there is always data > ready, but I don't know how to show that kind of data as an image. > Sometimes when the program is in the while loop I get this message: >=20 > 28/09/2007 01:15:41 PM javaclient2.PlayerClient read > WARNING: [PlayerClient]: Unknown message subtype received in read () >=20 > I also know Player is working fine, I have probed it with playercam. So > here > is my code: >=20 > import java.awt.*; > import java.awt.image.*; > import javax.swing.*; > import java.awt.Graphics; > import java.io.*; > import javax.imageio.*; > import javaclient2.CameraInterface; > import javaclient2.structures.camera.PlayerCameraData; > import javaclient2.PlayerClient; > import javaclient2.PlayerException; > import javaclient2.structures.PlayerConstants; >=20 >=20 > public class CameraJPEG extends JFrame{ >=20 > PlayerClient client =3D null; > CameraInterface cami =3D null; > PlayerCameraData camera =3D null; >=20 > BufferedImage image =3D null; > static byte[] img; > InputStream stream; >=20 >=20 > public CameraJPEG() { >=20 > super("CameraJPEG"); >=20 > Container container =3D getContentPane(); > container.setLayout(null); > container.setBackground(new Color(201, 199, 192)); >=20 > setBounds(0,0,500,400); > setVisible(true); >=20 > try{ > client =3D new PlayerClient("192.168.1.101", 6665); > cami =3D client.requestInterfaceCamera(1, > PlayerConstants.PLAYER_OPEN_MODE); > } > catch(PlayerException e) > { > e.printStackTrace(); > } >=20 > client.setNotThreaded(); > camera =3D new PlayerCameraData(); >=20 > try { > Thread.sleep (1000); > } > catch (Exception e) {} >=20 > while (true) > { > repaint(); > client.requestDataDeliveryMode( > PlayerConstants.PLAYER_DATAMODE_PULL); > client.readAll(); > client.requestAddReplaceRule (-1, -1, > PlayerConstants.PLAYER_MSGTYPE_DATA, -1, 1); > client.readAll(); > while (!cami.isDataReady ()); > camera =3D cami.getData(); > img =3D camera.getImage(); > stream =3D new ByteArrayInputStream(img,0, camera.getImage_co= unt > ()); >=20 > try{ > image =3D ImageIO.read(stream); > } > catch(Exception e) > { > e.printStackTrace(); > } >=20 > try{ > stream.close(); > } > catch(IOException e) > { > e.printStackTrace(); > } > } >=20 > } >=20 > public void paint(Graphics g) > { > if (image !=3D null) > { > g.drawImage(image, 0, 0, null); > } > else > { > g.clearRect(0, 0, getWidth(), getHeight()); > g.drawString("Please Wait", 50, 100); > } > } >=20 > public static void main(String[] args) > { > CameraJPEG aplication =3D new CameraJPEG(); > aplication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); >=20 > } >=20 > } >=20 > So, if anyone can help me i would really appreciate it. > Thanks. > Marcela >=20 > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Java-player-users mailing list > Jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-player-users >=20 >=20 --=20 View this message in context: http://www.nabble.com/Camera-compress-data-ne= ver-ready-tf4536101.html#a12978954 Sent from the java-player-users mailing list archive at Nabble.com. |
From: <mar...@gm...> - 2007-10-01 15:57:11
|
I tried with your option but I didn't get anything, I also tried with the runThreaded but is always the same, there is no data ready. I don't know wh= y with the camera device (no compress) works fine if I'm using the same routine but the camera compress just read once. Thanks Marcela ---------- Forwarded message ---------- From: John Oliver <joh...@gm...> Date: 01/10/2007 08:19 Subject: Re: [Java-player-users] Camera compress data never ready To: jav...@li... I think the problem is that you set PlayerClient to run not threaded, then after the initial client.readAll(); you then enter the infinate loop: while (!cami.isDataReady ()); and since there is no reading inside the loop to check for new data from player once this loop starts it will never end. I think something like: while (!cami.isDataReady ())client.readAll(); may work. thanks John Marcela G=F3mez wrote: > > Hello, > I'm having a strange problem with the data from the camera compress devic= e > (device index =3D 1), it is not ready, except for the first time it runs,= so > I > can only see one image in the application and after that the while loop > goes > forever. When I use the camera device it works fine, there is always data > ready, but I don't know how to show that kind of data as an image. > Sometimes when the program is in the while loop I get this message: > > 28/09/2007 01:15:41 PM javaclient2.PlayerClient read > WARNING: [PlayerClient]: Unknown message subtype received in read () > > I also know Player is working fine, I have probed it with playercam. So > here > is my code: > > import java.awt.*; > import java.awt.image.*; > import javax.swing.*; > import java.awt.Graphics; > import java.io.*; > import javax.imageio.*; > import javaclient2.CameraInterface; > import javaclient2.structures.camera.PlayerCameraData; > import javaclient2.PlayerClient; > import javaclient2.PlayerException; > import javaclient2.structures.PlayerConstants; > > > public class CameraJPEG extends JFrame{ > > PlayerClient client =3D null; > CameraInterface cami =3D null; > PlayerCameraData camera =3D null; > > BufferedImage image =3D null; > static byte[] img; > InputStream stream; > > > public CameraJPEG() { > > super("CameraJPEG"); > > Container container =3D getContentPane(); > container.setLayout(null); > container.setBackground (new Color(201, 199, 192)); > > setBounds(0,0,500,400); > setVisible(true); > > try{ > client =3D new PlayerClient("192.168.1.101 ", 6665); > cami =3D client.requestInterfaceCamera(1, > PlayerConstants.PLAYER_OPEN_MODE); > } > catch(PlayerException e) > { > e.printStackTrace(); > } > > client.setNotThreaded(); > camera =3D new PlayerCameraData(); > > try { > Thread.sleep (1000); > } > catch (Exception e) {} > > while (true) > { > repaint(); > client.requestDataDeliveryMode( > PlayerConstants.PLAYER_DATAMODE_PULL); > client.readAll(); > client.requestAddReplaceRule (-1, -1, > PlayerConstants.PLAYER_MSGTYPE_DATA, -1, 1); > client.readAll(); > while (!cami.isDataReady ()); > camera =3D cami.getData(); > img =3D camera.getImage(); > stream =3D new ByteArrayInputStream(img,0, camera.getImage_co= unt > ()); > > try{ > image =3D ImageIO.read(stream); > } > catch(Exception e) > { > e.printStackTrace(); > } > > try{ > stream.close(); > } > catch(IOException e) > { > e.printStackTrace(); > } > } > > } > > public void paint(Graphics g) > { > if (image !=3D null) > { > g.drawImage(image, 0, 0, null); > } > else > { > g.clearRect(0, 0, getWidth(), getHeight()); > g.drawString("Please Wait", 50, 100); > } > } > > public static void main(String[] args) > { > CameraJPEG aplication =3D new CameraJPEG(); > aplication.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > > } > > } > > So, if anyone can help me i would really appreciate it. > Thanks. > Marcela > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Java-player-users mailing list > Jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-player-users > > -- View this message in context: http://www.nabble.com/Camera-compress-data-never-ready-tf4536101.html#a1297= 8954 Sent from the java-player-users mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Java-player-users mailing list Jav...@li... https://lists.sourceforge.net/lists/listinfo/java-player-users --=20 +++++++++++++++++++++++++++++++++++++++ David Leonardo Acosta Molano M=F3vil 300 620 56 08 Cali - Colombia +++++++++++++++++++++++++++++++++++++++ |