热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

WinForm利用AForge.NET调用电脑摄像头进行拍照和视频

 当然了,你需要去官网下载类库,http:www.aforgenet.com 调用本机摄像头常用的组件:AForgeAForge.ControlsAForge.ImagingAFo

 当然了,你需要去官网下载类库,http://www.aforgenet.com/

 

调用本机摄像头常用的组件:

AForge

AForge.Controls

AForge.Imaging

AForge.Video

AForge.Video.DirectShow

 

图片展示方面,你可以使用PictureBox,也可以使用类库提供的控件 AForge.Controls.VideoSourcePlayer

因为我这个还集成了 条码识别、电子秤称重,所以代码有点多,多多见谅。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Drawing.Imaging;
using com.google.zxing.client.j2se;
using com.google.zxing;
using System.IO;
using System.Threading;
using Urovo.ExternalIndustryLib;
using System.IO.Ports;
using AForge.Video.DirectShow;
using AForge.Video;
using Inlite.ClearImageNet;

namespace SweepCode
{
    public partial class FrmMain : Form
    {
        //关闭标识
        private bool IsClose = false;
        //识别标识
        private bool StartCameraA = false;
        //重量读取标识
        private bool ElectrOnicScale= false;
        private string OnlyCode= "";
        private SerialPort Sp = new SerialPort();
        IndustryConfigDAL industryConfigDAL = new IndustryConfigDAL();
        private string strTemp = "";
        private FilterInfoCollection videoDevices;
        private bool ShowIdentification = false;
        private VideoCaptureDevice videoSource;

        public FrmMain()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            FormLoad();
        }
       
