Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > .NET Framework > Forum > c# สอบถามเรื่องคำสั่งที่ใช้กับ WebCam_Capture.dll คะ ทำให้ capture ภาพจากกล้องคะ



 

c# สอบถามเรื่องคำสั่งที่ใช้กับ WebCam_Capture.dll คะ ทำให้ capture ภาพจากกล้องคะ

 



Topic : 042083



โพสกระทู้ ( 40 )
บทความ ( 0 )



สถานะออฟไลน์




c# สอบถามเรื่องคำสั่งที่ใช้กับ WebCam_Capture.dll คะ พอดีว่าได้ Library ตัวนี้มา(ตัวเก่าใช้ webCamLib.dll แต่ว่ามีปัญหาตรงที่ capture แล้วเหมือนเป็นการจับภาพหน้าจอมากกว่าการ capจากกล้องโดยตรง) แต่วาตอนเขียนคำสั่งในการ capture รุปภาพ แต่ทำไม่ได้คะ มัน error เลยอยากทราบจะใช้คำสั่งยังไงดีคะ

ข้างล่างนี่เป็นตัวอย่างโค้ดโปรแกรมที่ลองโหลดมานะคะ แต่ว่าคำสั่งที่สั่งให้ บันทึกภาพมันไม่ได้อ่ะค่ะ

หนูเพิ่มตรง timer1_Tick ให้ capture อะคะ แต่ว่า เหมือนคำสั่งใน library จะต่างกัน พอดีเพิ่งหัดเขียน c#อะคะ ช่วยชี้แนะด้วยนะคะ อยากให้มัน capture ได้ แล้ว library นี้ หนูเอามาใช้กับตัวอย่างโค้ดนี้ก็ยังไม่ค่อยเข้าใจสักเท่าไหร่อะคะ

ขอบคุณพี่ที่ส่ง library นี้ให้นะคะ

