|
![](/images/resource/spacer.gif) |
|
สอบถามการ Capture ภาพจาก Webcam ลงฐานข้อมูลโดยทำการตั้งชื่อไฟล์อัตโนมัติ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เอา Code ที่เขียนไว้มาดูครับ ![](/images/bbcode/grin.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-05-01 17:54:00 |
By :
mr.win |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
อันนี้ครับ รบกวนหน่อยครับ^^
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace picture
{
public partial class Form1 : Form
{
string pic;
Bitmap bmpsave;
WebCam webcam;
SqlConnection cnn;
string connectionString = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
connectionString = "Server=RFID-PC\\SQLEXPRESS;UID=sa;PASSWORD=admin;Database=RFID;";
cnn = new SqlConnection(connectionString);
pic = Convert.ToString(imgVideo.Image);
if (File.Exists(pic))
{
byte[] content = ImageToStream(pic);
cnn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO DATAALL (PHOTO)", cnn);
cmd.Parameters.AddWithValue("@PHOTO", content);
cmd.ExecuteNonQuery();
cnn.Close();
MessageBox.Show("Image inserted");
}
else
{
MessageBox.Show(pic + " not found ");
}
}
private byte[] ImageToStream(string fileName)
{
MemoryStream stream = new MemoryStream();
tryagain:
try
{
Bitmap image = new Bitmap(fileName);
image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception ex)
{
goto tryagain;
}
return stream.ToArray();
}
private void button3_Click(object sender, EventArgs e)
{
imgVideo.Image = imgVideo.Image;
webcam.Stop();
}
private void button4_Click(object sender, EventArgs e)
{
webcam.Continue();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'rFIDDataSet2.DATAALL' table. You can move, or remove it, as needed.
this.dATAALLTableAdapter.Fill(this.rFIDDataSet2.DATAALL);
webcam = new WebCam();
webcam.InitializeWebCam(ref imgVideo);
webcam.Start();
}
}
}
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-05-01 19:35:48 |
By :
watasin03 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (C#)
private void checkfile()
{
int count, countdown;
count = 999;
countdown = 100;
while (countdown <= count)
{
countdown = countdown + 1;
if (File.Exists(Application.StartupPath + "\\MyScreenshot" + countdown + ".png"))
{
}
else
{
path = Application.StartupPath + "\\MyScreenshot" + countdown + ".png";
countdown = 1000;
}
}
}
แค่บันทึกไฟล์นะครับ
ลองเอาไปดูเป็นแนวทางแล้วประยุกต์เอานะครับ
ก่อนจะทำการบันทึกไฟล์ให้เรียก checkfile() ก่อนนะครับ
หลักการของมันนะครับ
-การบันทึกไฟล์จะอยู่ใน path ที่ โปรแกรมนั้นอยู่
-การตั้งชื่อไฟล์จะบันทึกตั้งแต่ MyScreenshot101 ขึ้นไป
-หากมีไฟล์ MyScreenshot101 อยู่แล้ว จะบันทึก MyScreenshot102 แทน
-หากมี 101 และ 103 ไฟล์มันจะบันทึก 102 แทรกเข้าไปนะครับ
|
ประวัติการแก้ไข 2013-05-01 20:09:41
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-05-01 20:08:10 |
By :
ForeverSaiZ |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
![](/images/bbcode/grin.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2013-05-01 20:56:42 |
By :
mr.win |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอ Code VB.net หน่อย
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2022-11-14 14:02:51 |
By :
vishnu |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 03
|