        public void FormLoad()
        {
            try
            {
                ShowIdentification = false;
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (videoDevices.Count == 0)
                    throw new ApplicationException();
                ComboName.Items.Clear();
                foreach (FilterInfo device in videoDevices)
                {
                    ComboName.Items.Add(device.Name);
                }
                ComboName.SelectedIndex = 0;
                videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString);
                for (int i = 0; i )
                {
                    ComboReso.Items.Add(videoSource.VideoCapabilities[i].FrameSize.Width + "*" + videoSource.VideoCapabilities[i].FrameSize.Height);
                }
                ComboReso.SelectedIndex = 0;
                videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex];
                videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
         videoSource.Start();
//类库提供的控件,也可以显示
//videPlayer.VideoSource = videoSource; //videPlayer.Start(); ShowIdentification = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //选择不同视频 private void ComboName_SelectedIndexChanged(object sender, EventArgs e) { if (ShowIdentification == false) return; IsClose = true; Thread.Sleep(100); ShowIdentification = false; videoSource.Stop(); videoSource = null; //videPlayer.SignalToStop(); //videPlayer.WaitForStop(); ComboReso.Items.Clear(); videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString); for (int i = 0; i ) { ComboReso.Items.Add(videoSource.VideoCapabilities[i].FrameSize.Width + "*" + videoSource.VideoCapabilities[i].FrameSize.Height); } ComboReso.SelectedIndex = 0; videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex]; videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame); videoSource.Start(); IsClose = false; //videPlayer.VideoSource = videoSource; //videPlayer.Start(); ShowIdentification = true; } //选择不同的分辨率 private void ComboReso_SelectedIndexChanged(object sender, EventArgs e) { if (ShowIdentification == false) return; ShowIdentification = false; //videPlayer.SignalToStop(); //videPlayer.WaitForStop(); IsClose = true; Thread.Sleep(100); videoSource.Stop(); videoSource = null; videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString); videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex]; videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame); videoSource.Start(); //videPlayer.VideoSource = videoSource; //videPlayer.Start(); IsClose = false; ShowIdentification = true; } //释放 private void CloseVideoSource() { if (!(videoSource == null)) if (videoSource.IsRunning) { videoSource.SignalToStop(); videoSource = null; } }
//加载图片到控件
private delegate void UpdateUI(); private void fun(Bitmap img) { if (this.pictureBox1.InvokeRequired) { UpdateUI update = delegate { this.pictureBox1.Image = img; }; this.pictureBox1.Invoke(update); } else { this.pictureBox1.Image = img; } } //保存图片 private delegate void SaveImage(); private void SaveImageHH(string ImagePath) { if (this.pictureBox1.InvokeRequired) { SaveImage saveimage = delegate { this.pictureBox1.Image.Save(ImagePath); }; this.pictureBox1.Invoke(saveimage); } else { this.pictureBox1.Image.Save(ImagePath); } } string tempImagePath = ""; /// /// 拍照-识别-显示 /// public void StartCamera() { try { while (StartCameraA) { // label1.Text = ""; List formats = new List(); formats.Add(BarcodeFormat.CODE128); formats.Add(BarcodeFormat.CODE39); int rNumber = RandomNumber(); string imagePath = System.Environment.CurrentDirectory; if (!Directory.Exists(@imagePath + "\\Images")) { Directory.CreateDirectory(@imagePath + "\\Images"); } StringBuilder p = new StringBuilder(@imagePath + "\\Images\\" + rNumber + ".jpg"); SaveImageHH(@imagePath + "\\Images\\" + rNumber + ".jpg"); BarcodeReader reader = new BarcodeReader(); reader.Horizontal = true; reader.Vertical = true; reader.DiagOnal= true; reader.Code39 = true; reader.Code128 = true; Barcode[] barcodes = reader.Read(@imagePath + "\\Images\\" + rNumber + ".jpg"); string s = ""; int cnt = 0; string CodeValue = ""; if (barcodes.Length > 1) { label1.Text = "Existence Multiple BarCode"; Thread.Sleep(100); } else { foreach (Barcode bc in barcodes) { cnt++; CodeValue = bc.Text; } if (cnt == 0) {//解码不成功,继续抓取图像并解码 // tempImagePath = ""; tempLableValue = "NO BARCODES"; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); label1.Text = "NO BARCODES"; Thread.Sleep(100); } else { //解码成功 if (label1.Text != CodeValue) { label1.Text = CodeValue; tempLableValue = CodeValue; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); string applicatiOnPath= Application.StartupPath; System.Media.SoundPlayer sndPlayer = new System.Media.SoundPlayer(@applicationPath + "\\WAV\\success.wav"); sndPlayer.Play(); } Thread.Sleep(100); } } File.Delete(@imagePath + "\\Images\\" + rNumber + ".jpg"); } } catch (Exception ex) { Thread.Sleep(100); label1.Text = ex.Message; tempLableValue = ex.Message; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); } } string tempLableValue; void SetLableText() { label1.Text = tempLableValue; } void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs) { if (IsClose) return; try { Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone(); fun(bitmap); } catch (Exception ex) { label1.Text = "保存图像失败!"; } } void videPlayer_NewFrame(object sender, ref Bitmap bitmapimage) { try { if (tempImagePath != "") { bitmapimage.Save(tempImagePath, System.Drawing.Imaging.ImageFormat.Bmp); } } catch (Exception ex) { label1.Text = ex.Message; } } /// /// 测试用-记录调用步骤 /// /// public void ShowMessage(string Value) { listBox1.Items.Add(Value); } public delegate void HandleInterfaceUpdataDelegate(string text); //委托,此为重点 private HandleInterfaceUpdataDelegate interfaceUpdataHandle; //拍照委托 /// /// 打开串口 /// /// public bool OpenElectronicScale() { try { industryConfigDAL.ReadConfig(); interfaceUpdataHandle = new HandleInterfaceUpdataDelegate(UpdateTextBox);//实例化委托对象 Sp.PortName = industryConfigDAL.Port; Sp.BaudRate = Convert.ToInt32(industryConfigDAL.BaudRate); Sp.Parity = Parity.None; Sp.StopBits = StopBits.One; // Sp.DataReceived += new SerialDataReceivedEventHandler(Sp_DataReceived); Sp.ReceivedBytesThreshold = 1; Sp.Open(); } catch (Exception ex) { //btnIdentify.Enabled = true; //btnStopDistinguish.Enabled = false; label4.Text = "端口" + industryConfigDAL.Port + "打开失败!"; //MessageBox.Show("端口" + industryConfigDAL.Port + "打开失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; } /// /// 更新值 /// /// private void UpdateTextBox(string text) { char[] arr = text.ToCharArray(); Array.Reverse(arr); label4.Text = new string(arr); } /// /// 识别 /// /// /// private void btnIdentify_Click(object sender, EventArgs e) { try { toolStripDropDownButton1.Enabled = false; ComboName.Enabled = false; ComboReso.Enabled = false; btnIdentify.Enabled = false; btnStopDistinguish.Enabled = true; #region //读取电子秤 if (OpenElectronicScale()) { ElectronicScale = true; Thread th = new Thread(Distinguish); th.IsBackground = true; th.Start(); } //条码识别 StartCameraA = true; Thread thread = new Thread(StartCamera); thread.IsBackground = true; thread.Start(); #endregion } catch { } } /// /// 读取电子秤数据 /// public void Distinguish() { try { while (ElectronicScale) { Thread.Sleep(50); int i = Sp.BytesToRead; if (i > 0) { try { strTemp = Sp.ReadExisting(); } catch { } if (strTemp.ToLower().IndexOf("=") <0) { i = 0; } else { string[] sd = strTemp.Split('='); this.Invoke(interfaceUpdataHandle, sd[1]); } } } } catch { ElectronicScale = false; return; } } /// /// 生成随机数 /// /// public int RandomNumber() { Random random = new Random(); int num = random.Next(100000, 1000000); return num; } /// /// 停止 /// /// /// private void btnStopDistinguish_Click(object sender, EventArgs e) { toolStripDropDownButton1.Enabled = true; ComboName.Enabled = true; ComboReso.Enabled = true; btnIdentify.Enabled = true; btnStopDistinguish.Enabled = false; StartCameraA = false; ElectronicScale = false; Thread.Sleep(1000); Sp.Close(); } /// /// 设置电子秤参数 /// /// /// private void btnElectronicScale_Click(object sender, EventArgs e) { FrmElectronicScale frmElectronicScale = new FrmElectronicScale(); frmElectronicScale.ShowDialog(); } /// /// 关闭窗体 /// /// /// private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { IsClose = true; Thread.Sleep(100); ElectronicScale = false; StartCameraA = false; if (videoSource.IsRunning) { videoSource.SignalToStop(); } //videoSource.Stop(); videoSource = null; Thread.Sleep(1000); Sp.Close(); Thread.Sleep(1000); this.Dispose(); Thread.Sleep(1000); Application.Exit(); Thread.Sleep(1000); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } }

 

 

出处:https://www.cnblogs.com/qigao/p/6430169.html

==============================================

参考:

AForge.net简介和认识
AForge.net 使用之录像拍照功能实现
 

==============================================

测试代码文件:AForge.Camera.zip   (下载请查看隐藏)

 

隐藏代码
AForge.Camera.zip

