Sunday 14 December 2014

VB6.0 :: PROGRAM MENGHAPUS FILE DI DALAM RECYLCLE BIN

PROGRAM MENGHAPUS FILE DI DALAM RECYLCLE BIN


Tambahkan Barisan Coding Di bawah Kedalam Modul dengan cara pilih Project – Add Modul.
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Public Const F0_DELETE = &H3
Public Const F0F_ALLOWUNDO = &H40
Public Const F0F_CREATEPROGRESSDLG As Long = &H0

Tuliskan Coding Dibawah ini ke dalam form :
Private Sub Form_Load()
Dim MyBool As Boolean
Mengganti 'c:\MyDir\MyFile.exe' Dengan nama Yang ingin Anda Hapus.
DelToRecycBin ("c:\MyDir\MyFile.exe")
End Sub

Public Function DelToRecycBin(FileName As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
On Error GoTo DelToRecycBin_Err
With FileOperation
.wFunc = F0_DELETE
.pFrom = FileName
.fFlags = F0F_ALLOWUNDO + F0F_CREATEPROGRESSDLG
End With
lReturn = SHFileOperation(FileOperation)
Exit Function
DelToRecycBin_Err:
MsgBox Err.Description
End Function

PROGRAM UNTUK MENDETEKSI TYPE DRIVE
'Tambahkan modul untuk proyek Anda (Dalam menu pilih Project -> Add Module, Kemudian klikOpen)
'Tambahkan 1 CommandButton (bernama Command1) dan 1 DriveListBox (bernama Drive1) untukmembentuk Anda.
'Pilih di DriveListBox drive yang ingin Anda untuk mendeteksi, dan tekan tombol.
'Masukkan kode untuk modul ini:
Declare Function GetDriveType Lib "kernel32" Alias ​​"GetDriveTypeA" _
(ByVal NDrive As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias ​​"GetLogicalDriveStringsA" _
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

‘masukkan coding di bawah ini ke dalam form :

Private Sub Command1_Click()
DriveType& = GetDriveType(Drive1.Drive)
Select Case DriveType
Case 1, 3: MsgBox "Hard Disk"
Case 2: MsgBox "Floppy Drive"
Case 4: MsgBox "Remote"
Case 5: MsgBox "CD Rom"
Case 6: MsgBox "RamDisk"
End Select
End Sub

VB6.0 :: PROGRAM MENGHAPUS FILE DI DALAM RECYLCLE BIN

PROGRAM MENGHAPUS FILE DI DALAM RECYLCLE BIN


Tambahkan Barisan Coding Di bawah Kedalam Modul dengan cara pilih Project – Add Modul.
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
Public Const F0_DELETE = &H3
Public Const F0F_ALLOWUNDO = &H40
Public Const F0F_CREATEPROGRESSDLG As Long = &H0

Tuliskan Coding Dibawah ini ke dalam form :
Private Sub Form_Load()
Dim MyBool As Boolean
Mengganti 'c:\MyDir\MyFile.exe' Dengan nama Yang ingin Anda Hapus.
DelToRecycBin ("c:\MyDir\MyFile.exe")
End Sub

Public Function DelToRecycBin(FileName As String)
Dim FileOperation As SHFILEOPSTRUCT
Dim lReturn As Long
On Error GoTo DelToRecycBin_Err
With FileOperation
.wFunc = F0_DELETE
.pFrom = FileName
.fFlags = F0F_ALLOWUNDO + F0F_CREATEPROGRESSDLG
End With
lReturn = SHFileOperation(FileOperation)
Exit Function
DelToRecycBin_Err:
MsgBox Err.Description
End Function

VB6.0 :: PROGRAM MENDETEKSI SUARA DI DALAM PC ANDA


Private Sub Form_Load()
Dim I As Integer
I = waveOutGetNumDevs()
If  I > 0 Then
MsgBox "Sistem Komputer Kamu Saat Ini Senang Memutar Lagu."
Else
MsgBox "Sistem Komputer Kamu Saat Ini Tidak Memutar Lagu."
End If
End Sub

VB6.0 :: Program Pengolah Warna Menggunakan Visual Basic 6.0


Adapun langkah-langkah pembuatan program pengolah warna menggunakan visual basic adalah sebagai berikut:
Buka program Visual Basic yang telah terinstal di komputer anda. Saya menggunakan visual basic versi 6.0.
Buat sebuah project baru.
  • Tambahkan sebuah control shape, sebuah kontrol frame (tidak terlalu penting) dan sebuah kontrol Vscroll/Hscroll dan beberapa label.
  • Ubah properties masing-masing kontrol terserah anda. Untuk kontrol shape1, ubah fillcolor jadi solid.
  • Copykan sebanyak dua kali kontol Vscroll/Hscroll. Jika muncul pesan klik yes. Sehingga akan terbentuk kontrol array dari Vscroll/Hscroll.
  • Susun program anda sedemikian rupa atau seperti gambar.1.
Gambar.1 Tampilan Program Pengolah Warna
  • Klik dua kali kontol Vscroll/Hscroll dan sisipkan script program berikut.
Shape1.FillColor = RGB(Vscroll1(0).Value, _
Vscroll1(1).Value, Vscroll1(2).Value)
  • Jalankan program buatan anda. Atur nilai warna, jika warna dari shape berubah maka program yang anda buat telah berhasil.

Program tersebut dapat terus dikembangkan dan semoga dapat membantu anda untuk mendalami pengolahan citra khususnya menggunakan visual basic.

Sumber : http://www.andisunesia.com/2011/04/program-pengolah-warna-menggunakan.html

MATLAB :: Deteksi wajah (face detection) menggunakan algoritma Viola-Jones


945431_692045540806193_773492431_n
1
2
3
4
5
faceDetector = vision.CascadeObjectDetector;
I = imread('visionteam.jpg');
bboxes = step(faceDetector, I);
IFaces = insertObjectAnnotation(I, 'rectangle', bboxes, 'Face');
figure, imshow(IFaces), title('Detected faces');

sumber :
http://pemrogramanmatlab.wordpress.com/2013/11/05/deteksi-wajah-face-detection-menggunakan-algoritma-viola-jones/

MATLAB :: Source code Face detection menggunakan matlab

FACE DETECTION - MATLAB CODE


  
Prerequisite: Computer vision system toolbox

FACE DETECTION:

clear all
clc
%Detect objects using Viola-Jones Algorithm

%To detect Face
FDetect = vision.CascadeObjectDetector;

%Read the input image
I = imread('HarryPotter.jpg');

%Returns Bounding Box values based on number of objects
BB = step(FDetect,I);

figure,
imshow(I); hold on
for i = 1:size(BB,1)
    rectangle('Position',BB(i,:),'LineWidth',5,'LineStyle','-','EdgeColor','r');
end
title('Face Detection');
hold off;



The step(Detector,I) returns Bounding Box value that contains [x,y,Height,Width] of the objects of interest.


BB =

    52    38    73    73
   379    84    71    71
   198    57    72    72

NOSE DETECTION:


%To detect Nose
NoseDetect = vision.CascadeObjectDetector('Nose','MergeThreshold',16);



BB=step(NoseDetect,I);


figure,
imshow(I); hold on
for i = 1:size(BB,1)
    rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','b');
end
title('Nose Detection');
hold off;





EXPLANATION:


To denote the object of interest as 'nose', the argument  'Nose' is passed.

vision.CascadeObjectDetector('Nose','MergeThreshold',16);

The default syntax for Nose detection :
vision.CascadeObjectDetector('Nose');

Based on the input image, we can modify the default values of the parameters passed tovision.CascaseObjectDetector. Here the default value for 'MergeThreshold' is 4.

When default value for 'MergeThreshold' is used, the result is not correct.
Here there are more than one detection on Hermione.




To avoid multiple detection around an object, the 'MergeThreshold' value can be overridden. 


MOUTH DETECTION:



%To detect Mouth
MouthDetect = vision.CascadeObjectDetector('Mouth','MergeThreshold',16);

BB=step(MouthDetect,I);


figure,
imshow(I); hold on
for i = 1:size(BB,1)
 rectangle('Position',BB(i,:),'LineWidth',4,'LineStyle','-','EdgeColor','r');
end
title('Mouth Detection');
hold off;



EYE DETECTION:


%To detect Eyes
EyeDetect = vision.CascadeObjectDetector('EyePairBig');

%Read the input Image
I = imread('harry_potter.jpg');

BB=step(EyeDetect,I);



figure,imshow(I);
rectangle('Position',BB,'LineWidth',4,'LineStyle','-','EdgeColor','b');
title('Eyes Detection');
Eyes=imcrop(I,BB);
figure,imshow(Eyes);







Cropped Image


I will discuss more about object detection and how to train detectors to identify object of our interest in my upcoming posts. Keep reading for updates.

Sumber : http://angeljohnsy.blogspot.com/2013/07/face-detection-matlab-code.html

Source Code Face Detection and Tracking Using CAMShift


Introduction



Object detection and tracking are important in many computer vision applications including activity recognition, automotive safety, and surveillance. In this example, you will develop a simple face tracking system by dividing the tracking problem into three separate problems:
  1. Detect a face to track
  2. Identify facial features to track
  3. Track the face
Step 1: Detect a Face To Track
Before you begin tracking a face, you need to first detect it. Use the vision.CascadeObjectDetector to detect the location of a face in a video frame. The cascade object detector uses the Viola-Jones detection algorithm and a trained classification model for detection. By default, the detector is configured to detect faces, but it can be configured for other object types.
% Create a cascade detector object.
faceDetector = vision.CascadeObjectDetector();

% Read a video frame and run the detector.
videoFileReader = vision.VideoFileReader('visionface.avi');
videoFrame = step(videoFileReader);
bbox = step(faceDetector, videoFrame);

% Draw the returned bounding box around the detected face.
videoOut = insertObjectAnnotation(videoFrame,'rectangle',bbox,'Face');
figure, imshow(videoOut), title('Detected face');
You can use the cascade object detector to track a face across successive video frames. However, when the face tilts or the person turns their head, you may lose tracking. This limitation is due to the type of trained classification model used for detection. To avoid this issue, and because performing face detection for every video frame is computationally intensive, this example uses a simple facial feature for tracking.
Step 2: Identify Facial Features To Track
Once the face is located in the video, the next step is to identify a feature that will help you track the face. For example, you can use the shape, texture, or color. Choose a feature that is unique to the object and remains invariant even when the object moves.
In this example, you use skin tone as the feature to track. The skin tone provides a good deal of contrast between the face and the background and does not change as the face rotates or moves.
% Get the skin tone information by extracting the Hue from the video frame
% converted to the HSV color space.
[hueChannel,~,~] = rgb2hsv(videoFrame);

% Display the Hue Channel data and draw the bounding box around the face.
figure, imshow(hueChannel), title('Hue channel data');
rectangle('Position',bbox(1,:),'LineWidth',2,'EdgeColor',[1 1 0])
Step 3: Track the Face
With the skin tone selected as the feature to track, you can now use the vision.HistogramBasedTracker for tracking. The histogram based tracker uses the CAMShift algorithm, which provides the capability to track an object using a histogram of pixel values. In this example, the Hue channel pixels are extracted from the nose region of the detected face. These pixels are used to initialize the histogram for the tracker. The example tracks the object over successive video frames using this histogram.
% Detect the nose within the face region. The nose provides a more accurate
% measure of the skin tone because it does not contain any background
% pixels.
noseDetector = vision.CascadeObjectDetector('Nose');
faceImage = imcrop(videoFrame,bbox(1,:));
noseBBox = step(noseDetector,faceImage);

% The nose bounding box is defined relative to the cropped face image.
% Adjust the nose bounding box so that it is relative to the original video
% frame.
noseBBox(1,1:2) = noseBBox(1,1:2) + bbox(1,1:2);

% Create a tracker object.
tracker = vision.HistogramBasedTracker;

% Initialize the tracker histogram using the Hue channel pixels from the
% nose.
initializeObject(tracker, hueChannel, noseBBox(1,:));

% Create a video player object for displaying video frames.
videoInfo = info(videoFileReader);
videoPlayer = vision.VideoPlayer('Position',[300 300 videoInfo.VideoSize+30]);

% Track the face over successive video frames until the video is finished.
while ~isDone(videoFileReader)

% Extract the next video frame
videoFrame = step(videoFileReader);

% RGB -> HSV
[hueChannel,~,~] = rgb2hsv(videoFrame);

% Track using the Hue channel data
bbox = step(tracker, hueChannel);

% Insert a bounding box around the object being tracked
videoOut = insertObjectAnnotation(videoFrame,'rectangle',bbox,'Face');

% Display the annotated video frame using the video player object
step(videoPlayer, videoOut);

end

% Release resources
release(videoFileReader);
release(videoPlayer);
Summary
In this example, you created a simple face tracking system that automatically detects and tracks a single face. Try changing the input video and see if you are able to track a face. If you notice poor tracking results, check the Hue channel data to see if there is enough contrast between the face region and the background.
Reference
[1] G.R. Bradski "Real Time Face and Object Tracking as a Component of a Perceptual User Interface", Proceedings of the 4th IEEE Workshop on Applications of Computer Vision, 1998.
[2] Viola, Paul A. and Jones, Michael J. "Rapid Object Detection using a Boosted Cascade of Simple Features", IEEE CVPR, 2001.

sumber : http://www.mathworks.com/help/vision/examples/face-detection-and-tracking-using-camshift.html