资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

手机拍照接口java代码 手机拍照编程代码

求java web项目使用html5调用手机摄像头扫描二维码并获取二维码信息代码

需要加载cordova.js 方法: document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { pictureSource = navigator.camera.PictureSourceType; destinationType = navigator.camera.DestinationType; } //相...

在新邵等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、做网站、成都外贸网站建设公司 网站设计制作按需求定制网站,公司网站建设,企业网站建设,高端网站设计,成都全网营销,外贸网站制作,新邵网站建设费用合理。

一个java接口的问题~~

interface MobilePhone {

void call();

void receive();

void sendMsg();

void receiveMsg();

}

interface Camera {

void takePhoto();

}

interface CameraPhone extends MobilePhone, Camera {

}

class NokiaPhone implements CameraPhone {

public void call() {

System.out.println("使用 NokiaPhone 打电话。");

}

public void receive() {

System.out.println("使用 NokiaPhone 接电话。");

}

public void sendMsg() {

System.out.println("使用 NokiaPhone 发短信。");

}

public void receiveMsg() {

System.out.println("使用 NokiaPhone 收短信。");

}

public void takePhoto() {

System.out.println("使用 NokiaPhone 照相。");

}

}

class MotoPhone implements CameraPhone {

public void call() {

System.out.println("使用 MotoPhone 打电话。");

}

public void receive() {

System.out.println("使用 MotoPhone 接电话。");

}

public void sendMsg() {

System.out.println("使用 MotoPhone 发短信。");

}

public void receiveMsg() {

System.out.println("使用 MotoPhone 收短信。");

}

public void takePhoto() {

System.out.println("使用 MotoPhone 照相。");

}

}

class Student {

private String name;

private CameraPhone myPhone;

public Student(String name, CameraPhone myPhone) {

this.name = name;

this.myPhone = myPhone;

}

public void mycall() {

System.out.print(name + " ");

myPhone.call();

}

public void myreceive() {

System.out.print(name + " ");

myPhone.receive();

}

public void mysendMsg() {

System.out.print(name + " ");

myPhone.sendMsg();

}

public void myreceiveMsg() {

System.out.print(name + " ");

myPhone.receiveMsg();

}

public void mytakePhoto() {

System.out.print(name + " ");

myPhone.takePhoto();

}

}

public class TestInterFace {

public static void main(String[] args) {

Student student1 = new Student("张三", new NokiaPhone());

Student student2 = new Student("李四", new MotoPhone());

student1.mycall();

student1.myreceive();

student1.mysendMsg();

student1.myreceiveMsg();

student1.mytakePhoto();

student2.mycall();

student2.myreceive();

student2.mysendMsg();

student2.myreceiveMsg();

student2.mytakePhoto();

}

}

java编程题目,求求大佬救救我

这个题考察的是面向对象三大特性之一的继承。

子类继承父类。

项目结构如何所示:

Mobile 为父类,有一个属性:mobilePhone 代表电话号码。

有4个方法(功能):

1、获取手机号码:public String getMobilePhone(){}

2、存储手机号码:public void setMobilePhone(String mobilePhone) {}

3、拨打电话号码:public void callOnMobilePhone(){}

4、挂断电话:public void callOffPhone(){}

具体代码如下所示:、

--------------------------------------mobilePhone 开始--------------------------------------

/**

* @author 冯修远

* 创建一个第一代手机类,要求包含手机号码信息,并包含获取电话号码,

* 存储电话号码、拨打电话号码和挂断电话等功能。并以此为父类,派生

* 出子类第二代手机类,增加拍照功能。以第二代手机类来生成对象并

* 模拟实现拨打电话、挂断电话拍照等功能。

*/

public class Mobile {

//手机号码

private String mobilePhone;

/**

* 获取手机号码

* @return

*/

public String getMobilePhone() {

return mobilePhone;

}

/**

* 存储手机号码

* @param mobilePhone

*/

public void setMobilePhone(String mobilePhone) {

this.mobilePhone = mobilePhone;

}

/**

* 拨打电话号码

*/

public void callOnMobilePhone(){

System.out.println("拨打电话号码:"+mobilePhone);

}

/**

* 挂断电话

*/

public void callOffPhone(){

System.out.println("挂断与:"+mobilePhone+"的通话");

}

}

--------------------------------------mobilePhone 结束--------------------------------------

PhotoMobile 为子类或者叫派生类,继承自父类:Mobile

同时也继承了父类的4个方法,但父类的属性因为我设置的是private,所以继承不了。

