Torna indietro   Hardware Upgrade Forum > Software > Programmazione

DJI RS 5: stabilizzazione e tracking intelligente per ogni videomaker
DJI RS 5: stabilizzazione e tracking intelligente per ogni videomaker
Analizziamo nel dettaglio DJI RS 5, l'ultimo arrivato della famiglia Ronin progettato per videomaker solisti e piccoli studi. Tra tracciamento intelligente migliorato e ricarica ultra rapida, scopriamo come questo gimbal eleva la qualità delle produzioni.
AMD Ryzen 7 9850X3D: Zen 5, 3D V-Cache e frequenze al top per il gaming
AMD Ryzen 7 9850X3D: Zen 5, 3D V-Cache e frequenze al top per il gaming
AMD Ryzen 7 9850X3D è la nuova CPU gaming di riferimento grazie alla 3D V-Cache di seconda generazione e frequenze fino a 5,6 GHz. Nei test offre prestazioni superiori a 9800X3D e 7800X3D, confermando la leadership AMD nel gaming su PC.
Le soluzioni FSP per il 2026: potenza e IA al centro
Le soluzioni FSP per il 2026: potenza e IA al centro
In occasione del Tech Tour 2025 della European Hardware Association abbiamo incontrato a Taiwan FSP, azienda impegnata nella produzione di alimentatori, chassis e soluzioni di raffreddamento tanto per clienti OEM come a proprio marchio. Potenze sempre più elevate negli alimentatori per far fronte alle necessità delle elaborazioni di intelligenza artificiale.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 13-12-2012, 10:20   #1
topix93
Member
 
Iscritto dal: Dec 2009
Messaggi: 98
[JAVA] visualizzare stream webcamera

Ho una telecamera a cui posso accedere allo streaming video attraverso l'indirizzo http://<camera ip>/video/mjpg.cgi... vorrei inculdere quello stream in una mia finestra.
come posso riuscire a fare ciò?? conoscete qualche libreria che può essermi d'aiuto??
topix93 è offline   Rispondi citando il messaggio o parte di esso
Old 13-12-2012, 16:27   #2
topix93
Member
 
Iscritto dal: Dec 2009
Messaggi: 98
Ho trovato questo esempio, ma non riesco a farlo funzionare in quanto mi restituisce un errore nel metodo 'public void readJPG()'... ecco l'errore che mi restituisce:
com.sun.image.codec.jpeg.ImageFormatException: Not a JPEG file: starts with 0x78 0x2d
at sun.awt.image.codec.JPEGImageDecoderImpl.readJPEGStream(Native Method)
at sun.awt.image.codec.JPEGImageDecoderImpl.decodeAsBufferedImage(Unknown Source)
at AxisCamera.readJPG(AxisCamera.java:102)
at AxisCamera.readMJPGStream(AxisCamera.java:95)
at AxisCamera.initDisplay(AxisCamera.java:51)
at AxisCamera.connect(AxisCamera.java:40)
at AxisCamera.run(AxisCamera.java:127)
at java.lang.Thread.run(Unknown Source)

come posso risolvere?

Codice:
import java.net.*;
import com.sun.image.codec.jpeg.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
/**
 *
 * @author David E. Mireles, Ph.D.
 */
public class AxisCamera extends JPanel implements Runnable {
	public boolean useMJPGStream = true;
	public String jpgURL="http://your-ip-here/axis-cgi/jpg/image.cgi?resolution=352x240";
	public String mjpgURL="http://192.168.1.20/video/mjpg.cgi";
	DataInputStream dis;
	private Image image=null;
	public Dimension imageSize = null;
	public boolean connected = false;
	private boolean initCompleted = false;
	HttpURLConnection huc=null;
	Component parent;
	
	/** Creates a new instance of AxisCamera */
	public AxisCamera (Component parent_) {
		parent = parent_;
	}
	
	public void connect(){
		try{
			MyAuthenticator auth = new MyAuthenticator("admin", "");
			Authenticator.setDefault(auth);
			URL u = new URL(useMJPGStream?mjpgURL:jpgURL);
			huc = (HttpURLConnection) u.openConnection();
			//System.out.println(huc.getContentType());
			InputStream is = huc.getInputStream();
			connected = true;
			BufferedInputStream bis = new BufferedInputStream(is);
			dis= new DataInputStream(bis);
			if (!initCompleted) initDisplay();
		}catch(IOException e){ //incase no connection exists wait and try again, instead of printing the error
			try{
				huc.disconnect();
				Thread.sleep(60);
			}catch(InterruptedException ie){huc.disconnect();connect();}
			connect();
		}catch(Exception e){;}
	}
	
