Implementasi Content Based Video retrieval Menggunakan Speede-Up Robust Features (Surf)
A-16
LISTING PROGRAM
Form Home.cs
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.IO;
namespace SURF_Algorithm
{
public partial class Form_Home : Form
{
public Form_Home()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
if (MessageBox.Show("Tutup Aplikasi ?", "Konfirmasi",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
Application.ExitThread();
else
e.Cancel = true;
}
private void keluarToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void videoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form_Video FV = new Form_Video();
Hide(); FV.Show();
}
private void Form_Home_Load(object sender, EventArgs e)
{
Directory.CreateDirectory(Application.StartupPath + "\\Data");
Directory.CreateDirectory(Application.StartupPath +
"\\Data\\Frame");
Directory.CreateDirectory(Application.StartupPath +
"\\Data\\Video");
}
private void sURFToolStripMenuItem_Click(object sender, EventArgs e)
Universitas Sumatera Utara
A-16
{
Form_SURF FS = new Form_SURF();
Hide(); FS.Show();
}
}
}
Form Video.cs
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Data.OleDb;
System.IO;
namespace SURF_Algorithm
{
public partial class Form_Video : Form
{
public Form_Video()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
Form_Home FH = new Form_Home();
FH.Show();
}
private void Form_Video_Load(object sender, EventArgs e)
{
Tampil_Data();
}
void Tampil_Data()
{
Konfigurasi.Koneksi();
Konfigurasi.DA = new OleDbDataAdapter("SELECT * FROM `Tabel Video`
ORDER BY Nama ASC", Konfigurasi.CONN);
Konfigurasi.DS = new DataSet();
Konfigurasi.DS.Clear();
Konfigurasi.DA.Fill(Konfigurasi.DS, "Tabel Video");
DGV.DataSource = Konfigurasi.DS.Tables["Tabel Video"];
DGV.Refresh();
}
private void btn_tambah_Click(object sender, EventArgs e)
{
Form_Tambah_Video FTV = new Form_Tambah_Video();
Universitas Sumatera Utara
A-16
FTV.ShowDialog();
}
private void btn_hapus_Click(object sender, EventArgs e)
{
if (groupBox2.Text == "Player : ")
{
MessageBox.Show("Pilih Video Yang Ingin Di Hapus", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (MessageBox.Show("Hapus Video " +
groupBox2.Text.Replace("Player : ", "") + " ?", "Konfirmasi",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
this.Cursor = Cursors.WaitCursor;
WMP.Ctlcontrols.stop();
WMP.URL = null;
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand("DELETE FROM `Tabel
Video` WHERE Nama = '" + groupBox2.Text.Replace("Player : ", "") + "'",
Konfigurasi.CONN);
Konfigurasi.CMD.ExecuteNonQuery();
Directory.Delete(Application.StartupPath + "\\Data\\Frame\\"
+ Path.GetFileNameWithoutExtension(groupBox2.Text.Replace("Player : ", "")),
true);
File.Delete(Application.StartupPath + "\\Data\\Video\\" +
groupBox2.Text.Replace("Player : ", ""));
this.Cursor = Cursors.Default;
groupBox2.Text = "Player : ";
MessageBox.Show("Video Berhasil Di Hapus", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
Tampil_Data();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void txt_cari_TextChanged(object sender, EventArgs e)
{
try
{
Konfigurasi.Koneksi();
Konfigurasi.DA = new OleDbDataAdapter("SELECT * FROM `Tabel
Video` WHERE Nama like '%" + txt_cari.Text + "%'", Konfigurasi.CONN);
Konfigurasi.DS = new DataSet();
Konfigurasi.DS.Clear();
Konfigurasi.DA.Fill(Konfigurasi.DS, "Tabel Video");
DGV.DataSource = Konfigurasi.DS.Tables["Tabel Video"];
DGV.Refresh();
}
catch
{
}
}
Universitas Sumatera Utara
A-16
private void DGV_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
groupBox2.Text = "Player : " +
DGV.Rows[e.RowIndex].Cells[0].Value.ToString();
WMP.URL = DGV.Rows[e.RowIndex].Cells[3].Value.ToString();
}
catch
{
}
}
private void btn_reload_Click(object sender, EventArgs e)
{
Tampil_Data();
}
private void DGV_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
}
}}
Form Tambah Video.cs
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;
System.Threading;
Emgu.CV;
Emgu.CV.Structure;
Emgu.Util;
System.Drawing.Imaging;
System.IO;
System.Data.OleDb;
namespace SURF_Algorithm
{
public partial class Form_Tambah_Video : Form
{
private Capture _capture = null;
Image frame;
double
double
double
double
FrameRate = 0;
TotalFrames = 0;
Framesno = 0;
codec_double = 0;
Universitas Sumatera Utara
A-16
string Tnama, Tdurasi, Tframe, Tlokasi, TLFrame;
public Form_Tambah_Video()
{
InitializeComponent();
}
private void ReleaseData()
{
if (_capture != null)
_capture.Dispose();
}
private void ProcessFrame(object sender, EventArgs arg)
{
try
{
Framesno =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
frame = _capture.QueryFrame();
if (frame != null)
{
pictureBox1.Image = frame.ToBitmap();
if (Video_seek.Value + (int)(FrameRate) <
Video_seek.Maximum)
{
Video_seek.Value = (int)(Framesno);
double time_index =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_MSEC);
Time_Label.Text = "Time: " +
TimeSpan.FromMilliseconds(time_index).ToString().Substring(0, 8);
double framenumber =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
Frame_lbl.Text = "Frame: " + framenumber.ToString();
SaveImage(framenumber.ToString());
Video_seek.Value += (int)FrameRate;
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
}
Thread.Sleep((int)(1000.0 / FrameRate));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
public void SaveImage(string frameNumber)
{
using (var m = new MemoryStream())
{
pictureBox1.Image.Save(m, ImageFormat.Jpeg);
var img = Image.FromStream(m);
Universitas Sumatera Utara
A-16
var path = TLFrame +
Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "-" + frameNumber +
".jpg";
img.Save(path);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Brows")
{
openFileDialog1.Filter = "MP4|*.mp4";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//Buat Folder Baru Untuk Frame Video
TLFrame = Application.StartupPath + "\\Data\\Frame\\" +
Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "\\";
if(Directory.Exists(TLFrame))
{
MessageBox.Show("Video Sudah Ada Dalam Database.",
"Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(TLFrame);
try
{
_capture = null;
_capture = new Capture(openFileDialog1.FileName);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT,
240);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH,
320);
FrameRate =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
TotalFrames =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
codec_double =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC);
string s = new
string(Encoding.UTF8.GetString(BitConverter.GetBytes(Convert.ToUInt32(codec_doub
le))).ToCharArray());
Codec_lbl.Text = "Codec: " + s;
Video_seek.Minimum = 0;
Video_seek.Maximum = (int)TotalFrames - 1;
Application.Idle += ProcessFrame;
button1.Text = "Save";
textBox1.Text = openFileDialog1.FileName;
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
}
else if (button1.Text == "Save")
{
Universitas Sumatera Utara
A-16
_capture.Stop();
Application.Idle -= ProcessFrame;
ReleaseData();
button1.Text = "Brows";
pictureBox1.Image = Properties.Resources.Temp;
Video_seek.Value = 0;
try
{
//Simpan Data
Tnama = openFileDialog1.SafeFileName;
Tdurasi = Time_Label.Text.Replace("Time: ", "");
string[] Gambars = Directory.GetFiles(TLFrame);
Tframe = Gambars.Length.ToString();
Tlokasi = Application.StartupPath + "\\Data\\Video\\" +
openFileDialog1.SafeFileName;
File.Copy(openFileDialog1.FileName, Application.StartupPath
+ "\\Data\\Video\\" + Tnama, true);
string Q = "INSERT INTO `Tabel Video` VALUES('"+ Tnama +"',
'"+ Tdurasi +"', '"+ Tframe +"', '"+ Tlokasi +"')";
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand(Q, Konfigurasi.CONN);
Konfigurasi.CMD.ExecuteNonQuery();
MessageBox.Show("Video Berhasil Di Tambah", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception)
{
MessageBox.Show("Gagal Menyimpan Video", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void Video_seek_Scroll(object sender, EventArgs e)
{
if (_capture != null)
{
if (_capture.GrabProcessState == ThreadState.Running)
{
_capture.Pause();
while (_capture.GrabProcessState == ThreadState.Running) ;
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
_capture.Start();
}
else
{
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
ProcessFrame(null, null);
}
}
}}}
Universitas Sumatera Utara
A-16
Form Player.cs
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Data.OleDb;
namespace SURF_Algorithm
{
public partial class Form_Player : Form
{
public string video;
public Form_Player()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
WMP.Dispose();
}
private void Form_Player_Load(object sender, EventArgs e)
{
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand("SELECT Lokasi FROM `Tabel Video`
WHERE Nama like '%" + video + "%'", Konfigurasi.CONN);
Konfigurasi.DR = Konfigurasi.CMD.ExecuteReader();
Konfigurasi.DR.Read();
WMP.URL = Konfigurasi.DR.GetString(0);
this.Text += " - " + video;
}
}}
Form SURF.cs
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
Emgu.CV;
Emgu.CV.Structure;
System.IO;
Universitas Sumatera Utara
A-16
namespace SURF_Algorithm
{
public partial class Form_SURF : Form
{
public Form_SURF()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
Form_Home FH = new Form_Home();
FH.Show();
}
private void Form_SURF_Load(object sender, EventArgs e)
{
Reset();
}
private void btn_pil_gambar_Click(object sender, EventArgs e)
{
ofd.Filter = "Image Files |*.gif;*.jpg;*.jpeg;*.bmp;*.wmf;*.png";
ofd.FileName = "";
if (ofd.ShowDialog() == DialogResult.OK)
{
pb_gbr1.Image = Image.FromFile(ofd.FileName);
txt_pil_gambar.Text = ofd.FileName;
}
}
private void btn_reset_Click(object sender, EventArgs e)
{
Reset();
}
private void Reset()
{
btn_pil_gambar.Focus();
txt_log.Text = "--> ";
txt_pil_gambar.Clear();
lbl_wp.Text = "- Detik";
lbl_th.Text = "0 Video";
pb_gbr1.Image = Properties.Resources.Temp;
pb_gbr2.Image = Properties.Resources.Temp;
pb_gbr_hasil.Image = Properties.Resources.Temp;
lb_video.Items.Clear();
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
long matchTime;
double Waktu_Proses = 0.0;
String Sample_Gambar = txt_pil_gambar.Text;
//Mengambil List Folder Gambar
Universitas Sumatera Utara
A-16
string[] Folders = Directory.GetDirectories(Application.StartupPath
+ "\\Data\\Frame");
foreach (string Folder in Folders)
{
bool Cocok;
int JC = 0;
//Mengambil List Gambar
string[] Gambars = Directory.GetFiles(Folder);
string video = new
DirectoryInfo(Path.GetDirectoryName(Gambars[0])).Name;
int skip = Gambars.Length.ToString().Length;
for (int i=0; i= 1)
{
lb_video.Items.Add(video);
lbl_th.Text = lb_video.Items.Count.ToString();
break;
}
}
}
}
private void bw_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
this.Cursor = Cursors.Default;
MessageBox.Show("Proses Selesai", "Pesan", MessageBoxButtons.OK,
MessageBoxIcon.Information);
btn_cari.Enabled = true;
btn_reset.Enabled = true;
btn_pil_gambar.Enabled = true;
}
private void pb_gbr_hasil_DoubleClick(object sender, EventArgs e)
{
if (groupBox4.Left == 507 && groupBox4.Top == 77)
{
groupBox4.Left = 10;
groupBox4.Top = 10;
groupBox4.Width = this.Width - 35;
groupBox4.Height = this.Height - 110;
Universitas Sumatera Utara
A-16
groupBox4.BringToFront();
} else
{
groupBox4.Left = 507;
groupBox4.Top = 77;
groupBox4.Width = 165;
groupBox4.Height = 165;
}
}
private void btn_cari_Click(object sender, EventArgs e)
{
if (txt_pil_gambar.Text == "")
{
MessageBox.Show("Pilih Gambar Terlebih Dahulu", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
lbl_wp.Text = "- Detik";
lbl_th.Text = "0 Video";
lb_video.Items.Clear();
bw.RunWorkerAsync();
Control.CheckForIllegalCrossThreadCalls = false;
btn_cari.Enabled = false;
btn_reset.Enabled = false;
btn_pil_gambar.Enabled = false;
}
private void lb_video_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Form_Player FP = new Form_Player();
FP.video = lb_video.SelectedItem.ToString();
FP.ShowDialog();
}
catch
{}
}
}}
SURF.CS
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Drawing;
System.Runtime.InteropServices;
Emgu.CV;
Universitas Sumatera Utara
A-16
using
using
using
using
using
Emgu.CV.CvEnum;
Emgu.CV.Features2D;
Emgu.CV.Structure;
Emgu.CV.Util;
Emgu.CV.GPU;
namespace SURF_Algorithm
{
public static class SURF
{
///
/// Draw the model image and observed image, the matched features and
homography projection.
///
/// The model image
/// The observed image
/// The output total time for computing the
homography matrix.
/// The model image and observed image, the matched features
and homography projection.
public static Image Draw(String modelImageFileName, String
observedImageFileName, out long matchTime, out bool Cocok)
{
Image modelImage = new Image(modelImageFileName);
Image observedImage = new Image(observedImageFileName);
Stopwatch watch;
HomographyMatrix homography = null;
SURFDetector surfCPU = new SURFDetector(500, false);
VectorOfKeyPoint modelKeyPoints;
VectorOfKeyPoint observedKeyPoints;
Matrix indices;
Matrix mask;
int k = 2;
double uniquenessThreshold = 0.5;
if (GpuInvoke.HasCuda)
{
GpuSURFDetector surfGPU = new
GpuSURFDetector(surfCPU.SURFParams, 0.01f);
using (GpuImage gpuModelImage = new GpuImage(modelImage))
//extract features from the object image
using (GpuMat gpuModelKeyPoints =
surfGPU.DetectKeyPointsRaw(gpuModelImage, null))
using (GpuMat gpuModelDescriptors =
surfGPU.ComputeDescriptorsRaw(gpuModelImage, null, gpuModelKeyPoints))
using (GpuBruteForceMatcher matcher = new
GpuBruteForceMatcher(DistanceType.L2))
{
modelKeyPoints = new VectorOfKeyPoint();
surfGPU.DownloadKeypoints(gpuModelKeyPoints,
modelKeyPoints);
watch = Stopwatch.StartNew();
// extract features from the observed image
using (GpuImage gpuObservedImage = new
GpuImage(observedImage))
Universitas Sumatera Utara
A-16
using (GpuMat gpuObservedKeyPoints =
surfGPU.DetectKeyPointsRaw(gpuObservedImage, null))
using (GpuMat gpuObservedDescriptors =
surfGPU.ComputeDescriptorsRaw(gpuObservedImage, null, gpuObservedKeyPoints))
using (GpuMat gpuMatchIndices = new
GpuMat(gpuObservedDescriptors.Size.Height, k, 1, true))
using (GpuMat gpuMatchDist = new
GpuMat(gpuObservedDescriptors.Size.Height, k, 1, true))
using (GpuMat gpuMask = new
GpuMat(gpuMatchIndices.Size.Height, 1, 1))
using (Stream stream = new Stream())
{
matcher.KnnMatchSingle(gpuObservedDescriptors,
gpuModelDescriptors, gpuMatchIndices, gpuMatchDist, k, null, stream);
indices = new Matrix(gpuMatchIndices.Size);
mask = new Matrix(gpuMask.Size);
//gpu implementation of voteForUniquess
using (GpuMat col0 = gpuMatchDist.Col(0))
using (GpuMat col1 = gpuMatchDist.Col(1))
{
GpuInvoke.Multiply(col1, new
MCvScalar(uniquenessThreshold), col1, stream);
GpuInvoke.Compare(col0, col1, gpuMask,
CMP_TYPE.CV_CMP_LE, stream);
}
observedKeyPoints = new VectorOfKeyPoint();
surfGPU.DownloadKeypoints(gpuObservedKeyPoints,
observedKeyPoints);
//wait for the stream to complete its tasks
//We can perform some other CPU intesive stuffs here
while we are waiting for the stream to complete.
stream.WaitForCompletion();
gpuMask.Download(mask);
gpuMatchIndices.Download(indices);
if (GpuInvoke.CountNonZero(gpuMask) >= 4)
{
int nonZeroCount =
Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints,
indices, mask, 1.5, 20);
if (nonZeroCount >= 4)
homography =
Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints,
observedKeyPoints, indices, mask, 2);
}
watch.Stop();
}
}
}
else
{
//extract features from the object image
modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
Matrix modelDescriptors =
surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);
Universitas Sumatera Utara
A-16
watch = Stopwatch.StartNew();
// extract features from the observed image
observedKeyPoints = surfCPU.DetectKeyPointsRaw(observedImage,
null);
Matrix observedDescriptors =
surfCPU.ComputeDescriptorsRaw(observedImage, null, observedKeyPoints);
BruteForceMatcher matcher = new
BruteForceMatcher(DistanceType.L2);
matcher.Add(modelDescriptors);
indices = new Matrix(observedDescriptors.Rows, k);
using (Matrix dist = new
Matrix(observedDescriptors.Rows, k))
{
matcher.KnnMatch(observedDescriptors, indices, dist, k,
null);
mask = new Matrix(dist.Rows, 1);
mask.SetValue(255);
Features2DToolbox.VoteForUniqueness(dist,
uniquenessThreshold, mask);
}
int nonZeroCount = CvInvoke.cvCountNonZero(mask);
if (nonZeroCount >= 4)
{
nonZeroCount =
Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints,
indices, mask, 1.5, 20);
if (nonZeroCount >= 4)
homography =
Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints,
observedKeyPoints, indices, mask, 2);
}
watch.Stop();
}
//Draw the matched keypoints
Image result = Features2DToolbox.DrawMatches(modelImage,
modelKeyPoints, observedImage, observedKeyPoints,
indices, new Bgr(255, 255, 255), new Bgr(255, 255, 255), mask,
Features2DToolbox.KeypointDrawType.DEFAULT);
#region draw the projected region on the image
if (homography != null)
{ //draw a rectangle along the projected model
Cocok = true;
Rectangle rect = modelImage.ROI;
PointF[] pts = new PointF[] {
new PointF(rect.Left, rect.Bottom),
new PointF(rect.Right, rect.Bottom),
new PointF(rect.Right, rect.Top),
new PointF(rect.Left, rect.Top)};
homography.ProjectPoints(pts);
result.DrawPolyline(Array.ConvertAll(pts,
Point.Round), true, new Bgr(Color.Red), 5);
} else {
Universitas Sumatera Utara
A-16
Cocok = false;
}
#endregion
matchTime = watch.ElapsedMilliseconds;
return result;
}
}}
Program.cs
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Threading.Tasks;
System.Windows.Forms;
namespace SURF_Algorithm
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_Home());
}
}}
Konfigurasi.cs
using
using
using
using
System;
System.Data;
System.Data.OleDb;
System.Windows.Forms;
namespace SURF_Algorithm
{
public static class Konfigurasi
{
public static OleDbConnection CONN;
public static OleDbDataAdapter DA;
public static DataSet DS;
public static DataTable DT;
Universitas Sumatera Utara
A-16
public static OleDbCommand CMD;
public static OleDbDataReader DR;
public static void Koneksi()
{
try
{
const string Q = "provider=microsoft.jet.oledb.4.0; data source
= DB.mdb;";
CONN = new OleDbConnection(Q);
if (CONN.State == ConnectionState.Closed)
{
CONN.Open();
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Database Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Universitas Sumatera Utara
DAFTAR RIWAYAT HIDUP
CURRICULUM VITAE
I.
DATA PRIBADI / Personal Identification
Nama Lengkap
:
EviP. Marpaung
Tempat /
:
Medan /
Tanggal Lahir
16 Februari 1995
Jenis Kelamin
:
Perempuan
Agama
:
Kristen Protestan
Kebangsaan
:
Indonesia
Alamat
:
DSN IX Jl. Sejarah No.54 DesaMekar Sari,Delitua, Sumatera Utara,
Indonesia 20035
II.
Telepon
:
+6281260957680
Tinggi / Berat
:
163 cm / 48 kg
Email
:
evimarpaung131401107@gmail.com
KESEHATAN / Health
Tidak memiliki cacat fisik maupun mental dan tidak memiliki penyakit bawaan.
Universitas Sumatera Utara
III.
IV.
KEMAMPUAN / Capabilities
Bahasa
: Indonesia, Inggris
Bahasa Pemrograman
: C#
Database
: MySQL
Lainnya
: Ms. Office
PENDIDIKAN FORMAL / Formal Education
[ 2013 – 2017 ]
“Implementasi Content Based Video Retrieval Menggunakan Speeded-Up Robust
Features”
S1 Ilmu Komputer, Fakultas Ilmu Komputer dan Teknologi Informasi
Universitas Sumatera Utara
[ 2010 – 2013 ]
SMA Negeri 2 Medan
[ 2007 – 2010 ]
SMP Negeri 34 Medan
[ 2001 – 2007 ]
SD N 060899
[2000 – 2001 ]
TK ‘Aisyiyah Bustanul Athfal
V.
PENDIDIKAN NON-FORMAL / Informal Education
[ 2012 – 2013 ]
BT / BS Medica, Medan
[ 2004 – 2005 ]
Standard English Courses, Medan
VI.
PRESTASI / Achievements
1)
Sertifikasi Internasional Microsoft Office Powerpoint 2010 , Medan [2016]
VII. SEMINAR / Seminars
1)
Peserta Seminar Nasional Bank Indonesia , Universitas Sumatera Utara, Medan [2016]
Universitas Sumatera Utara
2)
Peserta Seminar Nasional Literasi Informasi (SENARAI) Fakultas Ilmu Komputer dan
Teknologi Informasi, Universitas Sumatera Utara, Medan [2014]
VIII. PENGALAMAN ORGANISASI / Organizational Experiences
1)
Anggota Unit Kegiatan Mahasiswa Kebaktian Mahasiswa Kristen Universitas Sumatera
Utara [2013 – 2017]
IX.
X.
PENGALAMAN KEPANITIAAN / Committee Experiences
1)
Anggota Kesehatan Penerimaan Mahasiswa Baru S1 Ilmu Komputer USU [2015]
2)
Anggota Konsumsi Paskah Oikumene USU [2014]
3)
Panitia Pelaksana Natal Oikumene USU [2014]
4)
Anggota Kesehatan PORSENI IMILKOM USU [2014]
5)
Anggota Dana Paskah Fasilkom-TI USU [2014]
6)
Anggota Humas Natal S1 Ilmu Komputer USU [2013]
PENGALAMAN BEKERJA / Working Experience
Praktik Kerja Lapangan di Kantor Wilayah Direktorat Jendral Pajak Sumatera I [2016]
Universitas Sumatera Utara
LISTING PROGRAM
Form Home.cs
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.IO;
namespace SURF_Algorithm
{
public partial class Form_Home : Form
{
public Form_Home()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
if (MessageBox.Show("Tutup Aplikasi ?", "Konfirmasi",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
Application.ExitThread();
else
e.Cancel = true;
}
private void keluarToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void videoToolStripMenuItem_Click(object sender, EventArgs e)
{
Form_Video FV = new Form_Video();
Hide(); FV.Show();
}
private void Form_Home_Load(object sender, EventArgs e)
{
Directory.CreateDirectory(Application.StartupPath + "\\Data");
Directory.CreateDirectory(Application.StartupPath +
"\\Data\\Frame");
Directory.CreateDirectory(Application.StartupPath +
"\\Data\\Video");
}
private void sURFToolStripMenuItem_Click(object sender, EventArgs e)
Universitas Sumatera Utara
A-16
{
Form_SURF FS = new Form_SURF();
Hide(); FS.Show();
}
}
}
Form Video.cs
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Data.OleDb;
System.IO;
namespace SURF_Algorithm
{
public partial class Form_Video : Form
{
public Form_Video()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
Form_Home FH = new Form_Home();
FH.Show();
}
private void Form_Video_Load(object sender, EventArgs e)
{
Tampil_Data();
}
void Tampil_Data()
{
Konfigurasi.Koneksi();
Konfigurasi.DA = new OleDbDataAdapter("SELECT * FROM `Tabel Video`
ORDER BY Nama ASC", Konfigurasi.CONN);
Konfigurasi.DS = new DataSet();
Konfigurasi.DS.Clear();
Konfigurasi.DA.Fill(Konfigurasi.DS, "Tabel Video");
DGV.DataSource = Konfigurasi.DS.Tables["Tabel Video"];
DGV.Refresh();
}
private void btn_tambah_Click(object sender, EventArgs e)
{
Form_Tambah_Video FTV = new Form_Tambah_Video();
Universitas Sumatera Utara
A-16
FTV.ShowDialog();
}
private void btn_hapus_Click(object sender, EventArgs e)
{
if (groupBox2.Text == "Player : ")
{
MessageBox.Show("Pilih Video Yang Ingin Di Hapus", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (MessageBox.Show("Hapus Video " +
groupBox2.Text.Replace("Player : ", "") + " ?", "Konfirmasi",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
this.Cursor = Cursors.WaitCursor;
WMP.Ctlcontrols.stop();
WMP.URL = null;
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand("DELETE FROM `Tabel
Video` WHERE Nama = '" + groupBox2.Text.Replace("Player : ", "") + "'",
Konfigurasi.CONN);
Konfigurasi.CMD.ExecuteNonQuery();
Directory.Delete(Application.StartupPath + "\\Data\\Frame\\"
+ Path.GetFileNameWithoutExtension(groupBox2.Text.Replace("Player : ", "")),
true);
File.Delete(Application.StartupPath + "\\Data\\Video\\" +
groupBox2.Text.Replace("Player : ", ""));
this.Cursor = Cursors.Default;
groupBox2.Text = "Player : ";
MessageBox.Show("Video Berhasil Di Hapus", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
Tampil_Data();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void txt_cari_TextChanged(object sender, EventArgs e)
{
try
{
Konfigurasi.Koneksi();
Konfigurasi.DA = new OleDbDataAdapter("SELECT * FROM `Tabel
Video` WHERE Nama like '%" + txt_cari.Text + "%'", Konfigurasi.CONN);
Konfigurasi.DS = new DataSet();
Konfigurasi.DS.Clear();
Konfigurasi.DA.Fill(Konfigurasi.DS, "Tabel Video");
DGV.DataSource = Konfigurasi.DS.Tables["Tabel Video"];
DGV.Refresh();
}
catch
{
}
}
Universitas Sumatera Utara
A-16
private void DGV_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
groupBox2.Text = "Player : " +
DGV.Rows[e.RowIndex].Cells[0].Value.ToString();
WMP.URL = DGV.Rows[e.RowIndex].Cells[3].Value.ToString();
}
catch
{
}
}
private void btn_reload_Click(object sender, EventArgs e)
{
Tampil_Data();
}
private void DGV_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
}
}}
Form Tambah Video.cs
using
using
using
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;
System.Threading;
Emgu.CV;
Emgu.CV.Structure;
Emgu.Util;
System.Drawing.Imaging;
System.IO;
System.Data.OleDb;
namespace SURF_Algorithm
{
public partial class Form_Tambah_Video : Form
{
private Capture _capture = null;
Image frame;
double
double
double
double
FrameRate = 0;
TotalFrames = 0;
Framesno = 0;
codec_double = 0;
Universitas Sumatera Utara
A-16
string Tnama, Tdurasi, Tframe, Tlokasi, TLFrame;
public Form_Tambah_Video()
{
InitializeComponent();
}
private void ReleaseData()
{
if (_capture != null)
_capture.Dispose();
}
private void ProcessFrame(object sender, EventArgs arg)
{
try
{
Framesno =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
frame = _capture.QueryFrame();
if (frame != null)
{
pictureBox1.Image = frame.ToBitmap();
if (Video_seek.Value + (int)(FrameRate) <
Video_seek.Maximum)
{
Video_seek.Value = (int)(Framesno);
double time_index =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_MSEC);
Time_Label.Text = "Time: " +
TimeSpan.FromMilliseconds(time_index).ToString().Substring(0, 8);
double framenumber =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES);
Frame_lbl.Text = "Frame: " + framenumber.ToString();
SaveImage(framenumber.ToString());
Video_seek.Value += (int)FrameRate;
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
}
Thread.Sleep((int)(1000.0 / FrameRate));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
public void SaveImage(string frameNumber)
{
using (var m = new MemoryStream())
{
pictureBox1.Image.Save(m, ImageFormat.Jpeg);
var img = Image.FromStream(m);
Universitas Sumatera Utara
A-16
var path = TLFrame +
Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "-" + frameNumber +
".jpg";
img.Save(path);
}
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Brows")
{
openFileDialog1.Filter = "MP4|*.mp4";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//Buat Folder Baru Untuk Frame Video
TLFrame = Application.StartupPath + "\\Data\\Frame\\" +
Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "\\";
if(Directory.Exists(TLFrame))
{
MessageBox.Show("Video Sudah Ada Dalam Database.",
"Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Directory.CreateDirectory(TLFrame);
try
{
_capture = null;
_capture = new Capture(openFileDialog1.FileName);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT,
240);
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH,
320);
FrameRate =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
TotalFrames =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
codec_double =
_capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FOURCC);
string s = new
string(Encoding.UTF8.GetString(BitConverter.GetBytes(Convert.ToUInt32(codec_doub
le))).ToCharArray());
Codec_lbl.Text = "Codec: " + s;
Video_seek.Minimum = 0;
Video_seek.Maximum = (int)TotalFrames - 1;
Application.Idle += ProcessFrame;
button1.Text = "Save";
textBox1.Text = openFileDialog1.FileName;
}
catch (NullReferenceException excpt)
{
MessageBox.Show(excpt.Message);
}
}
}
else if (button1.Text == "Save")
{
Universitas Sumatera Utara
A-16
_capture.Stop();
Application.Idle -= ProcessFrame;
ReleaseData();
button1.Text = "Brows";
pictureBox1.Image = Properties.Resources.Temp;
Video_seek.Value = 0;
try
{
//Simpan Data
Tnama = openFileDialog1.SafeFileName;
Tdurasi = Time_Label.Text.Replace("Time: ", "");
string[] Gambars = Directory.GetFiles(TLFrame);
Tframe = Gambars.Length.ToString();
Tlokasi = Application.StartupPath + "\\Data\\Video\\" +
openFileDialog1.SafeFileName;
File.Copy(openFileDialog1.FileName, Application.StartupPath
+ "\\Data\\Video\\" + Tnama, true);
string Q = "INSERT INTO `Tabel Video` VALUES('"+ Tnama +"',
'"+ Tdurasi +"', '"+ Tframe +"', '"+ Tlokasi +"')";
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand(Q, Konfigurasi.CONN);
Konfigurasi.CMD.ExecuteNonQuery();
MessageBox.Show("Video Berhasil Di Tambah", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception)
{
MessageBox.Show("Gagal Menyimpan Video", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void Video_seek_Scroll(object sender, EventArgs e)
{
if (_capture != null)
{
if (_capture.GrabProcessState == ThreadState.Running)
{
_capture.Pause();
while (_capture.GrabProcessState == ThreadState.Running) ;
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
_capture.Start();
}
else
{
_capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,
Video_seek.Value);
ProcessFrame(null, null);
}
}
}}}
Universitas Sumatera Utara
A-16
Form Player.cs
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Data.OleDb;
namespace SURF_Algorithm
{
public partial class Form_Player : Form
{
public string video;
public Form_Player()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
WMP.Dispose();
}
private void Form_Player_Load(object sender, EventArgs e)
{
Konfigurasi.Koneksi();
Konfigurasi.CMD = new OleDbCommand("SELECT Lokasi FROM `Tabel Video`
WHERE Nama like '%" + video + "%'", Konfigurasi.CONN);
Konfigurasi.DR = Konfigurasi.CMD.ExecuteReader();
Konfigurasi.DR.Read();
WMP.URL = Konfigurasi.DR.GetString(0);
this.Text += " - " + video;
}
}}
Form SURF.cs
using
using
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
Emgu.CV;
Emgu.CV.Structure;
System.IO;
Universitas Sumatera Utara
A-16
namespace SURF_Algorithm
{
public partial class Form_SURF : Form
{
public Form_SURF()
{
InitializeComponent();
this.Closing += (this.Keluar);
}
void Keluar(object sender, CancelEventArgs e)
{
Form_Home FH = new Form_Home();
FH.Show();
}
private void Form_SURF_Load(object sender, EventArgs e)
{
Reset();
}
private void btn_pil_gambar_Click(object sender, EventArgs e)
{
ofd.Filter = "Image Files |*.gif;*.jpg;*.jpeg;*.bmp;*.wmf;*.png";
ofd.FileName = "";
if (ofd.ShowDialog() == DialogResult.OK)
{
pb_gbr1.Image = Image.FromFile(ofd.FileName);
txt_pil_gambar.Text = ofd.FileName;
}
}
private void btn_reset_Click(object sender, EventArgs e)
{
Reset();
}
private void Reset()
{
btn_pil_gambar.Focus();
txt_log.Text = "--> ";
txt_pil_gambar.Clear();
lbl_wp.Text = "- Detik";
lbl_th.Text = "0 Video";
pb_gbr1.Image = Properties.Resources.Temp;
pb_gbr2.Image = Properties.Resources.Temp;
pb_gbr_hasil.Image = Properties.Resources.Temp;
lb_video.Items.Clear();
}
private void bw_DoWork(object sender, DoWorkEventArgs e)
{
this.Cursor = Cursors.WaitCursor;
long matchTime;
double Waktu_Proses = 0.0;
String Sample_Gambar = txt_pil_gambar.Text;
//Mengambil List Folder Gambar
Universitas Sumatera Utara
A-16
string[] Folders = Directory.GetDirectories(Application.StartupPath
+ "\\Data\\Frame");
foreach (string Folder in Folders)
{
bool Cocok;
int JC = 0;
//Mengambil List Gambar
string[] Gambars = Directory.GetFiles(Folder);
string video = new
DirectoryInfo(Path.GetDirectoryName(Gambars[0])).Name;
int skip = Gambars.Length.ToString().Length;
for (int i=0; i= 1)
{
lb_video.Items.Add(video);
lbl_th.Text = lb_video.Items.Count.ToString();
break;
}
}
}
}
private void bw_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
this.Cursor = Cursors.Default;
MessageBox.Show("Proses Selesai", "Pesan", MessageBoxButtons.OK,
MessageBoxIcon.Information);
btn_cari.Enabled = true;
btn_reset.Enabled = true;
btn_pil_gambar.Enabled = true;
}
private void pb_gbr_hasil_DoubleClick(object sender, EventArgs e)
{
if (groupBox4.Left == 507 && groupBox4.Top == 77)
{
groupBox4.Left = 10;
groupBox4.Top = 10;
groupBox4.Width = this.Width - 35;
groupBox4.Height = this.Height - 110;
Universitas Sumatera Utara
A-16
groupBox4.BringToFront();
} else
{
groupBox4.Left = 507;
groupBox4.Top = 77;
groupBox4.Width = 165;
groupBox4.Height = 165;
}
}
private void btn_cari_Click(object sender, EventArgs e)
{
if (txt_pil_gambar.Text == "")
{
MessageBox.Show("Pilih Gambar Terlebih Dahulu", "Pesan",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
lbl_wp.Text = "- Detik";
lbl_th.Text = "0 Video";
lb_video.Items.Clear();
bw.RunWorkerAsync();
Control.CheckForIllegalCrossThreadCalls = false;
btn_cari.Enabled = false;
btn_reset.Enabled = false;
btn_pil_gambar.Enabled = false;
}
private void lb_video_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Form_Player FP = new Form_Player();
FP.video = lb_video.SelectedItem.ToString();
FP.ShowDialog();
}
catch
{}
}
}}
SURF.CS
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Diagnostics;
System.Drawing;
System.Runtime.InteropServices;
Emgu.CV;
Universitas Sumatera Utara
A-16
using
using
using
using
using
Emgu.CV.CvEnum;
Emgu.CV.Features2D;
Emgu.CV.Structure;
Emgu.CV.Util;
Emgu.CV.GPU;
namespace SURF_Algorithm
{
public static class SURF
{
///
/// Draw the model image and observed image, the matched features and
homography projection.
///
/// The model image
/// The observed image
/// The output total time for computing the
homography matrix.
/// The model image and observed image, the matched features
and homography projection.
public static Image Draw(String modelImageFileName, String
observedImageFileName, out long matchTime, out bool Cocok)
{
Image modelImage = new Image(modelImageFileName);
Image observedImage = new Image(observedImageFileName);
Stopwatch watch;
HomographyMatrix homography = null;
SURFDetector surfCPU = new SURFDetector(500, false);
VectorOfKeyPoint modelKeyPoints;
VectorOfKeyPoint observedKeyPoints;
Matrix indices;
Matrix mask;
int k = 2;
double uniquenessThreshold = 0.5;
if (GpuInvoke.HasCuda)
{
GpuSURFDetector surfGPU = new
GpuSURFDetector(surfCPU.SURFParams, 0.01f);
using (GpuImage gpuModelImage = new GpuImage(modelImage))
//extract features from the object image
using (GpuMat gpuModelKeyPoints =
surfGPU.DetectKeyPointsRaw(gpuModelImage, null))
using (GpuMat gpuModelDescriptors =
surfGPU.ComputeDescriptorsRaw(gpuModelImage, null, gpuModelKeyPoints))
using (GpuBruteForceMatcher matcher = new
GpuBruteForceMatcher(DistanceType.L2))
{
modelKeyPoints = new VectorOfKeyPoint();
surfGPU.DownloadKeypoints(gpuModelKeyPoints,
modelKeyPoints);
watch = Stopwatch.StartNew();
// extract features from the observed image
using (GpuImage gpuObservedImage = new
GpuImage(observedImage))
Universitas Sumatera Utara
A-16
using (GpuMat gpuObservedKeyPoints =
surfGPU.DetectKeyPointsRaw(gpuObservedImage, null))
using (GpuMat gpuObservedDescriptors =
surfGPU.ComputeDescriptorsRaw(gpuObservedImage, null, gpuObservedKeyPoints))
using (GpuMat gpuMatchIndices = new
GpuMat(gpuObservedDescriptors.Size.Height, k, 1, true))
using (GpuMat gpuMatchDist = new
GpuMat(gpuObservedDescriptors.Size.Height, k, 1, true))
using (GpuMat gpuMask = new
GpuMat(gpuMatchIndices.Size.Height, 1, 1))
using (Stream stream = new Stream())
{
matcher.KnnMatchSingle(gpuObservedDescriptors,
gpuModelDescriptors, gpuMatchIndices, gpuMatchDist, k, null, stream);
indices = new Matrix(gpuMatchIndices.Size);
mask = new Matrix(gpuMask.Size);
//gpu implementation of voteForUniquess
using (GpuMat col0 = gpuMatchDist.Col(0))
using (GpuMat col1 = gpuMatchDist.Col(1))
{
GpuInvoke.Multiply(col1, new
MCvScalar(uniquenessThreshold), col1, stream);
GpuInvoke.Compare(col0, col1, gpuMask,
CMP_TYPE.CV_CMP_LE, stream);
}
observedKeyPoints = new VectorOfKeyPoint();
surfGPU.DownloadKeypoints(gpuObservedKeyPoints,
observedKeyPoints);
//wait for the stream to complete its tasks
//We can perform some other CPU intesive stuffs here
while we are waiting for the stream to complete.
stream.WaitForCompletion();
gpuMask.Download(mask);
gpuMatchIndices.Download(indices);
if (GpuInvoke.CountNonZero(gpuMask) >= 4)
{
int nonZeroCount =
Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints,
indices, mask, 1.5, 20);
if (nonZeroCount >= 4)
homography =
Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints,
observedKeyPoints, indices, mask, 2);
}
watch.Stop();
}
}
}
else
{
//extract features from the object image
modelKeyPoints = surfCPU.DetectKeyPointsRaw(modelImage, null);
Matrix modelDescriptors =
surfCPU.ComputeDescriptorsRaw(modelImage, null, modelKeyPoints);
Universitas Sumatera Utara
A-16
watch = Stopwatch.StartNew();
// extract features from the observed image
observedKeyPoints = surfCPU.DetectKeyPointsRaw(observedImage,
null);
Matrix observedDescriptors =
surfCPU.ComputeDescriptorsRaw(observedImage, null, observedKeyPoints);
BruteForceMatcher matcher = new
BruteForceMatcher(DistanceType.L2);
matcher.Add(modelDescriptors);
indices = new Matrix(observedDescriptors.Rows, k);
using (Matrix dist = new
Matrix(observedDescriptors.Rows, k))
{
matcher.KnnMatch(observedDescriptors, indices, dist, k,
null);
mask = new Matrix(dist.Rows, 1);
mask.SetValue(255);
Features2DToolbox.VoteForUniqueness(dist,
uniquenessThreshold, mask);
}
int nonZeroCount = CvInvoke.cvCountNonZero(mask);
if (nonZeroCount >= 4)
{
nonZeroCount =
Features2DToolbox.VoteForSizeAndOrientation(modelKeyPoints, observedKeyPoints,
indices, mask, 1.5, 20);
if (nonZeroCount >= 4)
homography =
Features2DToolbox.GetHomographyMatrixFromMatchedFeatures(modelKeyPoints,
observedKeyPoints, indices, mask, 2);
}
watch.Stop();
}
//Draw the matched keypoints
Image result = Features2DToolbox.DrawMatches(modelImage,
modelKeyPoints, observedImage, observedKeyPoints,
indices, new Bgr(255, 255, 255), new Bgr(255, 255, 255), mask,
Features2DToolbox.KeypointDrawType.DEFAULT);
#region draw the projected region on the image
if (homography != null)
{ //draw a rectangle along the projected model
Cocok = true;
Rectangle rect = modelImage.ROI;
PointF[] pts = new PointF[] {
new PointF(rect.Left, rect.Bottom),
new PointF(rect.Right, rect.Bottom),
new PointF(rect.Right, rect.Top),
new PointF(rect.Left, rect.Top)};
homography.ProjectPoints(pts);
result.DrawPolyline(Array.ConvertAll(pts,
Point.Round), true, new Bgr(Color.Red), 5);
} else {
Universitas Sumatera Utara
A-16
Cocok = false;
}
#endregion
matchTime = watch.ElapsedMilliseconds;
return result;
}
}}
Program.cs
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Threading.Tasks;
System.Windows.Forms;
namespace SURF_Algorithm
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_Home());
}
}}
Konfigurasi.cs
using
using
using
using
System;
System.Data;
System.Data.OleDb;
System.Windows.Forms;
namespace SURF_Algorithm
{
public static class Konfigurasi
{
public static OleDbConnection CONN;
public static OleDbDataAdapter DA;
public static DataSet DS;
public static DataTable DT;
Universitas Sumatera Utara
A-16
public static OleDbCommand CMD;
public static OleDbDataReader DR;
public static void Koneksi()
{
try
{
const string Q = "provider=microsoft.jet.oledb.4.0; data source
= DB.mdb;";
CONN = new OleDbConnection(Q);
if (CONN.State == ConnectionState.Closed)
{
CONN.Open();
}
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "Database Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Universitas Sumatera Utara
DAFTAR RIWAYAT HIDUP
CURRICULUM VITAE
I.
DATA PRIBADI / Personal Identification
Nama Lengkap
:
EviP. Marpaung
Tempat /
:
Medan /
Tanggal Lahir
16 Februari 1995
Jenis Kelamin
:
Perempuan
Agama
:
Kristen Protestan
Kebangsaan
:
Indonesia
Alamat
:
DSN IX Jl. Sejarah No.54 DesaMekar Sari,Delitua, Sumatera Utara,
Indonesia 20035
II.
Telepon
:
+6281260957680
Tinggi / Berat
:
163 cm / 48 kg
:
evimarpaung131401107@gmail.com
KESEHATAN / Health
Tidak memiliki cacat fisik maupun mental dan tidak memiliki penyakit bawaan.
Universitas Sumatera Utara
III.
IV.
KEMAMPUAN / Capabilities
Bahasa
: Indonesia, Inggris
Bahasa Pemrograman
: C#
Database
: MySQL
Lainnya
: Ms. Office
PENDIDIKAN FORMAL / Formal Education
[ 2013 – 2017 ]
“Implementasi Content Based Video Retrieval Menggunakan Speeded-Up Robust
Features”
S1 Ilmu Komputer, Fakultas Ilmu Komputer dan Teknologi Informasi
Universitas Sumatera Utara
[ 2010 – 2013 ]
SMA Negeri 2 Medan
[ 2007 – 2010 ]
SMP Negeri 34 Medan
[ 2001 – 2007 ]
SD N 060899
[2000 – 2001 ]
TK ‘Aisyiyah Bustanul Athfal
V.
PENDIDIKAN NON-FORMAL / Informal Education
[ 2012 – 2013 ]
BT / BS Medica, Medan
[ 2004 – 2005 ]
Standard English Courses, Medan
VI.
PRESTASI / Achievements
1)
Sertifikasi Internasional Microsoft Office Powerpoint 2010 , Medan [2016]
VII. SEMINAR / Seminars
1)
Peserta Seminar Nasional Bank Indonesia , Universitas Sumatera Utara, Medan [2016]
Universitas Sumatera Utara
2)
Peserta Seminar Nasional Literasi Informasi (SENARAI) Fakultas Ilmu Komputer dan
Teknologi Informasi, Universitas Sumatera Utara, Medan [2014]
VIII. PENGALAMAN ORGANISASI / Organizational Experiences
1)
Anggota Unit Kegiatan Mahasiswa Kebaktian Mahasiswa Kristen Universitas Sumatera
Utara [2013 – 2017]
IX.
X.
PENGALAMAN KEPANITIAAN / Committee Experiences
1)
Anggota Kesehatan Penerimaan Mahasiswa Baru S1 Ilmu Komputer USU [2015]
2)
Anggota Konsumsi Paskah Oikumene USU [2014]
3)
Panitia Pelaksana Natal Oikumene USU [2014]
4)
Anggota Kesehatan PORSENI IMILKOM USU [2014]
5)
Anggota Dana Paskah Fasilkom-TI USU [2014]
6)
Anggota Humas Natal S1 Ilmu Komputer USU [2013]
PENGALAMAN BEKERJA / Working Experience
Praktik Kerja Lapangan di Kantor Wilayah Direktorat Jendral Pajak Sumatera I [2016]
Universitas Sumatera Utara