Canon camera gets stuck after sometime - 1200D EOS sdk java
<p>we are using canon eos sdk 2.14 to do live streaming and shoot.
camera is canon 1200D</p>

<p><strong>below are the camera setting :</strong></p>

<p>live streaming mode : enabled</p>

<p>AF mode : Flexi</p>

<p><strong>below is the code</strong></p>

<pre><code>import java.awt.image.BufferedImage;
import java.io.File;

import javax.swing.ImageIcon;
import javax.swing.SwingWorker;

import edsdk.api.CanonCamera;
import edsdk.api.commands.FocusModeCommand.Mode;

public class CameraWorker {
    static CanonCamera camera = null;
    public SwingWorker&lt;Void, Void&gt; liveViewWorker = null, shootWorker = null;

    public void startCameraLive() {
        try {
            camera = new CanonCamera();
            if (camera != null &amp;&amp; camera.openSession()) {
                if (camera.beginLiveView()) {
                    camera.setFocusMode(Mode.AUTO);
                    camera.setLiveViewMode(true);
                    liveViewWorker = new SwingWorker&lt;Void, Void&gt;() {
                        @Override
                        protected Void doInBackground() throws Exception {
                            try {
                                while (continueLoop) {
                                    try {
                                        Thread.sleep(100);
                                        camera.setLiveViewMode(true);
                                        final BufferedImage image = camera.downloadLiveView();

                                        if (image != null) {
                                                    ///set image to live view
                                        }else{
                                        System.out.println("NO LIVE VIEW&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
                                        }
                                    } catch (Exception e) {
                                        System.out.println("Exception Occured while getting Live View....");
                                        e.printStackTrace();
                                    }
                                }
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                            return null;
                        }

                        protected void done() {
                            try {
                                camera.endLiveView();
                                camera.closeSession();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    };
                    liveViewWorker.execute();
                }else{
                System.out.println("Live View not started.....");
                }
            }
        } catch(Exception e){
            e.printStackTrace();
        }
    }

      public void onFaceCapture() {
          shootWorker = new SwingWorker&lt;Void, Void&gt;() {
                BufferedImage croppedFaceImage;
                @Override
                protected Void doInBackground() throws Exception {
                    File[] camPictures = camera.shoot();

                    if (camPictures != null &amp;&amp; camPictures.length &gt; 0) {
                        for (File curFile : camPictures){
                            try {
                                byte[] imageBuffer = FileNDirUtils.getFileBytes(curFile.getAbsolutePath());

                            }catch(Exception e1){
                                System.out.println("ERRORR:::::::::&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+e1.getMessage());
                            }
                        }
                    }else{
                        System.out.println("camPictures Null");
                    }
                    return null;
                }
                protected void done() {
                    try {

                    ////////set final image to display


                    } catch(Exception e1){
                        System.out.println("ERRORR:::::::::&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+e1.getMessage() +" reason ::: "+e1.getCause());
                        e1.printStackTrace();
                    }
                    finally {
                        System.out.println("Done in finally........1");
                    }
                }
            };
            shootWorker.execute();
        }
}
</code></pre>

<p><strong>In the above code i have two methods</strong> </p>

<ol>
<li>startCameraLive()</li>
<li>onFaceCapture()</li>
</ol>

<p>first im starting the live view and displaying the downloaded image continuously and when the user clicks the capture button the second method will be executed. both the methods are invoked as below</p>

<pre><code>SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
        loop = true;
        cameraWorker = new CameraWorker();
        cameraWorker.startCameraLive();
    }
});
</code></pre>

<p>second method like this </p>

<pre><code>SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
             timerDisplay.setVisible(false);
             face_position_msg.setVisible(false);
             cameraWorker = new CameraWorker();
             cameraWorker.onFaceCapture();
         }
   });
</code></pre>

<p><strong>now the problem ::::</strong></p>

<p>after 5 or 6 iterations the camera gets stuck and nothing is functional. everything freezes and after closing the app and restarting the app it doesn't work. we need to unplug the camera or press the capture button on the camera manually to start working again. </p>

<p>the live streaming mode which is set to enable at the beginning becomes disable automatically. we need to set it again.</p>

<p>in startCameraLive() we are setting :::</p>

<p>camera.setFocusMode(Mode.AUTO);</p>

<p>camera.setLiveViewMode(true);</p>

<p>but still when the camera is stuck the live view mode becomes disabled. </p>

<p>how can we get rid of this stuck and we would like to know whats the root cause of this issue. there is no exception at all :( </p>

<p>Please help...</p>