佳能相机在一段时间后卡住-1200D EOS sdk java

佳能相机在一段时间后卡住-1200D EOS sdk java,java,live-streaming,canon-sdk,Java,Live Streaming,Canon Sdk,我们正在使用佳能eos sdk 2.14进行直播和拍摄。 相机是佳能1200D 以下是摄像头设置: 直播模式:已启用 AF模式:Flexi 下面是代码 import java.awt.image.BufferedImage; import java.io.File; import javax.swing.ImageIcon; import javax.swing.SwingWorker; import edsdk.api.CanonCamera; import edsdk.api.comma

我们正在使用佳能eos sdk 2.14进行直播和拍摄。 相机是佳能1200D

以下是摄像头设置:

直播模式:已启用

AF模式:Flexi

下面是代码

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<Void, Void> liveViewWorker = null, shootWorker = null;

    public void startCameraLive() {
        try {
            camera = new CanonCamera();
            if (camera != null && camera.openSession()) {
                if (camera.beginLiveView()) {
                    camera.setFocusMode(Mode.AUTO);
                    camera.setLiveViewMode(true);
                    liveViewWorker = new SwingWorker<Void, Void>() {
                        @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>>>>>>>>>>>>>>>>>>>>>>");
                                        }
                                    } 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<Void, Void>() {
                BufferedImage croppedFaceImage;
                @Override
                protected Void doInBackground() throws Exception {
                    File[] camPictures = camera.shoot();

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

                            }catch(Exception e1){
                                System.out.println("ERRORR:::::::::>>>>>>>>"+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:::::::::>>>>>>>>"+e1.getMessage() +" reason ::: "+e1.getCause());
                        e1.printStackTrace();
                    }
                    finally {
                        System.out.println("Done in finally........1");
                    }
                }
            };
            shootWorker.execute();
        }
}
像这样的第二种方法

SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
             timerDisplay.setVisible(false);
             face_position_msg.setVisible(false);
             cameraWorker = new CameraWorker();
             cameraWorker.onFaceCapture();
         }
   });
现在问题来了:

经过5或6次迭代后,相机卡住,没有任何功能。一切都冻结,在关闭应用程序并重新启动应用程序后,它将无法工作。我们需要拔下相机的插头或手动按下相机上的“捕获”按钮才能重新开始工作

开始时设置为启用的直播模式将自动变为禁用。我们需要重新设置

在startCameraLive()中,我们设置:

照相机。设置焦点模式(模式。自动)

camera.setLiveViewMode(真)

但是,当相机被卡住时,实时查看模式将被禁用

我们如何才能摆脱这个困境,我们想知道这个问题的根本原因是什么。毫无例外:(


请帮助…

您是否尝试查看Swingworkers方法是否适用于:

System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());
或者可能会在类中添加“扩展SwingWorker”

System.out.println(javax.swing.SwingUtilities.isEventDispatchThread());