日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

java 远程视频监控系统_基于android的远程视频监控系统 附完整源码

發布時間:2024/1/8 windows 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 远程视频监控系统_基于android的远程视频监控系统 附完整源码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

【實例簡介】原理:客戶端將采集到的每一幀圖像數據發送至服務器,服務器接收

【實例截圖】

【核心代碼】

/*

* @version 1.2 2012-06-29

* @author wanghai

*/

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.*;

import javax.imageio.*;

import javax.swing.*;

import java.net.Socket;

import java.net.ServerSocket;

/**

*在服務器開啟情況下,啟動客戶端,創建套接字接收圖像

*/

public class ImageServer {

public static ServerSocket ss = null;

public static void main(String args[]) throws IOException{

ss = new ServerSocket(6000);

final ImageFrame frame = new ImageFrame(ss);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

while(true){

frame.panel.getimage();

frame.repaint();

}

}

}

/**

A frame with an image panel

*/

@SuppressWarnings("serial")

class ImageFrame extends JFrame{

public ImagePanel panel;

public JButton jb;

public ImageFrame(ServerSocket ss){

// get screen dimensions

Toolkit kit = Toolkit.getDefaultToolkit();

Dimension screenSize = kit.getScreenSize();

int screenHeight = screenSize.height;

int screenWidth = screenSize.width;

// center frame in screen

setTitle("ImageTest");

setLocation((screenWidth - DEFAULT_WIDTH) / 2, (screenHeight - DEFAULT_HEIGHT) / 2);

setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

// add panel to frame

this.getContentPane().setLayout(null);

panel = new ImagePanel(ss);

panel.setSize(640,480);

panel.setLocation(0, 0);

add(panel);

jb = new JButton("拍照");

jb.setBounds(0,480,640,50);

add(jb);

saveimage saveaction = new saveimage(ss);

jb.addActionListener(saveaction);

}

public static final int DEFAULT_WIDTH = 640;

public static final int DEFAULT_HEIGHT = 560;

}

/**

A panel that displays a tiled image

*/

@SuppressWarnings("serial")

class ImagePanel extends JPanel {

private ServerSocket ss;

private Image image;

private InputStream ins;

public ImagePanel(ServerSocket ss) {

this.ss = ss;

}

public void getimage() throws IOException{

Socket s = this.ss.accept();

System.out.println("連接成功!");

this.ins = s.getInputStream();

this.image = ImageIO.read(ins);

this.ins.close();

}

public void paintComponent(Graphics g){

super.paintComponent(g);

if (image == null) return;

g.drawImage(image, 0, 0, null);

}

}

class saveimage implements ActionListener {

RandomAccessFile inFile = null;

byte byteBuffer[] = new byte[1024];

InputStream ins;

private ServerSocket ss;

public saveimage(ServerSocket ss){

this.ss = ss;

}

public void actionPerformed(ActionEvent event){

try {

Socket s = ss.accept();

ins = s.getInputStream();

// 文件選擇器以當前的目錄打開

JFileChooser jfc = new JFileChooser(".");

jfc.showSaveDialog(new javax.swing.JFrame());

// 獲取當前的選擇文件引用

File savedFile = jfc.getSelectedFile();

// 已經選擇了文件

if (savedFile != null) {

// 讀取文件的數據,可以每次以快的方式讀取數據

try {

inFile = new RandomAccessFile(savedFile, "rw");

} catch (FileNotFoundException e) {

e.printStackTrace();

}

}

int amount;

while ((amount = ins.read(byteBuffer)) != -1) {

inFile.write(byteBuffer, 0, amount);

}

inFile.close();

ins.close();

s.close();

javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(),

"已接保存成功", "提示!", javax.swing.JOptionPane.PLAIN_MESSAGE);

} catch (IOException e) {

e.printStackTrace();

}

}

}

總結

以上是生活随笔為你收集整理的java 远程视频监控系统_基于android的远程视频监控系统 附完整源码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。