 当然了,你需要去官网下载类库,http://www.aforgenet.com/

 

调用本机摄像头常用的组件:

AForge

AForge.Controls

AForge.Imaging

AForge.Video

AForge.Video.DirectShow

 

图片展示方面,你可以使用PictureBox,也可以使用类库提供的控件 AForge.Controls.VideoSourcePlayer

因为我这个还集成了 条码识别、电子秤称重,所以代码有点多,多多见谅。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Drawing.Imaging;
using com.google.zxing.client.j2se;
using com.google.zxing;
using System.IO;
using System.Threading;
using Urovo.ExternalIndustryLib;
using System.IO.Ports;
using AForge.Video.DirectShow;
using AForge.Video;
using Inlite.ClearImageNet;

namespace SweepCode
{
    public partial class FrmMain : Form
    {
        //关闭标识
        private bool IsClose = false;
        //识别标识
        private bool StartCameraA = false;
        //重量读取标识
        private bool ElectrOnicScale= false;
        private string OnlyCode= "";
        private SerialPort Sp = new SerialPort();
        IndustryConfigDAL industryConfigDAL = new IndustryConfigDAL();
        private string strTemp = "";
        private FilterInfoCollection videoDevices;
        private bool ShowIdentification = false;
        private VideoCaptureDevice videoSource;

        public FrmMain()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            FormLoad();
        }
       
