EmguCV capture rtsp ip camera stream ffmpeg - c#

I am working with IP camera and EmguCV to detect person in an area.
Everything is work normally with Highgui capture source.
But with Arlo camera which use FFMPEG format, I am unable to get stream without any exception.
Here is the code I have tried:
if (capture == null)
{
try
{
capture = new Capture("rtsp://<IP>:8554/live");
capture.ImageGrabbed += Capture_ImageGrabbed;
capture.Grab();
capture.Start();
}
catch (NullReferenceException exception)
{
MessageBox.Show(exception.Message);
}
catch (TypeInitializationException exc)
{
MessageBox.Show(
"Attention: You have to copy all the assemblies and native libraries from an official release of EmguCV to the directory of the demo." +
Environment.NewLine + Environment.NewLine + exc);
}
}
and here is Capture_ImageGrabbed event which is not fired.
private void Capture_ImageGrabbed(object sender, EventArgs e)
{
Mat image = new Mat();
capture.Retrieve(image);
picCAM.Image = image.Bitmap;
}
Thanks so much for your help!

This might be old, but until now I'm also facing the same issue, even using the newest version (which is version 3.3). Probably not the best solution, but after took some trial and error, what I did is to downgrade to version 2.4.2. You can download here.
I also recently submitted this issue in github. This is probably a bug.

Related

Leadtools - OcrException - ocr Not Enabled

I am using Leadtools OCR
I referenced the following DLLS:
Leadtools.dll
Leadtools.Barcode.oneD.dll
Leadtools.codecs.dll
Leadtools.codecs.fax.dll
Leadtools.codecs.png.dll
Leadtools.codecs.tif.dll
Leadtools.Forms.DocumentWriters.dll
Leadtools.forms.ocr.dll
Leadtools.forms.ocr.Advantage.dll
And the following code to convert a Png file to Pdf
private void button1_Click(object sender, EventArgs e)
{
try
{
string sourceFile = #"C:\Users\cf\Desktop\OcrTest\Images\Capture.PNG";
string targetFile = Path.ChangeExtension(sourceFile, "pdf");
using (IOcrEngine ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false))
{
ocrEngine.Startup(null, null, null, #"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime");
ocrEngine.AutoRecognizeManager.Run(sourceFile, targetFile, Leadtools.Forms.DocumentWriters.DocumentFormat.Pdf, null, null);
Process.Start(targetFile);
}
}
catch (OcrSupportLockedException ex)
{
Console.WriteLine("Support is locked. You need to unlock '{0}' in this engine to use this feature", ex.SupportType);
}
catch (OcrException ex)
{
Console.WriteLine("OCR Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
}
catch (RasterException ex)
{
Console.WriteLine("LEADTOOLS Error\nCode: {0}\nMessage:{1}", ex.Code, ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("System Error\nMessage:{0}", ex.Message);
}
}
The following line is returning an OcrException
Ocr Not Enabled
With the code: -1760
I cant figure out why this is happening
Any help would be appreciated
Error -1760 "OCR not enabled" is most likely caused by trying to use one of LEADTOOLS OCR engines without an appropriate license file or unlock key.
You could check before using CreateEngine() by calling RasterSupport.IsLocked( RasterSupportType.OcrAdvantage ). If the function returns TRUE, which means Locked, you should not try to use the OCR features.
To use OCR, you need to either own a valid toolkit license with OCR support in it, such as LEADTOOLS Document Imaging Suite, or have a valid free evaluation license.
The mechanism to enable OCR features depends on the toolkit version. If you already have a valid unlock key (v17 and earlier) or valid license file (version 17.5 and later), but it still fails, please send that license/unlock information to support#leadtools.com, since you should not post such details on a public forum.
If you don't have these details, send your toolkit serial number to sales#leadtools.com (also don't post it here!) You can also use our online chat service during working hours to contact support or sales.

Xamarin Android App not streaming online radio stream

So I'm trying to make a Android app for an online radio and no matter how much I use the guides on Xamarin, it's not streaming.
My code: http://pastebin.com/K20RX8Yk
The coding environment I am using is Xamarin.Android and I am coding in the Xamarin Studio. I've been using the Android emu running API 16.
I have already tried different path files but sadly that hasn't fixed it.
I would advice to use the MediaPlayer to stream audio on Android, as it is much easier to use then AudioTrack. Potentially AudioTrack could have better performance but you need to do quite some stuff yourself to get it working correctly.
Here is a blog post with example how to use MediaPlayer on Xamarin Android: http://blog.xamarin.com/background-audio-streaming-with-xamarin.android/
A quick example out of that is:
private const string Mp3 = #"http://167.88.113.131:8000/;stream.mp3";
private MediaPlayer player;
private void IntializePlayer()
{
player = new MediaPlayer();
//Tell our player to sream music
player.SetAudioStreamType(Stream.Music);
}
private async void Play()
{
if (player == null) {
IntializePlayer();
}
try {
await player.SetDataSourceAsync(ApplicationContext, Android.Net.Uri.Parse(Mp3));
player.PrepareAsync();
player.Start();
}
catch (Exception ex) {
//unable to start playback log error
Console.WriteLine("Unable to start playback: " + ex);
}
}

Camera server died! Error 100 when starting recording

NOTICE: I'm Using Monodroid, expect C# code.
I'm facing this error when the _recorder.Start() is called.
CODE:
private void IniciarGrabacion()
{
try
{
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.High);
String outputFile = "/sdcard/trompiz.mp4";
_camera.Unlock ();
_recorder = new MediaRecorder();
_recorder.SetCamera(_camera);
_recorder.SetAudioSource(AudioSource.Default);
_recorder.SetVideoSource(VideoSource.Camera);
_recorder.SetProfile(camProfile);
_recorder.SetOutputFile(outputFile);
_recorder.SetPreviewDisplay(_preview.Holder.Surface);
_recorder.Prepare();
_recorder.Start(); // HERE IS WHERE THE ERROR APPEARS
}
catch(Exception ex)
{
string error = "Error starting Recording: " + ex.Message;
Log.Debug("ERROR",error);
Toast.MakeText(Application, error, ToastLength.Long).Show();
}
}
The outputFile is hardcoded because i'm still testing.
I can confirm that exists because it gets created.
I just figured the problem.
It wasn't on how the camera was handled.
It was the Profile setting.
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.High);
Might be a Device bug, but I cant set it to high. To make it work, I changed it to LOW.
CamcorderProfile camProfile = CamcordeProfile.Get(CamcorderQuality.Low);
I have a Zenithink C93 Z283 (H6_2f)
I hope this helps anyone else fighting with this...
Now I have to see how to record on High quality. I know I can because the native camera app records in high....

