Cronicle8 Posted June 8, 2012 at 09:35 AM Report Share #461316 Posted June 8, 2012 at 09:35 AM Bom dia, Estou com uma duvida, eu consigo detetar uma cor (com o filtro) no video da webcam, mas para obter o que eu quero é preciso 2 filtros de cor, será possível fazê-lo? Obrigado pelas respostas em avanço. Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 01:09 PM Report Share #461392 Posted June 8, 2012 at 01:09 PM Explique melhor o que exatamente quer fazer ou como esta fazendo atualmente. Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 01:37 PM Author Report Share #461398 Posted June 8, 2012 at 01:37 PM Objetivo, substituir a cara e as mãos na webcam por uma imagem, e como eu estou a fazer é a partir de filtros de cor (AForge), só que só consigo ter um filtro de cada vez. private void cam_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Bitmap image = (Bitmap)eventArgs.Frame.Clone(); EuclideanColorFiltering filter = new EuclideanColorFiltering(); filter.CenterColor = new AForge.Imaging.RGB(colorDialog1.Color); //Pure White filter.Radius = 100; filter.FillOutside = true; //Increase this to allow off-whites filter.ApplyInPlace(image); //Cabeça blobCounter.FilterBlobs = true; blobCounter.ObjectsOrder = ObjectsOrder.Size; blobCounter.ProcessImage(image); Rectangle[] rects = blobCounter.GetObjectsRectangles(); Pen pen = new Pen(Color.Red, 1); foreach (Rectangle recs in rects) if (rects.Length > 0) { Graphics g = Graphics.FromImage(image); g.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\dog.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); //g.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\Hand.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); //g.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\Hand.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); g.Dispose(); } pictureBox1.Image = image; } Estou a fazer dessa maneira, será possivel usar dois filtros de cor, cada um com uma cor diferente, ou de outra maneira qulaquer? Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 01:39 PM Report Share #461400 Posted June 8, 2012 at 01:39 PM Você já tentou pegar a imagem resultante do primeiro filtro e aplicar um novo filtro nela? Isto funcionaria no seu caso? Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 02:09 PM Author Report Share #461416 Posted June 8, 2012 at 02:09 PM Já tentei isso, o problema de ter dois filtros é que um anula o outro, ou seja, suponhamos que tenho um filtro a detetar laranja e outro a detetar rosa, o resultado seria um ecrã preto e nenhuma cor. Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 02:14 PM Report Share #461418 Posted June 8, 2012 at 02:14 PM e se tentar aplicar os dois separadamente e posteriormente condensá-los em uma única imagem? Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 02:25 PM Author Report Share #461423 Posted June 8, 2012 at 02:25 PM Se te estiveres a referir a: EuclideanFilter filter 1 =... EclideanFilter filter2 =... filter1.apply(image); filter2.apply(image); Já tentei, mesmo resultado, se não te estiveres a referir a isso, poderias exlicar melhor. Obrigado. Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 02:30 PM Report Share #461426 Posted June 8, 2012 at 02:30 PM Nao estou pensando em algo mais no sentido de: 1) pegar a imagem, fazer uma cópia dela, temos então 2 imagens para trabalhar 2) aplicar um filtro numa imagem e outro filtro em outra. 3) mesclar o resultado em outra imagem (se este for seu objetivo). Ou daí trabalhar com as duas separadamente. Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 02:36 PM Author Report Share #461428 Posted June 8, 2012 at 02:36 PM Ok, já percebi, como eu já referi eu ainda sou novato, como posso fazer uma cópia da imagem (webcam), e como depois junto as duas? Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 03:10 PM Report Share #461451 Posted June 8, 2012 at 03:10 PM Bitmap image1 = (Bitmap)eventArgs.Frame.Clone(); Bitmap image2 = (Bitmap)eventArgs.Frame.Clone(); Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 03:24 PM Author Report Share #461460 Posted June 8, 2012 at 03:24 PM Como junto depois as duas imagens, da maneira que ue juntei a aplicação vai buscar a cor do filtro 1 mas deteta a definição(imagem) do filtro 2. Link to comment Share on other sites More sharing options...
petvetbr Posted June 8, 2012 at 03:50 PM Report Share #461466 Posted June 8, 2012 at 03:50 PM tem como colocar o seu código atualizado? Eu não mexo muito com a parte de imagens, mas talvez alguém mais possa te ajudar nisto. Fernando Lage Bastos - MCP/MCTS/MCPD Link to comment Share on other sites More sharing options...
Cronicle8 Posted June 8, 2012 at 04:00 PM Author Report Share #461469 Posted June 8, 2012 at 04:00 PM Aqui está o código atualizado: private void cam_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs) { Bitmap image1 = (Bitmap)eventArgs.Frame.Clone(); Bitmap image2 = (Bitmap)eventArgs.Frame.Clone(); EuclideanColorFiltering filter = new EuclideanColorFiltering(); EuclideanColorFiltering filter1 = new EuclideanColorFiltering(); filter.CenterColor = new AForge.Imaging.RGB(colorDialog1.Color); filter1.CenterColor = new AForge.Imaging.RGB(Color.Yellow); //Pure White filter.Radius = 100; filter1.Radius = 100; filter.FillOutside = true; filter1.FillOutside = true; //Increase this to allow off-whites filter.ApplyInPlace(image1); filter1.ApplyInPlace(image2); //Cabeça blobCounter.FilterBlobs = true; blobCounter.ObjectsOrder = ObjectsOrder.Size; blobCounter.ProcessImage(image1); Rectangle[] rects = blobCounter.GetObjectsRectangles(); Pen pen = new Pen(Color.Red, 1); foreach (Rectangle recs in rects) if (rects.Length > 0) { Graphics g = Graphics.FromImage(image1); Graphics g2 = Graphics.FromImage(image2); g.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\Platform Games\\dog.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); g2.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\Hand.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); //g.DrawImage(Bitmap.FromFile("C:\\Documents and Settings\\NEXTV035\\Ambiente de trabalho\\Daniel\\Hand.png"), rects[0].Location.X, rects[0].Location.Y, rects[0].Width, rects[0].Height); g.Dispose(); g2.Dispose(); } pictureBox1.Image = image1; pictureBox1.Image = image2; } Eu sei que aa ultima linha de código anula a anterior, mas foi a unica maneira que eu consigo "juntar" as duas. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now