	public void initDisplay(){ //setup the display
		if (useMJPGStream)readMJPGStream();
		else {readJPG();disconnect();}
		imageSize = new Dimension(image.getWidth(this), image.getHeight(this));
		setPreferredSize(imageSize);
		parent.setSize(imageSize);
		parent.validate();
		initCompleted = true;
	}
	
	public void disconnect(){
		try{
			if(connected){
				dis.close();
				connected = false;
			}
		}catch(Exception e){;}
	}
	
	public void paint(Graphics g) { //used to set the image on the panel
		if (image != null)
			g.drawImage(image, 0, 0, this);
	}
	
	public void readStream(){ //the basic method to continuously read the stream
		try{
			if (useMJPGStream){
				while(true){
					readMJPGStream();
					parent.repaint();
				}
			}
			else{
				while(true){
					connect();
					readJPG();
					parent.repaint();
					disconnect();
				}
			}
		}catch(Exception e){;} 
	}
	
	public void readMJPGStream(){ //preprocess the mjpg stream to remove the mjpg encapsulation
		readLine(4,dis); 
		readJPG();
		readLine(1,dis); 
	}
	
	public void readJPG(){ //read the embedded jpeg image
		try{
			JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(dis);
			image = decoder.decodeAsBufferedImage();
		}catch(Exception e){e.printStackTrace();disconnect();}
	}
	
	public void readLine(int n, DataInputStream dis){ //used to strip out the header lines
		for (int i=0; i<n;i++){
			readLine(dis);
		}
	}
	
	public void readLine(DataInputStream dis){
		try{
			boolean end = false;
			String lineEnd = "\n"; //assumes that the end of the line is marked with this
			byte[] lineEndBytes = lineEnd.getBytes();
			byte[] byteBuf = new byte[lineEndBytes.length];
			while(!end){
				dis.read(byteBuf,0,lineEndBytes.length);
				String t = new String(byteBuf);
				//System.out.print(t); //uncomment if you want to see what the lines actually look like
				if(t.equals(lineEnd)) end=true;
			}
		}catch(Exception e){e.printStackTrace();}
	}
	public void run() {
		connect();
		readStream();
	}

	public static void main(String[] args) {
		JFrame jframe = new JFrame();
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		AxisCamera axPanel = new AxisCamera(jframe);
		new Thread(axPanel).start();
		jframe.getContentPane().add(axPanel);
		jframe.pack();
		jframe.show();
	}
}
topix93 è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


DJI RS 5: stabilizzazione e tracking intelligente per ogni videomaker DJI RS 5: stabilizzazione e tracking intelligent...
AMD Ryzen 7 9850X3D: Zen 5, 3D V-Cache e frequenze al top per il gaming AMD Ryzen 7 9850X3D: Zen 5, 3D V-Cache e frequen...
Le soluzioni FSP per il 2026: potenza e IA al centro Le soluzioni FSP per il 2026: potenza e IA al ce...
AWS annuncia European Sovereign Cloud, il cloud sovrano per convincere l'Europa AWS annuncia European Sovereign Cloud, il cloud ...
Redmi Note 15 Pro+ 5G: autonomia monstre e display luminoso, ma il prezzo è alto Redmi Note 15 Pro+ 5G: autonomia monstre e displ...
Tesla, è ufficiale: i Robotaxi fa...
DeepL sempre più evoluto: arriva ...
Un vecchio assegno venduto a 4.800 volte...
Portatili Dell 16 in offerta su Amazon: ...
Amazfit punta ancora più in alto:...
Deep tech e venture capital: ScaleUp Lab...
GWM ha creato un font specifico per i di...
Oro rosa e charm Les Néréi...
La XPeng P7+ è salpata in direzio...
Quali sono i componenti più affid...
Amazon Haul raddoppia lo sconto: -30% su...
Germania e Danimarca accelerano sull'eol...
Azienda cinese che chiede aiuto ad una a...
Per aumentare la competitività ne...
I nuovi MacBook con M5 Pro e Max usciran...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 19:55.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v