PhotoMobile 的代码如下图所示:

最后一个类,也就是测试类,用于创建第二代手机的对象,并调用相应的功能,如下图所示:

最终,程序的运行结果如下图所示:

我是冯修远,如果我的答案对您有帮助的话,请采纳以帮助更多的人,如果还有其它的问题,也请关注我,私信我,谢谢!

求JAVA代码~~~~~~~~~~:编写一个应用抽象类的程序。

//抽象的形状类

abstract class Shape{

abstract double getArea(); //抽象的求面积方法

}

//矩形类

class Rectangle extends Shape{

protected double width;

protected double height;

public Rectangle(double width, double height){

this.width = width;

this.height = height;

}

@Override

double getArea() { //实现父类的方法

return this.width * this.height;

}

}

//椭圆类

class Ellipse extends Shape{

protected double a;

protected double b;

public Ellipse(double a, double b){

this.a = a;

this.b = b;

}

@Override

double getArea() {

return Math.PI * this.a * this.b;

}

}

public class TestAbstract {

public static void main(String[] args) {

Shape s;

s = new Rectangle(3, 4);

System.out.println("矩形的面积 : " + s.getArea());

s = new Ellipse(4, 3);

System.out.println("椭圆的面积 : " + s.getArea());

}

}

JAVA代码如何调用客户端摄像头

首先到sun下载最新的jmf,然后安装。

然后,说一下需求

1. 用摄像头拍照

2. 在文本框输入文件名

3. 按下拍照按钮,获取摄像头内的图像

4. 在拍下的照片上有一红框截取固定大小的照片。

5. 保存为本地图像为jpg格式,不得压缩画质

技术关键,相信也是大家最感兴趣的部分也就是如何让一个摄像头工作,并拍下一张照片了。

利用jmf,代码很简单:

//利用这三个类分别获取摄像头驱动,和获取摄像头内的图像流,获取到的图像流是一个swing的component组件类

public static player player = null;

private capturedeviceinfo di = null;

private medialocator ml = null;

//文档中提供的驱动写法,为何这么写我也不知:)

string str1 = "vfw:logitech usb video camera:0 ";

string str2 = "vfw:microsoft wdm image capture (win32):0 ";

di = capturedevicemanager.getdevice(str2);

ml = di.getlocator();

try

{

player = manager.createrealizedplayer(ml);

player.start();

component comp;

if ((comp = player.getvisualcomponent()) != null)

{

add(comp, borderlayout.north);

}

}

catch (exception e)

{

e.printstacktrace();

}

接下来就是点击拍照,获取摄像头内的当前图像。

代码也是很简单:

private jbutton capture;

private buffer buf = null;

private buffertoimage btoi = null;

private imagepanel imgpanel = null;

private image img = null;

private imagepanel imgpanel = null;

jcomponent c = (jcomponent) e.getsource();

if (c == capture)//如果按下的是拍照按钮

{

framegrabbingcontrol fgc =(framegrabbingcontrol) player.getcontrol( "javax.media.control.framegrabbingcontrol ");

buf = fgc.grabframe(); // 获取当前祯并存入buffer类

btoi = new buffertoimage((videoformat) buf.getformat());

img = btoi.createimage(buf); // show the image

imgpanel.setimage(img);

}

保存图像的就不多说了,以下为示例代码

bufferedimage bi = (bufferedimage) createimage(imgwidth, imgheight);

graphics2d g2 = bi.creategraphics();

g2.drawimage(img, null, null);

fileoutputstream out = null;

try

{

out = new fileoutputstream(s);

}

catch (java.io.filenotfoundexception io)

{

system.out.println( "file not found ");

}

jpegimageencoder encoder = jpegcodec.createjpegencoder(out);

jpegencodeparam param = encoder.getdefaultjpegencodeparam(bi);

param.setquality(1f, false);//不压缩图像

encoder.setjpegencodeparam(param);

try

{

encoder.encode(bi);

out.close();

}

catch (java.io.ioexception io)

{

system.out.println( "ioexception ");

}

把.jar文件导入。下载了jmf后需要安装,安装后你的那个jmf目录下就会有一个lib文件夹里面有.jar文件,然后打开eclipse,右键选择你的工程-〉属性-〉java build path- library-〉add external jars 找到你的jmf目录下lib的那个文件夹然后选中那些文件导入就ok了。

然后利用工具提供的导入文件帮助,一个一个导就OK了


分享名称:手机拍照接口java代码 手机拍照编程代码
当前地址:http://cdkjz.cn/article/dochhds.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220