        public void FormLoad()
        {
            try
            {
                ShowIdentification = false;
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (videoDevices.Count == 0)
                    throw new ApplicationException();
                ComboName.Items.Clear();
                foreach (FilterInfo device in videoDevices)
                {
                    ComboName.Items.Add(device.Name);
                }
                ComboName.SelectedIndex = 0;
                videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString);
                for (int i = 0; i )
                {
                    ComboReso.Items.Add(videoSource.VideoCapabilities[i].FrameSize.Width + "*" + videoSource.VideoCapabilities[i].FrameSize.Height);
                }
                ComboReso.SelectedIndex = 0;
                videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex];
                videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame);
         videoSource.Start();
//类库提供的控件,也可以显示
//videPlayer.VideoSource = videoSource; //videPlayer.Start(); ShowIdentification = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); } } //选择不同视频 private void ComboName_SelectedIndexChanged(object sender, EventArgs e) { if (ShowIdentification == false) return; IsClose = true; Thread.Sleep(100); ShowIdentification = false; videoSource.Stop(); videoSource = null; //videPlayer.SignalToStop(); //videPlayer.WaitForStop(); ComboReso.Items.Clear(); videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString); for (int i = 0; i ) { ComboReso.Items.Add(videoSource.VideoCapabilities[i].FrameSize.Width + "*" + videoSource.VideoCapabilities[i].FrameSize.Height); } ComboReso.SelectedIndex = 0; videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex]; videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame); videoSource.Start(); IsClose = false; //videPlayer.VideoSource = videoSource; //videPlayer.Start(); ShowIdentification = true; } //选择不同的分辨率 private void ComboReso_SelectedIndexChanged(object sender, EventArgs e) { if (ShowIdentification == false) return; ShowIdentification = false; //videPlayer.SignalToStop(); //videPlayer.WaitForStop(); IsClose = true; Thread.Sleep(100); videoSource.Stop(); videoSource = null; videoSource = new VideoCaptureDevice(videoDevices[ComboName.SelectedIndex].MonikerString); videoSource.VideoResolution = videoSource.VideoCapabilities[ComboReso.SelectedIndex]; videoSource.NewFrame += new NewFrameEventHandler(videoSource_NewFrame); videoSource.Start(); //videPlayer.VideoSource = videoSource; //videPlayer.Start(); IsClose = false; ShowIdentification = true; } //释放 private void CloseVideoSource() { if (!(videoSource == null)) if (videoSource.IsRunning) { videoSource.SignalToStop(); videoSource = null; } }
//加载图片到控件
private delegate void UpdateUI(); private void fun(Bitmap img) { if (this.pictureBox1.InvokeRequired) { UpdateUI update = delegate { this.pictureBox1.Image = img; }; this.pictureBox1.Invoke(update); } else { this.pictureBox1.Image = img; } } //保存图片 private delegate void SaveImage(); private void SaveImageHH(string ImagePath) { if (this.pictureBox1.InvokeRequired) { SaveImage saveimage = delegate { this.pictureBox1.Image.Save(ImagePath); }; this.pictureBox1.Invoke(saveimage); } else { this.pictureBox1.Image.Save(ImagePath); } } string tempImagePath = ""; /// /// 拍照-识别-显示 /// public void StartCamera() { try { while (StartCameraA) { // label1.Text = ""; List formats = new List(); formats.Add(BarcodeFormat.CODE128); formats.Add(BarcodeFormat.CODE39); int rNumber = RandomNumber(); string imagePath = System.Environment.CurrentDirectory; if (!Directory.Exists(@imagePath + "\\Images")) { Directory.CreateDirectory(@imagePath + "\\Images"); } StringBuilder p = new StringBuilder(@imagePath + "\\Images\\" + rNumber + ".jpg"); SaveImageHH(@imagePath + "\\Images\\" + rNumber + ".jpg"); BarcodeReader reader = new BarcodeReader(); reader.Horizontal = true; reader.Vertical = true; reader.DiagOnal= true; reader.Code39 = true; reader.Code128 = true; Barcode[] barcodes = reader.Read(@imagePath + "\\Images\\" + rNumber + ".jpg"); string s = ""; int cnt = 0; string CodeValue = ""; if (barcodes.Length > 1) { label1.Text = "Existence Multiple BarCode"; Thread.Sleep(100); } else { foreach (Barcode bc in barcodes) { cnt++; CodeValue = bc.Text; } if (cnt == 0) {//解码不成功,继续抓取图像并解码 // tempImagePath = ""; tempLableValue = "NO BARCODES"; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); label1.Text = "NO BARCODES"; Thread.Sleep(100); } else { //解码成功 if (label1.Text != CodeValue) { label1.Text = CodeValue; tempLableValue = CodeValue; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); string applicatiOnPath= Application.StartupPath; System.Media.SoundPlayer sndPlayer = new System.Media.SoundPlayer(@applicationPath + "\\WAV\\success.wav"); sndPlayer.Play(); } Thread.Sleep(100); } } File.Delete(@imagePath + "\\Images\\" + rNumber + ".jpg"); } } catch (Exception ex) { Thread.Sleep(100); label1.Text = ex.Message; tempLableValue = ex.Message; MethodInvoker invoke = new MethodInvoker(SetLableText); BeginInvoke(invoke); } } string tempLableValue; void SetLableText() { label1.Text = tempLableValue; } void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs) { if (IsClose) return; try { Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone(); fun(bitmap); } catch (Exception ex) { label1.Text = "保存图像失败!"; } } void videPlayer_NewFrame(object sender, ref Bitmap bitmapimage) { try { if (tempImagePath != "") { bitmapimage.Save(tempImagePath, System.Drawing.Imaging.ImageFormat.Bmp); } } catch (Exception ex) { label1.Text = ex.Message; } } /// /// 测试用-记录调用步骤 /// /// public void ShowMessage(string Value) { listBox1.Items.Add(Value); } public delegate void HandleInterfaceUpdataDelegate(string text); //委托,此为重点 private HandleInterfaceUpdataDelegate interfaceUpdataHandle; //拍照委托 /// /// 打开串口 /// /// public bool OpenElectronicScale() { try { industryConfigDAL.ReadConfig(); interfaceUpdataHandle = new HandleInterfaceUpdataDelegate(UpdateTextBox);//实例化委托对象 Sp.PortName = industryConfigDAL.Port; Sp.BaudRate = Convert.ToInt32(industryConfigDAL.BaudRate); Sp.Parity = Parity.None; Sp.StopBits = StopBits.One; // Sp.DataReceived += new SerialDataReceivedEventHandler(Sp_DataReceived); Sp.ReceivedBytesThreshold = 1; Sp.Open(); } catch (Exception ex) { //btnIdentify.Enabled = true; //btnStopDistinguish.Enabled = false; label4.Text = "端口" + industryConfigDAL.Port + "打开失败!"; //MessageBox.Show("端口" + industryConfigDAL.Port + "打开失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } return true; } /// /// 更新值 /// /// private void UpdateTextBox(string text) { char[] arr = text.ToCharArray(); Array.Reverse(arr); label4.Text = new string(arr); } /// /// 识别 /// /// /// private void btnIdentify_Click(object sender, EventArgs e) { try { toolStripDropDownButton1.Enabled = false; ComboName.Enabled = false; ComboReso.Enabled = false; btnIdentify.Enabled = false; btnStopDistinguish.Enabled = true; #region //读取电子秤 if (OpenElectronicScale()) { ElectronicScale = true; Thread th = new Thread(Distinguish); th.IsBackground = true; th.Start(); } //条码识别 StartCameraA = true; Thread thread = new Thread(StartCamera); thread.IsBackground = true; thread.Start(); #endregion } catch { } } /// /// 读取电子秤数据 /// public void Distinguish() { try { while (ElectronicScale) { Thread.Sleep(50); int i = Sp.BytesToRead; if (i > 0) { try { strTemp = Sp.ReadExisting(); } catch { } if (strTemp.ToLower().IndexOf("=") <0) { i = 0; } else { string[] sd = strTemp.Split('='); this.Invoke(interfaceUpdataHandle, sd[1]); } } } } catch { ElectronicScale = false; return; } } /// /// 生成随机数 /// /// public int RandomNumber() { Random random = new Random(); int num = random.Next(100000, 1000000); return num; } /// /// 停止 /// /// /// private void btnStopDistinguish_Click(object sender, EventArgs e) { toolStripDropDownButton1.Enabled = true; ComboName.Enabled = true; ComboReso.Enabled = true; btnIdentify.Enabled = true; btnStopDistinguish.Enabled = false; StartCameraA = false; ElectronicScale = false; Thread.Sleep(1000); Sp.Close(); } /// /// 设置电子秤参数 /// /// /// private void btnElectronicScale_Click(object sender, EventArgs e) { FrmElectronicScale frmElectronicScale = new FrmElectronicScale(); frmElectronicScale.ShowDialog(); } /// /// 关闭窗体 /// /// /// private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { IsClose = true; Thread.Sleep(100); ElectronicScale = false; StartCameraA = false; if (videoSource.IsRunning) { videoSource.SignalToStop(); } //videoSource.Stop(); videoSource = null; Thread.Sleep(1000); Sp.Close(); Thread.Sleep(1000); this.Dispose(); Thread.Sleep(1000); Application.Exit(); Thread.Sleep(1000); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } }

 


推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 本文介绍了C#中生成随机数的三种方法,并分析了其中存在的问题。首先介绍了使用Random类生成随机数的默认方法,但在高并发情况下可能会出现重复的情况。接着通过循环生成了一系列随机数,进一步突显了这个问题。文章指出,随机数生成在任何编程语言中都是必备的功能,但Random类生成的随机数并不可靠。最后,提出了需要寻找其他可靠的随机数生成方法的建议。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
author-avatar
鱼鱼
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有