I'm using sfml 2.1 in xcode4. ballSpriteSheet.png is in the project folder. It loads using a full file path. Why won't the file load as written? If not possible as written, can you at least set a relative path?
if(!tBall.loadFromFile("ballSpriteSheet.png"))
std::cout << "ERROR: Could not load ball sprite sheet!" << std::endl;
In output...
Failed to load image "ballSpriteSheet.png". Reason : Unable to open file
ERROR: Could not load ball sprite sheet!
Thanks in advance!
The error reffer to the image that cannot be found. Please check the image to be in the project or to be next to your '.exe' and to be named correctly.
Related
I am trying to load PNG image, but it always ends in an error. I was first trying to use SDL's SDL_LoadBMP, but since that dind't work, I downloaded SDL2_image.h, did all the setup, but it still isn't working. The image is in the same directory as the cpp file. When I run my program, it runs, but prints error. Here is the function to load the image:
void loadImage()
{
image = IMG_Load("Untitled.png");
if (image == NULL)
std::cout << "error: " << SDL_GetError();
}
The error message from SDL_GetError is Failed loading libpng16-16.dll: The specified module could not be found. I tried passing the full path, but it gives an error and I don't know how to get around that problem since I am a beginner. Thanks.
Edit: After reading through the article linked in the answer to the tagged-duplicate question and making some changes(particularly installing the missing dll file and putting it in the same directory as the main cpp flie), I am getting this error message in a pop-up window: The procedure entry point inflateValidate could not be located in the dynamic link library, and the path to libpng16-16.dll is given after that.
I used SFML to create ARKANOID.
If I run in debug mode, it will run normally.
But when I run in Release mode, it can't read the image file.
In the Command window, the output is as follows:
Failed to load image " ??
"? ". Reason: Unable to open file
Failed to load image "es/ball.png ". Reason: Unable to open file
Failed to load image "es/ball.png
"? ". Reason: Unable to open file
Failed to load image "es/ball.png
"? ". Reason: Unable to open file
I've tried the absolute path and I've tried the relative path.
And i also tired loadFromFile("images/ball");
please help me
You need to put the PNG file in the directory where main.cpp is located. You can put it in both the debug directory and the release directory. Also note the file extension in the directory (.png or .jpg) and edit the code.
Try pasting the image where the execution folder or where the compiler is example in codeblocks if you have MinGW then paste it "C:\Program Files (x86)\CodeBlocks\MinGW\bin" and it will work
I have a problem with sfml... everything was working fine but now I can't load any image. Whenever I try, I have the error "Failed to load Image" with a bunch of junk characters...
How can I fix it?
Please check that you are linking correct versions of sfml libs.
If you are buildign in debug mode, make sure to link debug versions of lib files (*-d.lib).
I have a problem loading an openflight (*.flt) model into Openscenegraph using a simple test app:
#include <osgDB/ReadFile>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
// Setting the message level low so I can read Debug messages
osg::setNotifyLevel(osg::NotifySeverity::DEBUG_FP);
cout << "Opening flt file..." << endl;
osg::ref_ptr<osg::Node> mdl = osgDB::readNodeFile(argv[1]);
if (mdl != NULL) cout << "Opening flt file successful" << endl;
else cout << "Opening flt file failed" << endl;
return 0;
}
This should read the file pyramid.flt, which is in my executable directory by passing the file as argument to the application. However, OSG does not seem to be able to load the required Openflight plugin to indeed read the file. And thus the program returns NULL when trying to load it.
The strange thing is that the debug messages tell me that the required DLL is being used, see below:
Opening flt file...
itr='C:\dev\CgfGen\build32\3dviewer\Debug'
FindFileInPath() : trying C:\dev\CgfGen\build32\3dviewer\Debug\osgPlugins-3.4.1\osgdb_openflightd.dll ...
FindFileInPath() : USING C:\dev\CgfGen\build32\3dviewer\Debug\osgPlugins-3.4.1\osgdb_openflightd.dll
DynamicLibrary::failed loading "osgPlugins-3.4.1/osgdb_openflightd.dll"
Warning: Could not find plugin to read objects from file "pyramid.flt".
Opening flt file failed
I the pyramid.flt is in Openflight version 16.5.
I am running the debug version of my app.
OSG is loading the debug version of osgdb_openflightd.dll
Does anyone have any idea on what the problem is? and how it can be solved?
FindFileInPath() : USING C:\dev\CgfGen\build32\3dviewer\Debug\osgPlugins-3.4.1\osgdb_openflightd.dll
This just means that OSG has discovered a file matching the name of the one it's looking for, but doesn't mean that it is successfully USING it. The next line:
DynamicLibrary::failed loading "osgPlugins-3.4.1/osgdb_openflightd.dll"
Indicates that the plugin failed to load. This could be because of a problem with the plugin's own dependencies. Did you build OSG and the plugins yourself, from scratch?
You can probably use depends.exe to check and see what other DLLs your FLT plugin requires. You could also use something like SysInternals' Process Monitor to see what OSG was trying to load after
I've imported opencv and opencv_contrib frameworks in an Xcode project, and in my Objective-C++ file, I load a face classifier and then a Fisher face recognizer:
// set up classifier, recognizer, and webcam
-(void) setupAnalyzer:(NSString *)faceCascadeName :(NSString *)fisherDatasetName
{
// load face classifier
cout << "loading face classifier..." << endl;
String faceCascadeNameString = string([faceCascadeName UTF8String]);
faceCascade.load(faceCascadeNameString);
// load face recognizer
cout << "loading face recognizer..." << endl;
fishface = createFisherFaceRecognizer();
String fisherDatasetNameString = string([fisherDatasetName UTF8String]);
fishface->load(fisherDatasetNameString);
}
When I call this function from Swift, it seems the face classifier loads just fine with an xml file I have in my project. But when I try to load the Fisher face recognizer using another xml file in my project, Xcode shows this error:
OpenCV Error: Unspecified error (File can’t be opened for reading!) in load, file ~/opencv/modules/face/src/facerec.cpp, line 61
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: ~/opencv/modules/face/src/facerec.cpp:61: error: (-2) File can’t be opened for reading! in function load
I've tried rebuilding the OpenCV frameworks in different ways and I keep getting the same error!
First of all, I'm confused why the program is looking to source code that isn't contained in the project (it's looking for facerec.cpp in another directory on my computer). Also, why does the cascade classifier load just fine? This makes me think it's an issue with the way I built the opencv_contrib modules, because the face classifier comes from opencv_contrib. But I tried rebuilding opencv_contrib, and I still get this OpenCV error.
Any help would be greatly appreciated!
[UPDATE]
It is not an issue with building the contrib module. I manually included the module in Xcode, so it's now looking within the project for the facerec.cpp, but it still can't open the xml file for reading.
First of all, I'm confused why the program is looking to source code that isn't contained in the project (it's looking for facerec.cpp in another directory on my computer).
It doesn't search for file. It shows you where error was happen. Since your library was build on your machine and has debug information it can point you source file and line number where error happen.
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: ~/opencv/modules/face/src/facerec.cpp:61: error: (-2) File can’t be opened for reading! in function load
This message means that exception was generated at line 61 in file facerec.cpp. You need to check if your data is available for reading.
Figured it out! This answer helped me realize that I needed to get the app bundle's path to the xml files: OpenCV Cascade Classifier load error iOS