What is the proper way to download setup packages in a WiX custom managed bootstrapper application?

I wrote a WiX custom MBA that I have been using which embeds all of the setup packages (msis, cabs and exes) I need for my installation. However I would now like to make a lightweight web bootstrapper which will download the packages that need to be installed. I thought you would get that for free with the underlying WiX bootstrapper engine, but I guess I was wrong.
I tried subscribing to the ResolveSource event to get a package's download url and download it to the local source location, but it seems like at that point it's too late in the process as my installation fails with an error "Failed to resolve source for file: " (even though the download is successful).
Sample of what I tried:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
string localSource = e.LocalSource;
string downloadSource = e.DownloadSource;
if (!File.Exists(localSource) && !string.IsNullOrEmpty(downloadSource))
{
try
{
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(e.DownloadSource, e.LocalSource);
}
}
catch (ArgumentNullException ex)
{
e.Result = Result.Error;
}
catch (WebException ex)
{
e.Result = Result.Error;
}
}
}
Thanks to Rob Mensching answering this on the wix-users mailing list:
Make sure your packages of URLs provided (authored is easiest but you can
programmatically set them all) then return IDDOWNLOAD from the
ResolveSource call.
I edited my code as follows:
private void OnResolveSource(object sender, ResolveSourceEventArgs e)
{
if (!File.Exists(e.LocalSource) && !string.IsNullOrEmpty(e.DownloadSource))
e.Result = Result.Download;
}
Setting the result to Result.Download instructs the bootstrapper engine to download the package. No need to try to download the file myself.

Can't open a mpg-File for capture using EmguCV with C#

I'm trying to open a mpg-File using emguCV. I use the following code:
if (instance == null)
{
lock (m_lock)
{
try
{
instance = new Capture(0); // capture from camera works fine if a camera is connected
}
catch (NullReferenceException)
{
String sFileName = #"C:\tmp\MarkerMovie.mpg";
try
{
if (File.Exists(sFileName))
{
instance = new Capture(sFileName); // here the exception is thrown
}
else
{
MessageBox.Show("No Camera and no Video-File found");
}
}
catch (NullReferenceException)
{
MessageBox.Show("Couldn't open Video: "+sFileName);
}
}
}
}
If a webcam is connected everything works fine, but when I unplug the webcam the line instance = new Capture(sFileName); throws a NullReferenceException:
Message = "Unable to create capture from C:\tmp\MarkerMovie.mpg"
I debugged and found the reason is in the constructor of capture. The following command always returns a Null-Pointer:
_ptr = CvInvoke.cvCreateFileCapture(fileName);
I could open the same video using C++ using this code:
cap = cvCaptureFromFile("C:\\tmp\\MarkerMovie.mpg");
I'm new to openCV, so I'm not sure which information you need to help me. I installed emguCV yesterday from http://sourceforge.net/projects/emgucv/ on a Windows XP computer. The installer-version is x86_2.3.0.1416. I included opencv_core231.dll, opencv_highgui231.dll and opencv_imgproc231.dll to my project.
Does somebody know how I can make this code working?
Let me know if you need more information.
Thanks.
I had the same problem and adding the opencv_ffmpeg.dll to the project seems to solve it. (Found in the bin directory in the Emgu CV directory) I have tried it on the project that you posted and it seems to be working too. Hope it helps.
With EmguCV in C#, you need to put the opencv_ffmpeg.dll, for example: opencv_ffmpeg2410.dll, be careful if you have x86 or 64 bits

Categories

Resources