My concern is that to what location should i copy the .jpg file so that it could be loaded from application and
displayed on screen.
Is PxLoadImage() load file from its default path and how can we modify that path.
Lets say:-
If i am using ETFS file system and my application image is at “fs/etfs”.
and this application is suppose to load the .jpg file and display on screen but my concern is that where i should place
the .jpg file so that it can be loaded.
Do I have to place the .jpg file at same location “fs/etfs” or somewhere else.
This seems to be a very silly doubt but Please help me…!!!
The application will use the current directoy as the base. The current directory is NOT where the binary is but rather were it was started from. This can be changed with chdir() what I like to do in my program is get the binary location with _cmdname() and then make every thing relative to that path.
Still I am confused…!!
What if I don’t change the directory of my binary file <say , let it be fs/etfs>
than where I put my .jpg image so that it can be load and displayed.
It doesn’t matter where the program is, it’s where you start it from that matters. If you binary and jpg are in /fs/etfs/ and before starting it you do cd /fs/etfs/ then if you progralm does a PxLoadImage and specify the jpg file without any path, then it will work.
If you do cd /fs and start the program by dont etfs/program then PxLoadImage won’t be able to load the image because it will try to find it in /fs.
First you should always check return values, for exemple did the chdir() worked?
I also suggest you re-read the documenation as you seems to have misunderstood how thing works. _cmdname show the path of the executable, chdir() has no effect on that.
Maybe if you print the value of errno when PxLoadImage fail it would give you some extra clue has to what is going on.
What if you try to do and open() on the file, does that work. Maybe it’s something else that having access to the file that makes PxLoadImage. What if you try to provide full path to PxLoadImage( “/fs/etfs/image6.bmp” …) does that work ?
Sorry Mario, but
chdir( “cd /fs/etfs” ) does not make sense, as the argument has to be a path.
system(“cd /fs/etfs”) will change to the specified directory. This works always!
Just make sure your process has the permission to operate with /fs/etfs.
Could you please list /fs directory: “ls -l /fs”, and also list you executable “ls -l your_program”
I never said anything about chdir(“cd /fs/etfs”), the OP is the one that came up with that I would not expect system(“cd …” ) to work. Even if it does work it’s a bad idea, it’s hard to handle error, it’s slower, it’s less real-time etc.
I would not expect it to work ( although I haven’t tried it myself ) because when you call system you invoke a shell, which in turn runs the cd command, and thus changes the current directory of that shell. I don’t beleive a child can affect the parent’s current directory. Otherwise imagine this, a process start, which spawn another proces, which spawn another one. Now the 3 programs are happily running and then the third process does chdir() or system (“cd …” ). If that change would propagate up to the 3 processes, chaos would ensue
I won’t get any clue regarding the error
and also by giving full path “/fs/etfs/image6.bmp” to the PxLoadImage( “/fs/etfs/image6.bmp” …)
it also won’t work.
What do you mean by "I wont get any clue regarding the error", If you give full path and it doesn't work then it becomes obvious its not a path issue.
Have you tried loading the file with open as was suggested to you. If you print the value of errno after PxLoadImage fails what is its value. If you use pv ( Photon Viewer) to load the file does it work ( pv used PxLoadImage() ). PxLoadImage needs some special .so files to work maybe you haven`t install them properly if your target is a custom made image.
As always you have right Mario. You are the Master.
PxLoadImage uses pi_io_jpeg.so for jpeg files.
Try to load BMP file( instead of JPEG ). It uses pi_io_bmp.so.