#dotnet – Display a video file🎥 in Winform using #OpenCV and #net5

Buy Me A Coffee

Hi !

Super short post today, however is the base of the next series of posts around OpenCV and .Net 5. I already wrote on how to work with a webcam, and now it’s time to share a simple piece of code to show

How to open and process a video frame by frame

I’ve downloaded a “traffic cam” video from Youtube, and this is the output in a Winform.

Super easy ! And as usual, the source code

using System;
using System.Threading;
using System.Windows.Forms;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using Size = OpenCvSharp.Size;
namespace Demo13_WinFormVideoFromFile
{
public partial class Form1 : Form
{
private bool _run = false;
private VideoCapture _capture;
private Mat _image;
private Thread _cameraThread;
private string _videoFile = "4K camera example for Traffic Monitoring (Road).mp4";
private delegate void SafeCallDelegate(string text);
public Form1()
{
InitializeComponent();
Load += Form1_Load;
Closed += Form1_Closed;
}
private void Form1_Closed(object sender, EventArgs e)
{
_cameraThread.Interrupt();
_capture.Release();
}
private void btnStart_Click(object sender, EventArgs e)
{
_capture = new VideoCapture(_videoFile);
_run = true;
}
private void btnStop_Click(object sender, EventArgs e)
{
_run = false;
}
private void Form1_Load(object sender, EventArgs e)
{
_image = new Mat();
_cameraThread = new Thread(new ThreadStart(CaptureCameraCallback));
_cameraThread.Start();
}
private void CaptureCameraCallback()
{
while (true)
{
if (!_run) continue;
var startTime = DateTime.Now;
_capture.Read(_image);
if (_image.Empty()) return;
var imageRes = new Mat();
Cv2.Resize(_image, imageRes, new Size(320, 240));
var bmpWebCam = BitmapConverter.ToBitmap(imageRes);
pictureBoxWebCam.Image = bmpWebCam;
}
}
}
}

And the source video

Happy coding!

Greetings

El Bruno


References

#Event – Cold weather? > All the @MVPDays sessions available for offline viewing !

snowstormintoronto

Hi !

While we are enjoying this amazing days with -20C as average temperature, it’s maybe the perfect excuse to watch and learn with all the videos from yesterday’s MVP Days session.

All of the recording are available here: https://www.youtube.com/playlist?list=PLW-BLrn2azoSeYbDWqNeQa83B5R8gc2vY 

And the topics are:

  • MVPDays – Securing Service Accounts The Modern Way – John O’Neill Sr
  • MVPDays – DevOps ICU: Improving DevOps Results by (Correctly) Integrating UX – Debbie Levitt
  • MVPDays – Getting Started with Azure Devops – Gregor Suttie
  • MVPDays – Automate blockchain w/ Azure Blockchain Workbench and Microsoft Flow – StefanoTempesta
  • MVPDays – Getting Started with Machine Learning.Net and Windows Machine Learning – Bruno Capuano
  • MVPDays – Ten practical tips to secure your corporate data with Microsoft 365 – Peter Daalmans
  • MVPDays – The First 5 Things To Getting Started with Teams: IT Admin Edition – Jeremy Miller
  • MVPDays – Automate your Patching with Azure Patch Management – Sarah Lean
  • MVPDays – Xamarin and the Cloud – Rebai Hamida
  • MVPDays – Microsoft Teams: A Collaboration Story – Muditha Chathuranga
  • MVPDays – Hardening Windows Server – Orin Thomas
  • MVPDays – Azure AD Domain Services – domain controllers in the cloud? – Sam Cogan
  • MVPDays – Configure Azure AD Connect like the Pros – Max Fritz
  • MVPDays – Going Serverless on Azure – Ivan Culjak
  • MVPDays – Azure STack Development Kit the cheap Azure Development platform – Carsten Rachfahl

Happy coding !

Greetings @ Toronto

El Bruno

#Tutorial – How to build an #Amazon #AlexaSkill using Visual Studio 2017, C# and #Azure (5 on N)

Hi!

Now that I have written about how to use C # with Visual Studio 2017 to connect an Alexa Skill with an EndPoint in Azure, I think it’s time to share some contents which should be at the beginning of the series:

How to design and plan user interactions with Alexa

Of course, I will not write about it because the account of Alexa Developers has a great series of short videos about it. Here is the list of videos

How to Choose Projects for Voice – Amazon Alexa Voice Design Guide

Design for Voice in 3 Steps – Amazon Alexa Voice Design Guide

How to Understand Intents? – Amazon Alexa Voice Design Guide

How To Interact with Alexa – Amazon Alexa Voice Design Guide

And if we want something more for developers the next series of 6 episodes is what we should add to our list of videos

Developing Alexa Skills – Hello, Alexa! (Part 1 of 6)

 

Happy Coding!

Greetings @ Toronto

El Bruno

#Tutorial – Como crear un #Amazon #AlexaSkill con Visual Studio 2017, C# y #Azure (5 de N)

Buenas!

Ahora que ya he escritor sobre cómo utilizar C# con Visual Studio 2017 para conectar un Alexa Skill con un EndPoint en Azure, creo que es momento de escribir lo que debería ser el 1er post:

Como se debe diseñar y planificar las interacciones de usuario con Alexa

Eso sí, no voy a escribir al respecto ya que la cuenta de Alexa Developers tiene una serie grandiosa de videos cortos al respecto. He aquí la lista

How to Choose Projects for Voice – Amazon Alexa Voice Design Guide

Design for Voice in 3 Steps – Amazon Alexa Voice Design Guide

How to Understand Intents? – Amazon Alexa Voice Design Guide

How To Interact with Alexa – Amazon Alexa Voice Design Guide

Y si queremos algo más para developers la siguiente serie de 6 episodios es lo que debemos agregar a nuestra lista de

Developing Alexa Skills – Hello, Alexa! (Part 1 of 6)

 

Happy Coding!

Saludos @ Toronto

El Bruno