OpenCV cvHaarDetectObject error - c

I am making a project in Visual Studio 2010 using Qt4.8.0 and OpenCV2.3.1 library. Everything is fine as long as I don't use
cvHaarDetectObjects()
function. The program was compiled and built without problems, but when I try to run the application the error 0xc000007b appears. I've done similar program in win console and this function work properly. Why am I receiving this error message? I also try to use:
CascadeClassifier *haar;
haar->load("haarcascade_frontalface_alt.xml");
but it doesn't work even in console.
Example code
MainWindow.cpp:
MainWindow::MainWindow()
{
temp = cvCreateImage(cvSize(200, 200), 8, 1);
haarface = (CvHaarClassifierCascade*) cvLoad("haarcascade_frontalface_alt.xml");
storage = cvCreateMemStorage(0);
twarze = cvHaarDetectObjects(temp, haarface, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING, cvSize(100,100));
}
MainWindow.h:
class MainWindow
{
private:
CvMemStorage *pamiec;
CvHaarClassifierCascade * haarface;
IplImage *temp2;
CvSeq *twarze;
public:
MainWindow(void);
};
Maybe it something wrong with .xml files?

Are you sure the file haarcascade_frontalface_alt.xml exists in the current directory?
If it does not exist, then cvLoad will return NULL. Use full path for the xml file.
Also, what is error 0xc000007b? Could you post the full error description?

I simply changed slashes to backslashes and it works ;) cvLoad("\haarcascades\haarcascade_frontalface_alt.xml");
EDITED: ok, it doesn't crashes. Actually I am working with 2.4.8 edition o opencv. The problem with this code is cvHaarDetectObjects that seems to be not longer supported. It is recomended to use detectMultiScale instead.

Related

Sshj library for download multifiles in remote server

I use Java 8 and my condition is to download multiple file in a remote server using sftp protocol, is not necessary to filter file for his name but necessary to download all file in a specific remote folder.
i see the library com.hierynomus ยป sshj for this scope, but looking on the net i haven't found what i need, only for download a single file.
What i think is i could use this method,
String localDir = "/home";
String remoteFile = "/home/folder/*"
SSHClient sshClient = setupSshj();
SFTPClient sftpClient = sshClient.newSFTPClient();
sftpClient.get(remoteFile, localDir);
but i'm not sure if the asterisk in the "remoteFile" will be useful for my purpose...
Unfortunately for now i can't try this on remote server ...
Someone can help me?
Thank's everyone
You need to LIST all the files you want to download:
List<RemoteResourceInfo> entries = sftpClient.ls("/home/folder")
After that you will loop the entries to download them one by one:
for (RemoteResourceInfo remoteFile : entries) {
if(remoteFile.isRegularFile()){
sftpClient.get(remoteFile.getPath(), localDir);
}
}
E: Also you should check if the list entry is really a file, edited the code accordingly. Though I am not sure whether using !remoteFile.isDirectory() would be better.

How to Execute (Vector) Storage.getInstance().readObject(filePath); in Java 8 Swing Package

Windows 10 Pro
Latest Simulator
Java Swing Project
I would like to execute "Vector a1 = (Vector) Storage.getInstance().readObject(filePath);"
In a Java Swing Application running on Windows 10 platform, I tried import CodenameOne.jar in Swing package, however when executing above code, get null pointer exception in Storage.getInstance()
Is there a way to execute this in Swing?
Thoughts?
Best Regards.
Thanks, I did not init the Display, however "Display.init(Object m)" requires an Object Argument and the Init method is deprecated.
Can you please provide me the codenameone Display dependencies?
And perhaps a java Swing snippet of code to initialize Display in order to execute Storage.getInstance().readObject(filePath)
Thoughts?
Best Regards
Thanks, Passing init(working directory) solved the Exception thrown.
Here is the Code snippet used to allow me to execute:
Storage.getInstance().readObject(filePath).
String filePath = incSrv.Pwd();// gets working directory
try {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
Display.init(filePath);
String fileName = "A1-MMA.properties";
Vector a1 = (Vector) Storage.getInstance().readObject(filePath);
}
});
} catch (Exception e) {
}
And it does appear to work,
However I am left with a blacked out form that appears modal.
How can I avoid this or dispose it?.
FYI: What I am creating here is a work around for serializing Vector in Codenameone. I Save Vector to file using "Storage.getInstance().writeObject(Path, Vector)"
I convert the file to bytes and write it to the Swing Server VIA socket.
Using Storage.getInstance().readObject(file) on the Swing Server I have deserialize the object into the Vector from my app.
This appears to work well and is more efficient than the current method I use to deliver complex Vectors from the app to the Swing Server.
Can you please let me know if you see a red flag with this workaround?
Like The ability to Storage.getInstance().readObject(file) on the Swing Server may go away?
This method will save a lot of time in movind Vector data to and from the App/Server.
Thoughts Best Regards
Storage.getInstance().readObject(file) // (A1ServiceSrv.java:571)
Caused this Exception:
java.lang.NullPointerException
at com.codename1.io.Storage.init(Storage.java:89)
at com.codename1.io.Storage.getInstance(Storage.java:112)
at Main.A1ServiceSrv.loadVectorFromFile(A1ServiceSrv.java:571)
Regards
12/11/2021:
Thanks Shai,
I am including in my classpath CodenameOne.jar with update date of 12/11/2021 after CN1 refresh.
Getting Same null pointer exception.
Passing in Path "C:\Src1\A1-Arms\A1-Server\A1-MMA.properties" (Absolute Path)
Also Tried "A1-MMA.properties", however I don't think Codenameone knows where my home path is since we are not initializing it as we did with
Display.init("Current Working Directory where files reside");
This is the Fresh Stack Trace w/o calling Display.init (12-20-2021)
java.lang.NullPointerException at
com.codename1.ui.Display.getResourceAsStream(Display.java:3086)
at com.codename1.io.Log.print(Log.java:327)
at com.codename1.io.Log.logThrowable(Log.java:299)
at com.codename1.io.Log.e(Log.java:285)
at com.codename1.io.Storage.readObject(Storage.java:271)
at Main.A1ServiceSrv.loadVectorFromFile(A1ServiceSrv.java:596)
vector = (Vector) Storage.getInstance().readObject(filePath); // (A1ServiceSrv.java:596)
This is hopefully fixed by this commit: https://github.com/codenameone/CodenameOne/commit/72bf283bdaaefe5207bb9fd6787578e3ef61522c if not let me know with a fresh stack

