เขียนโปรแกรมจับตา โดยใช้ OPENCV
link น่าสนใจ
http://www.youtube.com/watch?v=LHfUeyxhgvk
http://www.youtube.com/watch?v=JL3Gbb9aY0c
https://opencv-code.com/tutorials/eye-detection-and-tracking/
http://hackaday.com/2012/05/30/opencv-k ... -tracking/
[ view entry ] ( 2965 views ) | permalink | ( 3 / 2550 )
การใช้ high Resolution Timer ด้วย c++
#include <windows.h>
#include <stdio.h>
#include <conio.h>
typedef struct {
LARGE_INTEGER start;
LARGE_INTEGER stop;
} stopWatch;
class CStopWatch {
private:
stopWatch timer;
LARGE_INTEGER frequency;
double LIToSecs( LARGE_INTEGER & L) ;
public:
CStopWatch() ;
void startTimer( ) ;
void stopTimer( ) ;
double getElapsedTime() ;
};
double CStopWatch::LIToSecs( LARGE_INTEGER & L) {
return ((double)L.QuadPart /(double)frequency.QuadPart) ;
}
CStopWatch::CStopWatch(){
timer.start.QuadPart=0;
timer.stop.QuadPart=0;
QueryPerformanceFrequency( &frequency ) ;
}
void CStopWatch::startTimer( ) {
QueryPerformanceCounter(&timer.start) ;
}
void CStopWatch::stopTimer( ) {
QueryPerformanceCounter(&timer.stop) ;
}
double CStopWatch::getElapsedTime() {
LARGE_INTEGER time;
time.QuadPart = timer.stop.QuadPart - timer.start.QuadPart;
return LIToSecs( time) ;
}
#define n 200000
int main(int argc, char*argv[])
{
int x[n];
int j= 0;
int k = 1;
int l = 0;
int m=0;
CStopWatch timer;
for(int k=1;k<n/2;k=k*2)
{
timer.startTimer();
for(int l=0;l<20;l++)
{
for(int i=0;i< k;i++)
{
m=i;
while(m<n)
{
//printf("%d ",m);
x[m] = 7*x[m]*x[m];
m = (m + k ) ;
}
}
}
timer.stopTimer();
printf("\nk= %d --> \t%lf\n\n",k,timer.getElapsedTime());
}
}
http://expert-programming-tutor.com/
[ view entry ] ( 2948 views ) | permalink | ( 3 / 2520 )
เฉลย Google Code jam 2009 : Welcome to google code jam (Dynamic Programming)
จากโจทย์
https://code.google.com/codejam/contest/90101/dashboard#s=p2&a=2
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
public class WelcomToGoogleCodeJam {
public static void main(String[] args) {
try {
String welcom = "welcome to code jam";
PrintWriter pw = new PrintWriter(new File("out-large.out"));
Scanner sc = new Scanner(new File("C-large-practice.in"));
int T = Integer.parseInt(sc.nextLine());
for (int i = 1; i <= T; i++) {
String s = sc.nextLine();
BigInteger mem[] = new BigInteger[welcom.length()];
for(int j=0;j< welcom.length();j++)
{
mem[j] = new BigInteger("0");
}
for (int j = 0; j < s.length(); j++) {
char x = s.charAt(j);
if (welcom.contains("" + x)) {
if (x == welcom.charAt(0)) {
mem[0] = mem[0] .add(BigInteger.ONE);
} else {
for (int k = 1; k < welcom.length(); k++) {
if (x == welcom.charAt(k))
mem[k] = mem[k].add( mem[k - 1]);
}
}
}
}
String output ;
output = String.format("%04d", mem[ welcom.length()-1].mod(new BigInteger( "10000")));
System.out.println("Case #"+i+": "+output);
pw.println("Case #"+i+": "+output);
}
pw.close();
} catch (IOException ee) {
ee.printStackTrace();
}
}
}
[ view entry ] ( 1371 views ) | permalink | ( 3 / 454 )
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
typedef struct Nodex
{
int data;
Nodex* next;
} Node ;
typedef struct List
{
int size;
Node * head;
} LinkedList;
void addFirst(LinkedList* ll , int data )
{
if(ll->head == NULL)
{
ll->head = (Node*)malloc(sizeof(Node));
ll->head->data = data;
ll->head->next = NULL;
}
else
{
Node * n= (Node*)malloc(sizeof(Node));
n->data = data;
n->next = ll->head;
ll->head = n;
}
ll->size ++;
}
void addLast(LinkedList* ll , int data )
{
if(ll->head == NULL)
{
ll->head = (Node*)malloc(sizeof(Node));
ll->head->data = data;
ll->head->next = NULL;
}
else
{
Node * n= (Node*)malloc(sizeof(Node));
n->data = data;
n->next = NULL;
Node * k = ll->head;
while(k->next != NULL)
{
k=k->next;
}
k->next = n;
}
ll->size ++;
}
void insert(LinkedList* ll , int data,int at)
{
if(ll->head == NULL)
{
if(at ==0 )
{
ll->head = (Node*)malloc(sizeof(Node));
ll->head->data = data;
ll->head->next = NULL;
}
}
else
{
Node * k = ll->head;
int i=0;
while(k->next != NULL&& i < at-1)
{
k=k->next;
i++;
}
Node * n= (Node*)malloc(sizeof(Node));
n->data = data;
n->next = k->next ;
k->next = n;
}
ll->size ++;
}
void print(LinkedList* ll)
{
Node * k = ll->head;
int i=0;
while(k != NULL)
{
printf(" [%d]-> ",k->data, k->next );
k=k->next;
i++;
}
printf("\n");
}
void removeLast(LinkedList * ll)
{
if(ll->head == NULL) return;
if(ll->size == 1)
{
free (ll->head);
ll->head = NULL;
ll->size --;
return;
}
Node * k = ll->head;
int i=0;
while(k->next->next != NULL )
{
k=k->next;
i++;
}
free (k->next);
k->next = NULL;
ll->size --;
}
void sort(LinkedList * ll)
{
if(ll->head == NULL) return ;
int s = ll->size;
int i = 0 ;
int m;
for(;i < s ; i++)
{
Node * k = ll->head;
int j=0;
while(k->next != NULL && j < s- i )
{
if( k->data > k->next->data)
{
m = k->data;
k->data = k->next->data;
k->next->data = m;
}
k=k->next;
j++;
}
}
}
void removeFirst(LinkedList * ll)
{
if(ll->head == NULL) return;
Node * n= ll->head;
ll->head = ll->head->next;
free(n);
ll->size --;
}
void deleteListAll(LinkedList * ll)
{
while(ll->size > 0 )
{
removeFirst( ll);
}
}
int main(int argc,char* argv[])
{
LinkedList ll;
ll.head = NULL;
ll.size = 0;
addFirst (&ll,5);
addFirst (&ll,15);
addFirst (&ll,3);
addFirst (&ll,4);
addFirst (&ll,2);
addLast (&ll,21);
insert (&ll,40,1);
print (&ll);
sort(&ll);
print (&ll);
deleteListAll(&ll);
return 0;
}
[ view entry ] ( 2941 views ) | permalink | ( 3.1 / 1249 )
มาเขียนโปรแกรม FACE DETECTION ด้วย C# กันเถอะ
จริงๆ ACCORD.VISION (http://accord-framework.net/) อันนี้มันก็คือ Image Processign โดย ใช้ Aforge.NET (http://www.aforgenet.com/) เป็นฐานนะครับ
1 Load Accord.Vision จาก NUGET ตามรูป
2 ใช้ CODE ดังนี้
HaarObjectDetector detector;
HaarCascade cascade = new FaceHaarCascade();
detector = new HaarObjectDetector(cascade, 120);
detector.SearchMode = (ObjectDetectorSearchMode.Default);
detector.ScalingMode = (ObjectDetectorScalingMode.SmallerToGreater);
detector.ScalingFactor = 1.5f;
detector.UseParallelProcessing = true;
detector.Suppression = 2;
Stopwatch sw = Stopwatch.StartNew();
// Process frame to detect objects
Rectangle[] objects = detector.ProcessFrame(bitmap);
sw.Stop();
if (objects.Length > 0)
{
RectanglesMarker marker = new RectanglesMarker(objects, Color.Fuchsia);
bitmap = marker.Apply(bitmap);
}
ผลที่ได้
[ view entry ] ( 1637 views ) | permalink | ( 3 / 2513 )
<<First <Back | 1 | 2 | 3 | 4 | 5 | Next> Last>>