Code (C#)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Webcam_Test
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private WebCam_Capture.WebCamCapture UserControl1;
		private WebCam_Capture.WebCamCapture WebCamCapture;
		private System.Windows.Forms.PictureBox picCam;
		private System.Windows.Forms.Button cmdStart;
		private System.Windows.Forms.Button cmdStop;
		private System.Windows.Forms.Button cmdContinue;
		private System.Windows.Forms.NumericUpDown numCaptureTime;
		private System.Windows.Forms.Label label1;
        private ComboBox cmbDevice;
        private Button btnSelectDevice;
        private Timer timer1;
        private IContainer components;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.WebCamCapture = new WebCam_Capture.WebCamCapture();
            this.picCam = new System.Windows.Forms.PictureBox();
            this.cmdStart = new System.Windows.Forms.Button();
            this.cmdStop = new System.Windows.Forms.Button();
            this.cmdContinue = new System.Windows.Forms.Button();
            this.numCaptureTime = new System.Windows.Forms.NumericUpDown();
            this.label1 = new System.Windows.Forms.Label();
            this.cmbDevice = new System.Windows.Forms.ComboBox();
            this.btnSelectDevice = new System.Windows.Forms.Button();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.picCam)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.numCaptureTime)).BeginInit();
            this.SuspendLayout();
            // 
            // WebCamCapture
            // 
            this.WebCamCapture.CaptureHeight = 240;
            this.WebCamCapture.CaptureWidth = 320;
            this.WebCamCapture.FrameNumber = ((ulong)(0ul));
            this.WebCamCapture.Location = new System.Drawing.Point(17, 17);
            this.WebCamCapture.Name = "WebCamCapture";
            this.WebCamCapture.Size = new System.Drawing.Size(342, 252);
            this.WebCamCapture.TabIndex = 0;
            this.WebCamCapture.TimeToCapture_milliseconds = 100;
            this.WebCamCapture.ImageCaptured += new WebCam_Capture.WebCamCapture.WebCamEventHandler(this.WebCamCapture_ImageCaptured);
            // 
            // picCam
            // 
            this.picCam.Location = new System.Drawing.Point(28, 65);
            this.picCam.Name = "picCam";
            this.picCam.Size = new System.Drawing.Size(320, 240);
            this.picCam.TabIndex = 0;
            this.picCam.TabStop = false;
            this.picCam.Click += new System.EventHandler(this.pictureBox1_Click);
            // 
            // cmdStart
            // 
            this.cmdStart.Location = new System.Drawing.Point(478, 65);
            this.cmdStart.Name = "cmdStart";
            this.cmdStart.Size = new System.Drawing.Size(92, 77);
            this.cmdStart.TabIndex = 1;
            this.cmdStart.Text = "Start";
            this.cmdStart.Click += new System.EventHandler(this.cmdStart_Click);
            // 
            // cmdStop
            // 
            this.cmdStop.Location = new System.Drawing.Point(655, 65);
            this.cmdStop.Name = "cmdStop";
            this.cmdStop.Size = new System.Drawing.Size(78, 24);
            this.cmdStop.TabIndex = 2;
            this.cmdStop.Text = "Stop";
            this.cmdStop.Click += new System.EventHandler(this.cmdStop_Click);
            // 
            // cmdContinue
            // 
            this.cmdContinue.Location = new System.Drawing.Point(655, 118);
            this.cmdContinue.Name = "cmdContinue";
            this.cmdContinue.Size = new System.Drawing.Size(78, 24);
            this.cmdContinue.TabIndex = 3;
            this.cmdContinue.Text = "Continue";
            this.cmdContinue.Click += new System.EventHandler(this.cmdContinue_Click);
            // 
            // numCaptureTime
            // 
            this.numCaptureTime.Location = new System.Drawing.Point(585, 285);
            this.numCaptureTime.Maximum = new decimal(new int[] {
            32000,
            0,
            0,
            0});
            this.numCaptureTime.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.numCaptureTime.Name = "numCaptureTime";
            this.numCaptureTime.Size = new System.Drawing.Size(66, 20);
            this.numCaptureTime.TabIndex = 4;
            this.numCaptureTime.Value = new decimal(new int[] {
            20,
            0,
            0,
            0});
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(429, 287);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(150, 18);
            this.label1.TabIndex = 5;
            this.label1.Text = "Capture Time (Milliseconds)";
            // 
            // cmbDevice
            // 
            this.cmbDevice.FormattingEnabled = true;
            this.cmbDevice.Location = new System.Drawing.Point(443, 13);
            this.cmbDevice.Name = "cmbDevice";
            this.cmbDevice.Size = new System.Drawing.Size(229, 21);
            this.cmbDevice.TabIndex = 6;
            this.cmbDevice.SelectedIndexChanged += new System.EventHandler(this.cmdDevice_SelectedIndexChanged);
            // 
            // btnSelectDevice
            // 
            this.btnSelectDevice.Location = new System.Drawing.Point(691, 4);
            this.btnSelectDevice.Name = "btnSelectDevice";
            this.btnSelectDevice.Size = new System.Drawing.Size(56, 37);
            this.btnSelectDevice.TabIndex = 7;
            this.btnSelectDevice.Text = "เลือก";
            this.btnSelectDevice.UseVisualStyleBackColor = true;
            this.btnSelectDevice.Click += new System.EventHandler(this.btnSelectDevice_Click);
            // 
            // timer1
            // 
            this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(859, 778);
            this.Controls.Add(this.btnSelectDevice);
            this.Controls.Add(this.cmbDevice);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.numCaptureTime);
            this.Controls.Add(this.cmdContinue);
            this.Controls.Add(this.cmdStop);
            this.Controls.Add(this.cmdStart);
            this.Controls.Add(this.picCam);
            this.Name = "Form1";
            this.Text = "WebCam Capture";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
            ((System.ComponentModel.ISupportInitialize)(this.picCam)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.numCaptureTime)).EndInit();
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			// set the image capture size
			this.WebCamCapture.CaptureHeight = this.picCam.Height;
			this.WebCamCapture.CaptureWidth = this.picCam.Width;
		}

		private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			// stop the video capture
			this.WebCamCapture.Stop();
		}

		/// <summary>
		/// An image was capture
		/// </summary>
		/// <param name="source">control raising the event</param>
		/// <param name="e">WebCamEventArgs</param>
		private void WebCamCapture_ImageCaptured(object source, WebCam_Capture.WebcamEventArgs e)
		{
			// set the picturebox picture
			this.picCam.Image = e.WebCamImage;
		}

		private void cmdStart_Click(object sender, System.EventArgs e)
		{
            

            // change the capture time frame
			this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;

			// start the video capture. let the control handle the
			// frame numbers.
			this.WebCamCapture.Start(0);

		}

		private void cmdStop_Click(object sender, System.EventArgs e)
		{
			// stop the video capture
			this.WebCamCapture.Stop();
		}

		private void cmdContinue_Click(object sender, System.EventArgs e)
		{
			// change the capture time frame
			this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;

			// resume the video capture from the stop
			this.WebCamCapture.Start(this.WebCamCapture.FrameNumber);
		}

        private void cmdDevice_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

       

        private void timer1_Tick(object sender, EventArgs e)
        {
            Image im = WebCamCapture.CaptureImage(picCam);    // capture ภาพที่แสดงอยู่บน pictureBox1
            im.Save("c:\\test.jpg");    // save ภาพไปที่ c:\test.jpg   
        }

        private void btnSelectDevice_Click(object sender, EventArgs e)
        {
            btnSelectDevice.Text = "start";
            timer1.Enabled = true;
            btnSelectDevice.Enabled = false;

            Device d = DeviceManager.GetDevice(cmbDevices.SelectedIndex);
            d.ShowWindow(this.picCam);
        }


       
	}
}




error ที่เกิดขึ้นคะ
error



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-04-27 18:23:38 By : Takezeed View : 3084 Reply : 5
 

 

No. 1



โพสกระทู้ ( 40 )
บทความ ( 0 )



สถานะออฟไลน์


T_T






Date : 2010-04-28 00:08:52 By : Takezeed
 


 

No. 2



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


add reference หรือยังครับ
Date : 2010-04-28 08:27:40 By : tungman
 

 

No. 3



โพสกระทู้ ( 40 )
บทความ ( 0 )



สถานะออฟไลน์


แอดแล้วค่ะ Webcam_Capture.dll จะต้องใช้คำสั่งยังไงคะ ในการ capture รูปภาพจากกล้อง

library
Date : 2010-04-28 16:40:25 By : Takezeed
 


 

No. 4



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์


งั้นเจ้า WebCam_Capture.WebCamCapture มันก็ไม่มี method CaptureImage อ่ะดิ มันถึงบอกว่าไม่มี

ลองตรวจดูนะว่าใน WebCam_Capture มี class อะไรบ้าง

และแต่ละ class มี method อะไรบ้าง
Date : 2010-04-28 16:49:32 By : tungman
 


 

No. 5



โพสกระทู้ ( 373 )
บทความ ( 0 )



สถานะออฟไลน์


น้องเอ๊ย

โปรเจ็คนี้ Dll WebCam_Capture.dll มันยังไม่ได้ Build

click ขวาที่ WebCam_Capture Project แล้วเลือก "Rebuild"

แล้วลอง Run ดูใหม่
Date : 2010-04-29 11:07:42 By : numenoy
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : c# สอบถามเรื่องคำสั่งที่ใช้กับ WebCam_Capture.dll คะ ทำให้ capture ภาพจากกล้องคะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่