Affdex Android SDK - บันทึกและใช้ CameraDetector

ส่วนใหญ่ฉันต้องการทราบว่ามีความขัดแย้งพื้นฐานที่ทำให้ฉันไม่สามารถแบ่งปันทรัพยากรเดียวกันกับห้องสมุดได้หรือไม่ หากเป็นเช่นนั้น ฉันจำเป็นต้องใช้แนวทางอื่น

เป้าหมายของฉันคือการมีวิดีโอคุณภาพต่ำโดยที่ข้อมูลเมตาของตัวตรวจจับบันทึกไว้ในเวลาเดียวกัน เพื่อที่ฉันจะสามารถดำเนินการภายหลังและตัดส่วนได้โดยไม่ล่าช้ามากนัก

อ้างอิงจาก CameraDetectorDemo - ตัวตรวจจับกล้อง

ฉันได้เริ่มต้น MediaRecorder แล้ว แต่จะบันทึกหน้าจอสีดำหากฉันสตาร์ทก่อนตัวตรวจจับ และมันจะหยุดทำงานเมื่อสตาร์ท (ด้วยรหัส -19) หากฉันสตาร์ทหลังจากตัวตรวจจับ เครื่องมือตรวจจับกำลังแนบตัวอย่าง ซึ่งอาจเกี่ยวข้องกับสิ่งนั้น

ฉันได้เพิ่มปุ่มบางปุ่มเพื่อควบคุมฟังก์ชันเหล่านี้:

protected void cameraInit() {
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state)) {
        Log.d(LOG_TAG, "Drive not mounted - cannot write video");
        return;
    }

    File file = new File(getExternalFilesDir(Environment.DIRECTORY_MOVIES), "demo.gp3");

    Log.d(LOG_TAG, String.format("Camera Initializing. Setting output to: %s", file.getAbsolutePath()));

    // Set sources
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

    // Set profile
    recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));

    // Set output profile
    recorder.setOutputFile(file.getAbsolutePath());

    // Set preview output
    recorder.setPreviewDisplay(cameraPreview.getHolder().getSurface());



    try {
        this.recorder.prepare();
    } catch (IOException e) {
        Log.e(LOG_TAG, "IO exception on camera Initialization");
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // This is thrown if the previous calls are not called with the
        // proper order
        Log.e(LOG_TAG, "Failed to initialize things properly :(  ");
        e.printStackTrace();
    }
}

protected void cameraStart() {
    Log.d(LOG_TAG, "Camera Start");
    this.recorder.start();
}

protected void cameraStop() {
    Log.d(LOG_TAG, "Camera Stop");
    this.recorder.stop();
}

person exrhizo    schedule 19.07.2016    source แหล่งที่มา


คำตอบ (1)


CameraDetector ของ Affdex SDK จำเป็นต้องเข้าถึงกล้องเพื่อรับเฟรมแสดงตัวอย่างและประมวลผล ดังนั้นจะไม่ทำงานหาก MediaRecorder สามารถควบคุมกล้องได้

ทางออกที่ดีที่สุดของคุณคือนำเฟรมตัวอย่างจากกล้อง ป้อนเฟรมเหล่านั้นไปยัง Affdex FrameDetector เพื่อประมวลผล และยังบันทึกเฟรมเหล่านั้นลงในไฟล์วิดีโอผ่าน MediaCodec และ MediaMuxer แม้ว่าฉันจะยังไม่ได้ลองก็ตาม

person Andy Dennie    schedule 19.07.2016
comment
อืม ฉันสงสัยว่าฉันสามารถตั้งค่าเครื่องบันทึกสื่อให้ใช้พื้นผิวเดียวกันกับ CameraDetector แล้วบันทึกจากนั้นได้หรือไม่ - person exrhizo; 20.07.2016
comment
ฉันไม่คิดอย่างนั้น อย่างที่ฉันจำได้ ฉันคิดว่าเมื่อ MediaRecorder เริ่มบันทึก กล้องจะเข้าควบคุมกล้อง ดังนั้น CameraDetector จะไม่ได้รับเฟรมแสดงตัวอย่างหลังจากจุดนั้น - person Andy Dennie; 20.07.2016