Multiple Images per second

Home Forums Android development Multiple Images per second

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Amit Amit 1 year, 2 months ago.

Viewing 1 post (of 1 total)

  • Author

    Posts

  • #7597

    Profile photo of Amit
    Amit

    Participant

    Hi guys,
    I am trying to capture multiple thermal images per second using flir gen 2 Android version and modified version of provided example application. Relevant code is as below.

    
    ** frameProcessor initialization ***
    frameProcessor = new FrameProcessor(this, this, EnumSet.of(RenderedImage.ImageType.ThermalRadiometricKelvinImage), true);
    **some other initialization code ***
    
    public void onFrameProcessed(final RenderedImage renderedImage) {
            if (imageCaptureRequested) {
                imageCaptureRequested = false;
                final String localFileName = new SimpleDateFormat("d-M-Y_HH_mm_ss_SSS").format(new Date()).toString();
    
                if (renderedImage.imageType() == RenderedImage.ImageType.ThermalRadiometricKelvinImage) {
                    new Thread(new Runnable() {
                        public void run() {
                            String path1 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + "/" + localFileName + "_pixel_values.csv";
                            try {
                                FileWriter fileWriter1 = new FileWriter(path1);
                                int[] thermalValues = renderedImage.thermalPixelValues();
                                for (int i = 0; i < thermalValues.length; i++) {
                                    fileWriter1.write(Integer.toString(thermalValues[i]) + "\n");
                                }
                                fileWriter1.close();
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                            Log.e("Writing", "going to write image file");
    			String path3 = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + "/" + localFileName + ".jpg";
                            try {
                                renderedImage.getFrame().save(new File(path3), frameProcessor);
                            } catch (IOException e) {
                                e.printStackTrace();
                            } 
                            Log.e("Writing", "visible written");
                        }
                    }).start();
                }
    

    There is another piece of code, running on separate thread, which is just flipping the boolean variable imageCaptureRequested in a loop as follows:

    
    while(some_condition_thats_true_for_few_seconds){
    imageCaptureRequested = true;
    Thread.sleep(200)
    }
    

    Now, the issues I am having here are:
    1. Thermal data is written quickly (in csv files) but image files take few seconds to write (nothing happens for few seconds after thermal data is written then suddenly all of the image files will start appearing). Why is this delay of few seconds in between?
    2. Let’s say I am capturing a gesture spanning across multiple images and each of my image file name is derived from current system date time. Then, ideally earlier parts of the gestures should be saved with earlier date than the later parts of the gestures. This is not happening. The order is kind of mixed up. Sometimes, even the frames that were received after the while loop (above method which flips imagecaptureRequested) condition has become false. What could be going on here?

    Please suggest what am I doing wrong here.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.