Shell Scripting
For the first time in 10 years of programming someone asked for a shell script to do a bunch of operations.
I had never done such thing but I tought it should be easy.
One thing that helped me a lot was this cheat sheet. Extremelly usefull for some basic operations.
Also I was faced with a problem: How to get a dump of a pg database that is on a remote machine?
Well, I found a nice approach thanks to www.stackoverflow.com website. So here is the a little sample on how to perform that:
ssh $USERNAME@$HOSTNAME "pg_dump -f /dev/stdout -t tb1 -t tb2 -t tb3 dbname" > /export/bin/dbexport.sql err=$? if [ $err -ne 0 ]; then echo "Dump failed with error code ${err}!" fi
Was this usefull or what?Pela primeira vez em 10 anos de programação, pediram-me para codar um script shell para fazer um monte de operações
Nunca tinha feito antes mas passado algumas paginas de pesquisa percebi que era bastante simples até.
Uma das coisas que me ajudou muito foi esta cheat sheet. Extremamente útil para saber como fazer as operações mais básicas.
Também encontrei um problema no meio disto tudo: Como fazer dump de uma base de dados pg que esta numa maquina remota através de shell scripting?
Bom, encontrei uma boa maneira de seguir em frente graças ao site www.stackoverflow.com. Portanto aqui esta um pequeno exemplo de como é possível fazer isso:
ssh $USERNAME@$HOSTNAME "pg_dump -f /dev/stdout -t tb1 -t tb2 -t tb3 dbname" > /export/bin/dbexport.sql err=$? if [ $err -ne 0 ]; then echo "Dump failed with error code ${err}!" fi
Então é pratico ou não?
First DemoA Primeira Demo
Ok, aqui fica a minha primeira demonstração... É so uma coisa simples, basicamente tenho 2 views uma com o VideoStream RGB e outra com o DepthFieldStream.
É um exemplo bastante semelhante ao tutorial do Channel9 com alguma alterações pelo meio. Por exemplo não estou a usar apenas 3 distancias chave para desenhar as cores, em vez disso implementei a coloração em escala de cinzentos dependendo da distancia, assim da um efeito mais agradavel
Aqui esta o video:
Ok, so here is my first demo... Simple stuff, basically I have 2 views, one with the RGB VideoStream and another with the DepthFieldStream.
Pretty similar to the one of the Channel9 tutorial with some minor changes like I'm not using 3 diferent distance keys to draw the colors and implemented a grayscale colouring depending on the distance.... so it becomes a very smooth...
Here's a vid about it
Kinect + Emgu
Sorry about the inactivity but having and a daytime job and girlfriend sometimes leaves us without time.
using Emgu.CV; using Emgu.CV.UI; using Emgu.CV.Structure; using Emgu.Util; using Emgu.CV.CvEnum; using Microsoft.Research.Kinect.Nui; using Coding4Fun.Kinect.WinForm;
haar = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
will populate the the haarCascade object with that file.
kinect.Initialize(RuntimeOptions.UseColor); kinect.VideoFrameReady += new EventHandler(kinect_VideoFrameReady); kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
public Form1() { InitializeComponent(); haar = new HaarCascade("haarcascade_frontalface_alt_tree.xml"); kinect.Initialize(RuntimeOptions.UseColor); kinect.VideoFrameReady += new EventHandler(kinect_VideoFrameReady); kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); }
Image kinImage = new Image(e.ImageFrame.ToBitmap());
Image grayframe = nextFrame.Convert();
grayframe.DetectHaarCascade( haar, 1.4, 4, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(grayframe.Width / 8, grayframe.Height / 8) )[0];
foreach (var face in faces) { nextFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3); }
imageBox1.Image = nextFrame;
void kinect_VideoFrameReady(object sender, ImageFrameReadyEventArgs e) { Image kinImage = new Image(e.ImageFrame.ToBitmap()); using (Image; nextFrame = kinImage) { if (nextFrame != null) { // there's only one channel (greyscale), hence the zero index Image grayframe = nextFrame.Convert(); var faces = grayframe.DetectHaarCascade( haar, 1.4, 4, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(grayframe.Width / 14, grayframe.Height / 14) )[0]; foreach (var face in faces) { nextFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3); } imageBox1.Image = nextFrame; } } }
with good lightning, the detection occurs flawlessly
Descupem lá a inactividade nos ultimos tempos. mas ter um trabalho a tempo inteiro e ter namorada as vezes deixa-nos sem tempo.
using Emgu.CV; using Emgu.CV.UI; using Emgu.CV.Structure; using Emgu.Util; using Emgu.CV.CvEnum; using Microsoft.Research.Kinect.Nui; using Coding4Fun.Kinect.WinForm;
haar = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
vai pupolar o objecto haar com o ficheiro xml
kinect.Initialize(RuntimeOptions.UseColor); kinect.VideoFrameReady += new EventHandler(kinect_VideoFrameReady); kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
public Form1() { InitializeComponent(); haar = new HaarCascade("haarcascade_frontalface_alt_tree.xml"); kinect.Initialize(RuntimeOptions.UseColor); kinect.VideoFrameReady += new EventHandler(kinect_VideoFrameReady); kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color); }
Agora que ja temos o event hanler do VideoFrameReady, ele vai receber no ImageFreameReayEventArgs todos os dados relevantes acerca da imagem.
A primeira tarefa vai ser converter a imagem capturada num bitmap e converte-la outra vez para uma imagem do Emgu, de modo a podermos processa-la
Image kinImage = new Image(e.ImageFrame.ToBitmap());
Image grayframe = nextFrame.Convert();
grayframe.DetectHaarCascade( haar, 1.4, 4, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(grayframe.Width / 8, grayframe.Height / 8) )[0];
foreach (var face in faces) { nextFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3); }
imageBox1.Image = nextFrame;
void kinect_VideoFrameReady(object sender, ImageFrameReadyEventArgs e) { Image kinImage = new Image(e.ImageFrame.ToBitmap()); using (Image; nextFrame = kinImage) { if (nextFrame != null) { // there's only one channel (greyscale), hence the zero index Image grayframe = nextFrame.Convert(); var faces = grayframe.DetectHaarCascade( haar, 1.4, 4, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(grayframe.Width / 14, grayframe.Height / 14) )[0]; foreach (var face in faces) { nextFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3); } imageBox1.Image = nextFrame; } } }
Em excelentes condições de luminusidade a detecção de faces funciona na perfeição
Kinect SDK + EmguCV
Acho que é melhor começar pelo basico
Hoje vou começa a criar alguns controlos para brincar com o kinect. O primeiro vai ser um controlo para login, acho que vai ficar brutal sobretudo se fizer reconhecimento facial e reconhecimento de voz para inserir a password.
Mais tarde irei colocar codigo sobre estes controlos 🙂
I guess that it's better to start with the basics
Today I will start creating some controls to play with kinect. The first one will be a Login Control and I thought it will be great if I create a face recognition for use, and speech recognition to insert the password.
Later on I will post some code and the control code be aware 🙂
Power Supply Adapter has arrivedCarregado do Kinect chegou…
Almost miss the carrier delivery but I managed to get the power supply today so it's time to start downloading the sdk and development IDE
Por pouco que não apanhava o homem das encomendas, mas consegui por fim o transformador para o kinect... Esta na hora de começar a fazer o download do Kinect SDK e sacar um IDE
RequirementsRequisitos
As I believe, if you're reading this blog probably you are interested in develop over kinect or you're already doing it.
Acredito que, se estão a ler esta pagina, provavemente estão interessados em desenvolver aplicações para o kinect, ou então ja o estão a fazer...
Para os interessados aconselho a verem este link - Kinect SDK QuickStart Series.
Mas só isso não é o suficiente... por isso sugiro que façam download do Coding4Fun Kinect Toolkit. Assim teram todos os recursos necessarios para começar a brincar com o "bicho"
Still WaitingA eterna espera…
Right now I am anxiously waiting for the Kinect Power Supply Adapter to arrive and put the hand on...Neste momento estou desesperadamente a espera que o transformador do kinect chegue....