C# UWP accress to file, created by app, is denied

I am creating a C# UWP App, which creates files with broadFileSystemAccess capability.
Creating and writing to the file is no problem, but reading it fails with error message "Access to the path is denied even when I use storageFile.Path after writing it (so path is guaranteed to be correct and I can open the file in a text editor without problem).
Can anyone tell me, what I may can do to fix the problem?
Kind regards,
Wolfgang
Now I use following code to create a StorageFile, which can be read by my UWP app:
public static async Task<StorageFile> CreateStorageFileFromPath(string filepath)
{
string path = Path.GetDirectoryName(filepath);
string filename = Path.GetFileName(filepath);
var folder = await StorageFolder.GetFolderFromPathAsync(path);
return await folder.GetFileAsync(filename);
}
Kind regards,
Wolfgang

EF6 (6.1.3/ net45) Logging feature does not seem to work

When I attempt to run the line:
MyDBContext.Database.Log = Console.Write
The compiler smiles and tells me I don't know what I am doing...
The app won't compile because of the line and the error on that line is:
Overload resolution failed because no accessible Write accepts this number of arguments.
That makes sense. 'Console.Write' returns nothing and I am setting it equal to a System.Action(Of String)
This just seems kind of half baked.
I tried numerous ways to fix it including delegates, and some of the other 'new possibilities' moving this off the Context is supposed to offer but still no dice.
What am I missing? Is it something that was changed at the last minute?
I have two large edmx files (one connects to SQL Server and the other to Oracle) in the solution and all of that is working great.
Here are my version numbers if that can help.
EntityFramework 6.0.0.0 (folder is ...\EntityFramework.6.1.3\lib\net45\EntityFramework.dll)
EntityFramework.SqlServer 6.0.0.0 (folder is ...\EntityFramework.6.1.3\lib\net45\EntityFramework.dll)
Oracle.ManagedDataAccess.EntityFramework 6.121.2.0
I have a tool I created that lets me paste the output of the L2S 'mycontext.log' into it and it then parses it and creates SSMS ready SQL with variables... it has been incredibly useful. This has been one of my favorite features of L2S.
Please help me understand why this isn't working.
Thanks in advance.
This technique works for me:
public override int SaveChanges()
{
SetIStateInfo();
#if DEBUG
Database.Log = s => Debug.WriteLine(s);
#endif
return base.SaveChanges();
}
http://blogs.msdn.com/b/mpeder/archive/2014/06/16/how-to-see-the-actual-sql-query-generated-by-entity-framework.aspx
Well, the answer was to research the Action(T) Delegate which showed me how to do it.
#If DEBUG Then
myctx.Database.Log = AddressOf Console.Write
#End If
Just needed the AddressOf and I was back in business.

How to resolve Fortify scan reports cannot dereference null pointer exception in Silverlight.js file?

I am getting the following error when trying to run fortify scan on my silverlight project.
The method createObject() in Silverlight.js can dereference a null pointer on line 2,
thereby raising a NullExcpetion.
This silverlight.js file is created by Microsoft. Does anybody have pointers on how this can be resolved?
Given that the file has come from Microsoft I would assume that the error is theoretical rather than actual. Checking the debug version of the file for CreateObject I find the following code:
Silverlight.createObject = function(source, parentElement, id, properties, events, initParams, userContext)
{
var slPluginHelper = new Object();
var slProperties = properties;
var slEvents = events;
slPluginHelper.version = slProperties.version;
slProperties.source = source;
slPluginHelper.alt = slProperties.alt;
...
I can only assume that fortify is objecting to the following line:
slPluginHelper.version = slProperties.version;
as slProperties could be null if the properties argument is null.
If you really must have these errors fixed then you need to report the issue to Microsoft and hope that they release an updated version of the file. In the meantime you could modify the code (edit the .debug version of the file) and use that. However, you will have to reapply your edits if you download a new version of the file at any point in the future.

Resources