Android二维码功能实现
最近二维码真是越来越火了,随便电视上、网络上、商场里,到处都是二维码。而内嵌二维码扫描功能的软件也越来越多,QQ、微信、UC浏览器等等应用都可以对着二维码扫一扫,感觉我们自己的应用里不加上二维码扫描功能,都跟不上时代潮流了。所以今天我就将带着大家一起,在我们自己的程序里加入二维码扫描的功能。
不过,二维码功能如果真要做起来还是非常复杂的,从零开始实现不太现实,比较好的做法就是借助现有的开源项目。目前在二维码这一领域名气最大的开源项目就是ZXing了(Zebra Crossing),它提供了多个平台的二维码扫描解决方案,开源项目地址是https://code.google.com/p/zxing/ 。
虽说网上已经有现成的开源项目了,不过关于ZXing的文档和教程好像还比较少,因此还是有不少朋友并不知道在项目中该如何引入ZXing的,这里我就带着大家一步步地实现,相信每个人在看完本篇文章后都可以在自己的项目中实现二维码扫描功能。
首先,我们需要下载ZXing项目所依赖的Jar包的源码。
下载地址是 http://repo1.maven.org/maven2/com/google/zxing/core/2.2/core-2.2-sources.jar 。
然后我们再来下载ZXing项目,下载地址是 https://zxing.googlecode.com/files/ZXing-2.2.zip 。
建议使用迅雷下载,因为Google Code和Maven的访问在国内不稳定,经常出现断联的情况,使用迅雷可以保证文件的完整性。
另外,经过我的测试,在ZXing项目中直接导入core-2.2的Jar包是无法正常运行的,所以我们只能通过将core-2.2的源码加入到ZXing项目中来实现。下载好以上两个文件后,先解压core-2.2-sources.jar文件,解压之后的目录结构如下图所示:
然后解压ZXing-2.2这个压缩包,里面可以看到各种平台下的ZXing项目源码,我们进入到android文件夹的src目录下,将core-2.2-sources中的源码拷贝进来。拷贝之后android文件夹下的目录结构如下图所示:
这样准备工作已经完成了,现在我们新建一个Android项目ScannerTest,项目使用Android 4.0的API。
然后将上图中src目录下的所有文件全部复制,粘贴到我们ScannerTest项目的src目录下,完成后目录结构如下图所示:
拷贝完了代码,现在该拷贝资源了,展开ZXing项目android文件夹下的res目录,将drawable文件夹、layout文件夹、menu文件夹、raw文件夹、values文件夹以及xml文件夹中的内容都拷贝到ScannerTest项目的res目录下,注意有冲突的部分要小心解决,比如两个values文件夹中都有string.xml文件,要将它们的内容进行合并,不能只是简单地覆盖。
然后我们还需要将AndroidManifest中的内容进行合并,注意ZXing Android项目下的AndroidManifest在声明Activity时用的都是简写,而现在由于项目包名变了,再使用简写会出现找不到活动的情况,因此所有的简写都要改成完整类名,例如.CaptureActivity要改成com.google.zxing.client.android.CaptureActivity。另外ZXing Android项目下的主活动是CaptureActivity,这里我们需要将主活动的声明删除掉,因为ScannerTest项目中主活动是MainActivity。合并后的AndroidManifest中的代码如下所示:
- <?xmlversion="1.0"encoding="utf-8"?>
- <manifest
xmlns:android="http://schemas.android.com/apk/res/android" - package="com.example.scannertest"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-permissionandroid:name="android.permission.CAMERA"/>
- <uses-permissionandroid:name="android.permission.INTERNET"/>
- <uses-permissionandroid:name="android.permission.VIBRATE"/>
- <uses-permissionandroid:name="android.permission.FLASHLIGHT"/>
- <uses-permissionandroid:name="android.permission.READ_CONTACTS"/>
- <uses-permissionandroid:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
- <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE"/>
- <uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE"/>
- <uses-sdk
- android:minSdkVersion="14"
- android:targetSdkVersion="17"/>
- <uses-feature
- android:name="android.hardware.camera"
- android:required="false"/>
- <uses-feature
- android:name="android.hardware.camera.front"
- android:required="false"/>
- <uses-feature
- android:name="android.hardware.camera.autofocus"
- android:required="false"/>
- <uses-feature
- android:name="android.hardware.camera.flash"
- android:required="false"/>
- <uses-featureandroid:name="android.hardware.screen.landscape"/>
- <uses-feature
- android:name="android.hardware.wifi"
- android:required="false"/>
- <uses-featureandroid:name="android.hardware.touchscreen"/>
- <supports-screens
- android:anyDensity="true"
- android:largeScreens="true"
- android:normalScreens="true"
- android:smallScreens="true"
- android:xlargeScreens="true"/>
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme">
- <activity
- android:name="com.example.scannertest.MainActivity"
- android:label="@string/app_name">
- <intent-filter>
- <actionandroid:name="android.intent.action.MAIN"/>
- <categoryandroid:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.CaptureActivity"
- android:clearTaskOnLaunch="true"
- android:configChanges="orientation|keyboardHidden"
- android:screenOrientation="landscape"
- android:stateNotNeeded="true"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:windowSoftInputMode="stateAlwaysHidden">
- <intent-filter>
- <actionandroid:name="com.google.zxing.client.android.SCAN"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <categoryandroid:name="android.intent.category.BROWSABLE"/>
- <data
- android:host="zxing.appspot.com"
- android:path="/scan"
- android:scheme="http"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <categoryandroid:name="android.intent.category.BROWSABLE"/>
- <data
- android:host="www.google.com"
- android:path="/m/products/scan"
- android:scheme="http"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <categoryandroid:name="android.intent.category.BROWSABLE"/>
- <data
- android:host="www.google.co.uk"
- android:path="/m/products/scan"
- android:scheme="http"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <categoryandroid:name="android.intent.category.BROWSABLE"/>
- <data
- android:host="scan"
- android:path="/"
- android:scheme="zxing"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.PreferencesActivity"
- android:label="@string/preferences_name"
- android:stateNotNeeded="true">
- </activity>
- <activity
- android:name="com.google.zxing.client.android.encode.EncodeActivity"
- android:stateNotNeeded="true">
- <intent-filter>
- <actionandroid:name="com.google.zxing.client.android.ENCODE"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.SEND"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <dataandroid:mimeType="text/x-vcard"/>
- </intent-filter>
- <intent-filter>
- <actionandroid:name="android.intent.action.SEND"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- <dataandroid:mimeType="text/plain"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.book.SearchBookContentsActivity"
- android:configChanges="orientation|keyboardHidden"
- android:label="@string/sbc_name"
- android:screenOrientation="landscape"
- android:stateNotNeeded="true">
- <intent-filter>
- <actionandroid:name="com.google.zxing.client.android.SEARCH_BOOK_CONTENTS"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.share.ShareActivity"
- android:screenOrientation="user"
- android:stateNotNeeded="true"
- android:theme="@android:style/Theme.Light">
- <intent-filter>
- <actionandroid:name="com.google.zxing.client.android.SHARE"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.history.HistoryActivity"
- android:label="@string/history_title"
- android:stateNotNeeded="true">
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.share.BookmarkPickerActivity"
- android:label="@string/bookmark_picker_name"
- android:stateNotNeeded="true">
- <intent-filter>
- <actionandroid:name="android.intent.action.PICK"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.share.AppPickerActivity"
- android:configChanges="orientation"
- android:label="@string/app_picker_name"
- android:stateNotNeeded="true">
- <intent-filter>
- <actionandroid:name="android.intent.action.PICK"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- <activity
- android:name="com.google.zxing.client.android.HelpActivity"
- android:screenOrientation="user">
- <intent-filter>
- <actionandroid:name="android.intent.action.VIEW"/>
- <categoryandroid:name="android.intent.category.DEFAULT"/>
- </intent-filter>
- </activity>
- </application>
- </manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.scannertest"
android:versionCode="1"
android:versionName="1.0" > <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" /> <uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-feature android:name="android.hardware.screen.landscape" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" /> <supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.scannertest.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:stateNotNeeded="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="zxing.appspot.com"
android:path="/scan"
android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.com"
android:path="/m/products/scan"
android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.co.uk"
android:path="/m/products/scan"
android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="scan"
android:path="/"
android:scheme="zxing" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.PreferencesActivity"
android:label="@string/preferences_name"
android:stateNotNeeded="true" >
</activity>
<activity
android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="com.google.zxing.client.android.ENCODE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/x-vcard" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.book.SearchBookContentsActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/sbc_name"
android:screenOrientation="landscape"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="com.google.zxing.client.android.SEARCH_BOOK_CONTENTS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.share.ShareActivity"
android:screenOrientation="user"
android:stateNotNeeded="true"
android:theme="@android:style/Theme.Light" >
<intent-filter>
<action android:name="com.google.zxing.client.android.SHARE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.history.HistoryActivity"
android:label="@string/history_title"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.share.BookmarkPickerActivity"
android:label="@string/bookmark_picker_name"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.share.AppPickerActivity"
android:configChanges="orientation"
android:label="@string/app_picker_name"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.google.zxing.client.android.HelpActivity"
android:screenOrientation="user" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application> </manifest>
完成到这一步之后,你会发现项目中还是有很多的错误。不用担心,剩下的错误全部都是由于找不到R文件所造成的。这是因为ZXing项目中所引用的R文件都是com.google.zxing.client.android包下的R,而现在我们拷贝到ScannerTest项目之后,应该引用com.example.scannertest包下的R文件。我们需要将有错误的文件一个个地修改过来,虽然工作量不少,但都是傻瓜式操作,只要大家有耐心,就一定可以完成。
现在ScannerTest项目中应该已经没有任何错误了,然后我们还需要对ZXing的代码进行稍微的定制。
打开CaptureActivity,这个类就是用于扫描二维码的最主要的一个类,其中有一个handleDecode()方法,当二维码扫描完成之后会把结果回调到这个方法中,我们现在不想使用默认的处理方式,于是修改handleDecode()中的代码,如下所示:
- public void handleDecode(Result rawResult, Bitmap barcode,float scaleFactor) {
- String result = rawResult.getText();
- if (!TextUtils.isEmpty(result)) {
- Intent intent = new Intent();
- intent.putExtra("scan_result", rawResult.getText());
- setResult(RESULT_OK, intent);
- } else {
- setResult(RESULT_CANCELED);
- }
- finish();
- }
public void handleDecode(Result rawResult, Bitmap barcode, float scaleFactor) {
String result = rawResult.getText();
if (!TextUtils.isEmpty(result)) {
Intent intent = new Intent();
intent.putExtra("scan_result", rawResult.getText());
setResult(RESULT_OK, intent);
} else {
setResult(RESULT_CANCELED);
}
finish();
}
这里我们将扫描出来的结果借助Intent进行返回。
然后打开或新建activity_main.xml文件做为ScannerTest项目的主布局,在其中添加如下代码:
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <Button
- android:id="@+id/scan_button"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="扫一扫"/>
- <TextView
- android:id="@+id/scan_result"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- </LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:id="@+id/scan_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="扫一扫" /> <TextView
android:id="@+id/scan_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> </LinearLayout>
这个布局文件很简单,一个按钮用于开启二维码扫描功能,一个TextView用于显示扫描结果。
最后打开或新建MainActivity做为ScannerTest项目的主Activity,代码如下所示:
- public class MainActivityextends Activity {
- public staticfinal
int SCAN_CODE =1; - @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Button button = (Button) findViewById(R.id.scan_button);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
- startActivityForResult(intent, SCAN_CODE);
- }
- });
- }
- @Override
- protected void onActivityResult(int requestCode,int resultCode, Intent data) {
- switch (requestCode) {
- case SCAN_CODE:
- TextView scanResult = (TextView) findViewById(R.id.scan_result);
- if (resultCode == RESULT_OK) {
- String result = data.getStringExtra("scan_result");
- scanResult.setText(result);
- } else
if (resultCode == RESULT_CANCELED) { - scanResult.setText("扫描出错");
- }
- break;
- default:
- break;
- }
- }
- }
public class MainActivity extends Activity { public static final int SCAN_CODE = 1; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.scan_button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, CaptureActivity.class);
startActivityForResult(intent, SCAN_CODE);
}
});
} @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case SCAN_CODE:
TextView scanResult = (TextView) findViewById(R.id.scan_result);
if (resultCode == RESULT_OK) {
String result = data.getStringExtra("scan_result");
scanResult.setText(result);
} else if (resultCode == RESULT_CANCELED) {
scanResult.setText("扫描出错");
}
break;
default:
break;
}
} }
这个类也很简单,点击按钮时,我们通过startActivityForResult()方法启动CaptureActivity,开始执行二维码扫描,扫描的结果将回调到onActivityResult()方法中,然后在这个方法中取出扫描的结果,并展示在TextView上。
这样我们所有的编码工作就已经完成了,可以尝试运行一下了。首先看到程序的主界面如下图所示:
点击扫一扫后可以进行二维码扫描,见下图:
扫描完成后会将结果返回到主界面,如下图所示:
不知道大家有没有成功呢?这里我精心给大家准备了一张二维码图片,看看有多少朋友能够成功扫出来。 ^_^
另外,ZXing项目是比较庞大的,里面还有很多复杂的功能我们并不需要,如果你有兴趣深度钻研ZXing源码的话,其实还可以简化非常多的代码。 这里我就不带着大家深入研究了,因为我自己都还没完全搞明白呢
好了,今天的讲解到此结束,有疑问的朋友请在下面留言。
源代码下载:http://download.csdn.net/detail/lxq_xsyu/5955731
Android二维码功能实现的更多相关文章
- Android二维码功能实现,在程序内嵌入ZXing项目
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/9526247 最近二维码真是越来越火了,随便电视上.网络上.商场里,到处都是二维码. ...
- Android二维码的生成,解析以及扫描功能
<1> 布局只有2个按钮,实现生成二维码和解析二维码 <Button android:layout_width="wrap_content" android:la ...
- Android二维码识别 开源项目ZXing的编译
Android二维码识别 开源项目ZXing的编译 Android端的条形码/二维码识别功能 因为手机端的输入不是很方便,所以条形码/二维码的扫描是一种很有效的解决手段. 比较流行的手机应用中,常用的 ...
- android 二维码扫描
了解二维码这个东西还是从微信 中,当时微信推出二维码扫描功能,自己感觉挺新颖的,从一张图片中扫一下竟然能直接加好友,不可思议啊,那时候还不了解二维码,呵呵,然后做项目的时候, 老板说要加上二维码扫描功 ...
- android 二维码生成+扫描
android 二维码生成+扫描 1.在Android应用当中,很多时候都要用到二维码扫描,来避免让用户手动输入的麻烦. Google官方自己推出了一个二维码开源项目:ZXing库. 2.这里简单介绍 ...
- Android二维码开源项目zxing用例简化和生成二维码、条形码
上一篇讲到:Android二维码开源项目zxing编译,编译出来后有一个自带的測试程序:CaptureActivity比較复杂,我仅仅要是把一些不用的东西去掉,用看起来更方便,二维码和条形码的流行性自 ...
- FastReport 中添加二维码功能.(Delphi)
http://www.cnblogs.com/fancycloud/archive/2011/07/24/2115240.html FastReport 中添加二维码功能.(Delphi) 在实际 ...
- iOS开发——高级技术&二维码功能的实现
二维码功能的实现 ZBarSDK,一个比较优秀的开源项目,使用起来也很简单. ZBarSDK是一个开源的SDK,可从这里下载到源码,该SDK实现了识别和读取各种条形码,包括EAN-13/UPC-A, ...
- iOS--iOS7摄像头识别二维码功能
iOS–iOS7摄像头识别二维码功能 属性介绍: AVFoundation 框架基于以下几个类实现图像捕捉 ,通过这些类可以访问来自相机设备的原始数据并控制它的组件. AVCaptureDevice ...
随机推荐
- UIDeviceOrientationDidChangeNotification和UIApplicationDidChangeStatusBarFrameNotification
这几天做App的时候,需要添加旋转屏通知以便调整UI布局 刚开始我使用的是UIDeviceOrientationDidChangeNotification, 一直有一些问题就是,如果使用这个通知,当i ...
- C# AutoMapper
http://www.cnblogs.com/xlhblogs/p/3356748.html
- Machine-learning of Andrew Ng
Machine-learning of Andrew Ng 1.基础概念 机器学习是一门研究在非特定编程条件下让计算机采取行动的学科.最近二十年,机器学习为我们带来了自动驾驶汽车.实用的语音识别.高效 ...
- cmake配置c++可调用的文件路径参数
一.目的 在程序中使用一个路径配置,因为在svn服务器的测试数据,测试数据成为了本地路径,在程序中使用了绝对路径来处理文件的输入,这个令人头疼啊. 每次下完代码,我得挨个地方去找,谁在用本地路径,有点 ...
- IIS FTP匿名登录不成功
FTP网站没有开启匿名登录的权限,对你没有看错.可能你的虚拟目录已经设置了如下所示的内容: 但是,单击上右图时,在其功能视图中的FTP身份验证中,可能并未启用"匿名身份验证",如下右图所示.启动 ...
- TCP套接字编程模型及实例
摘要: 本文讲述了TCP套接字编程模块,包括服务器端的创建套接字.绑定.监听.接受.读/写.终止连接,客户端的创建套接字.连接.读/写.终止连接.先给出实例,进而结合代码分析. PS:本文权当 ...
- 结合Wireshark捕获分组深入理解TCP/IP协议栈之HTTP协议
摘要: 本文简单介绍了Web应用层协议理论知识,详细讲述了HTTP请求报文和响应报文各个字段含义,并从Wireshark俘获分组中选取HTTP相关报文进行分析. 一.概述 Web的应用 ...
- 29、从零写USB摄像头驱动之通过urb接受数据后上报数据是函数中fid的作用
原因分析如下: 视频数据是由一帧一帧数据组成,为了防止数据错乱,会给每一帧数据分配一个frameid,从第0帧开始,接着是第1帧,接着又是第0帧这样交错进行的,对usb摄像头来说每一帧数据来源于多个包 ...
- 8、摄像头驱动_Linux的V4L2架构分析
V4L2架构可以参考 linux-3.4.2\Documentation\video4linux\v4l2-framework.txt V4L2全名为Video For Linux 2,它是针对Li ...
- linux系统进程的查看与控制
原文:linux系统进程的查看与控制 一.什么是进程? 进程就是系统未完成并且正在进行的工作. 二.查看系统进程 1.图形方式查看 gnome-system-monitor 2.进程查看命令 ps - ...