unhandled exception whith cvCreatImage in visual studio 2010 - visual-studio-2010

I am using openCV2.3.1 on windows7 in visual studio 2010, and whenever i try to create an image with cvCreateImage() it gives an unhandled exception. But when I try my code on code blocks it runs without errors.
here is my code
imgToTreate = cvCreateImage (cvSize (250, 250), IPL_DEPTH_8U, 1);
cvResize(img, imgToTreate);
I don't understand why, I need your help...
thank you !

You need to check that:
img is loaded correctly in Visual Studio (you use relative paths, don't you?)
img has the same type and number of channels as imgToTreate.

Related

Xamarin + Visual Studio 2017 on Android: how debug Exception?

I have taken over a Xamarin.Forms (C#) application from an external source for fixing.
Problem is, that the application does sometimes fail with a runtime error:
System.NullReferenceException: Object reference not set to an instance of an object
The message appears in the output console and in a separate message window in Visual Studio. Unfortunately neither gives any more information about the failed object, a source code line number or a classname, there is just the bare message. Furthermore the "Call Stack" window in Visual Studio is always empty --> I have no easy way to find out where the failure occurs in foreign source code, because virtually no documentation of the program flow exists.
Full source code is available, and I have re-built the application with "Debug" configuration.
Right now the only option I can think of is to scatter breakpoints and Debug.Writelines all over the source code to get an idea where the problem occurs.
Is this really my only option, or did I miss some setting somewhere, so I can retrieve more info, so I can somehow go straight to the code where the failure occurs?
Thx!

Visual Studio 2010 Professional Find and Replace Not Working

My find and replace has stopped working.
Background:
I have a paid version Visual Studio 2010 installed. I also was running a trial version of Ultimate. However, the trial expired so I un-installed Ultimate. After the un-install of Ultimate, I can no longer do a global search in VS Professional.
Anyone have any ideas? Where should Microsoft.VisualStudio.Progression.GraphModel reside and why is it causing my search to fail? I tried running a repair on VS Professional without luck.
Error Message:
In the find results, I get the following:
Find all "test", Subfolders, Find Results 1, "Current Project"
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) Could not load file or assembly 'Microsoft.VisualStudio.Progression.GraphModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Resulting in: An exception occurred while trying to create an instance of type 'Microsoft.VisualStudio.Fragments.LanguageContext'.
Resulting in: Cannot activate part 'Microsoft.VisualStudio.Fragments.LanguageContext'.
Element: Microsoft.VisualStudio.Fragments.LanguageContext --> Microsoft.VisualStudio.Fragments.LanguageContext
Resulting in: Cannot get export 'Microsoft.VisualStudio.Fragments.LanguageContext (ContractName="Microsoft.VisualStudio.Fragments.ILanguageContext")' from part 'Microsoft.VisualStudio.Fragments.LanguageContext'.
Element: Microsoft.VisualStudio.Fragments.LanguageContext (ContractName="Microsoft.VisualStudio.Fragments.ILanguageContext") --> Microsoft.VisualStudio.Fragments.LanguageContext
Resulting in: Cannot set import 'Microsoft.VisualStudio.Fragments.EventsManager..ctor (Parameter="languageContext", ContractName="Microsoft.VisualStudio.Fragments.ILanguageContext")' on part 'Microsoft.VisualStudio.Fragments.EventsManager'.
Element: Microsoft.VisualStudio.Fragments.EventsManager..ctor (Parameter="languageContext", ContractName="Microsoft.VisualStudio.Fragments.ILanguageContext") --> Microsoft.VisualStudio.Fragments.EventsManager
Resulting in: Cannot get export 'Microsoft.VisualStudio.Fragments.EventsManager (ContractName="Microsoft.VisualStudio.Fragments.IEventsManager")' from part 'Microsoft.VisualStudio.Fragments.EventsManager'.
Element: Microsoft.VisualStudio.Fragments.EventsManager (ContractName="Microsoft.VisualStudio.Fragments.IEventsManager") --> Microsoft.VisualStudio.Fragments.EventsManager
Found out what was wrong. The reason I switched to Ultimate to begin with was to use this plugin called Code Bubbles (which required Ultimate). When I switched back to Professional after my trial expired, the plugin got into a strange state that was causing other parts of Visual Studio to fail. Once I fully uninstalled the plugin, search returned to normal.
Strange. Have you tried using ctrl + break? As suggested here:
Search stops working for "Entire Solution"
... you should click inside the Find Results window, not the Output window. Once the
blinking text cursor is visible, hit ctrl-break four or five times. That should do the
trick.
- DJ Couchy Couch

OpenCV 2.1: facedetect.cpp crashes when it finds ugly face

I am trying to compile the facedetect.cpp in the OpenCV\Samples\C folder, in Visual Studio 2010. The project compiles and begins just fine, shows a preview of my camera, and then seems to crash at cascade.detectMultiScale() as soon as it detects a face. I concluded that OpenCV thinks I am too ugly.
Unhandled exception at 0x100342bf in HeadTrackerExample.exe: 0xC0000005: Access violation writing location 0x00000000.
Unfortunately the debug info doesn't let me probe deeper. I am linking against cv210.lib;cxcore210.lib;highgui210.lib; the debug versions won't work:
LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002
I'm going to try to trick the classifier with a printout of Anne Hathaway but I am open to other suggestions.
https://code.ros.org/trac/opencv/browser/trunk/opencv/samples/c/facedetect.cpp
I guess I'm better looking than you because it's working here (under OS X). Are you sure you're successfully loading the xml files? Are you using the default xml files (haarcascade_frontalface_alt.xml and haarcascade_eye_tree_eyeglasses.xml)?
It sure looks like you have a null pointer. Try setting a breakpoint at the call to cascade.detectMultiScale() and examine the values of cascade, smallImg, smallImg.data, and faces.
Edit: populating the faces vector
Here's the detectMultiScale code:
void HaarClassifierCascade::detectMultiScale( const Mat& image,
Vector<Rect>& objects, double scaleFactor,
int minNeighbors, int flags,
Size minSize )
{
MemStorage storage(cvCreateMemStorage(0));
CvMat _image = image;
CvSeq* _objects = cvHaarDetectObjects( &_image, cascade, storage, scaleFactor,
minNeighbors, flags, minSize );
Seq<Rect>(_objects).copyTo(objects);
}
It's not touching the faces vector until the last line after all the detection is done. If you are adventurous, you could throw some printf statements in here to see if cvHaarDetectObjects is completing and if it is returning a null pointer.
I spent the day trying to fix this. Who knows why it was crashing? I couldn't link to the debug DLLs so we'll never know. I downloaded the OpenCV-2.1.0-win32-vs2008.exe distribution. And I am using Visual Studio 2010. Therefore, the exe was crashing with
LDR: LdrpWalkImportDescriptor() failed to probe D:\OpenCV2.1\bin\cv210d.dll for its manifest, ntstatus 0xc0150002
Debugger:: An unhandled non-continuable exception was thrown during process load
The program '[5172] HeadTrackerExample.exe: Native' has exited with code -1072365566 (0xc0150002).
This is the "0xc0150002 error". According to Dependency Walker, the OpenCV debug DLLs are trying to find msvcr90d.dll and msvct90d.dll, the Visual Studio 2008 debug runtime DLLs. Well, I obtained these and it still didn't work, so then this gets into esoteric Windows sidebyside and manifest stuff.
I switched to the OpenCV-2.3.1-win-superpack.exe distribution and it is now working.

Loading Visual Studio solution into programmatic instance

I have an F# program that creates an instance of Visual Studio:
let vsTy = Type.GetTypeFromProgID("VisualStudio.DTE.10.0") in
let dte2 = Activator.CreateInstance(vsTy,true) :?> EnvDTE80.DTE2 in
...
That works well; I can probe all kinds of info about the running instance
of Visual Studio.
But I can't determine how to load a solution into the instance of Visual Studio. I've tried dte2.ItemOperations.OpenFile(). I've also tried dte2.ExecuteCommand("File.OpenProject"), which works, but requires the user to select from a file dialog -- I want something that works from code alone.
Here's how to do it:
let soln2 = dte2.Solution :?> EnvDTE80.Solution2 in
let _ = soln2.Open(solutionFile) in
...
Bizarre, because dte2.Solution isn't a solution at all.

Configure the visual studio debugger for try-catch statements

VS 2005
For example,
My employees gave me a project with about X try-catch statements.
X > 100 .. 300
I need to test a project. Is there a way to mark each (every) beginning of catch as a breakpoint ? I don't want to do it manually. Maybe there is some settings that fit to me ?
Go to Debug > Exceptions (Visual Studio 2013 and earlier) or Debug > Windows > Exception Settings (Visual Studio 2015 and later).
In this dialog you can enable first chance debugging of exceptions - when an exception is thrown, the debugger will automatically break at the throwing code before the "catch" code is executed, allowing you to debug it.
What you want to do is ask it to break when CLR exceptions are thrown, not only when they're unhandled (image from Visual Studio 2013 - 2015 is similar but now is in a view rather than a dialog):
(Note: This won't get the debugger to break whenever you execute a try block, only if the exception is actually thrown)
Short answer is no. But you might be able to make some an aspect-oriented plugin to your project that captures the catch crosspoint, then you just have to put one breakpoint at in your aspect
I am not aware of a possibility that allows setting breakpoints in code by some pattern. The closest you can come to is Debug/New breakpoint/Break at Function where you can specify the file and line number. If you can get this automated and working down a list generated by a grep search, you might find a way. Here is something from the IDE samples that might get you started:
' Sets a pending breakpoint at the function named "main". It marks the
' breakpoint as one set by automation.
Sub AddBreakpointToMain()
Dim bp As EnvDTE.Breakpoint
Dim bps As EnvDTE.Breakpoints
bps = DTE.Debugger.Breakpoints.Add("main")
For Each bp In bps
bp.Tag = "SetByMacro"
Next
End Sub
However, why do you want to set those breakpoints anyway? If it's in order to catch exceptions as they are thrown, you can make the debugger break automatically whenever the happens under Tools/Exceptions.
You can use this if you are using older IDE's (anything pre-2012)
Programmatically apply / deactivate breakpoints in Visual Studio
Unfortunately they removed the macros from the newer IDE's.
There are extensions you can download and one of them allows you to modify a *.js file. Issue is going to be converting what the gentleman wrote in the other post to have it read properly.
For now I'm just using System.Diagnostics.Debugger.Launch(); it's just a pain and it would be awesome if someone could translate that file over.

Resources