Question

I have a program that needs to repeatedly produce an image, write the image to disk, then read the image in again and process it. I am running into difficulties due to quirks of the library I am using, which forces me to read and write from different contexts as seen in this pseudocode:

while (true)
    captureAndPrintTo("src/images/xxxx.jpg"); //prints relative to project directory
    readImageAt("images/xxxx.jpg"); //reads relative to default package directory

This causes my program when run in Eclipse to print the image to src/ which succeeds then try and read it again from bin/ where it doesn't exist causing a crash. After the program exits, Eclipse mirrors the image from src/ to bin/, so that the next time I execute, the loop will run one more time than the last. I have currently resorted to printing the image to both src/ and bin/.

I am interested in any of: 1) a way to change Eclipse's behaviour so that images printed to src/ are mirrored to bin/ immediately 2) a better way to do this in idiomatic Java 3) a better way to do this with the specific library I am using

In particular, I am using Java's class.getResource("src/...") to input and OpenCV library's Highgui.imwrite(...) to output. Thanks!

Was it helpful?

Solution

bin is generated when you compile your application and it is impossible to update it after when the application is running. you have to save your images in another place (sd card or internal memory) then read it from there. you can of course put this resources as private to your application.

you should make a look at : The Storage Options

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top