2016-11-22 27 views
5

我正在使用相機拍攝電影。
我想使用滑塊縮放視頻像谷歌地圖的縮放。
我發現了另一個Question on SO,但是提出的解決方案適用於點擊,而我想爲滑塊開發解決方案。
我寫了代碼無法正常工作。 我還沒有找到錯誤,但視頻尺寸會非常大,然後我沒有看到視頻。
我嘗試設置digitalZoom的相機,但我有這個錯誤: 該相機不支持縮放。。我知道我的相機不支持「DigitalZoom」和「OpticalZoom」。我想找到一種方法來放大從相機拍攝的視頻。
My camera is dino ccd. 打擾我的朋友,我無法添加評論,我有這個錯誤:「你必須有50個評論的聲望」。連接滑塊以控制qml上的縮放攝像機

VideoOutput { 
    id: viewfinder 
    source: camera 
    anchors.fill: parent 
    focus : true         
    transform: [ 
     Scale { 
      id: zoomScale 
     }, 
     Translate { 
      id: zoomTranslate 
     } 
     ] 

     //Keys.onLeftPressed: viewfinder.seek(viewfinder.position - 5000) 
     //Keys.onRightPressed: viewfinder.seek(viewfinder.position + 5000) 

     MouseArea { 
      anchors.fill: parent 
      acceptedButtons: Qt.AllButtons 
      onClicked: { 
       var zoomIn = mouse.button === Qt.LeftButton; 
       zoomScale.origin.x = mouse.x; 
       zoomScale.origin.y = mouse.y; 
      } 
     } 

     Slider { 
      id:zoomVideo 
      orientation: Qt.Vertical 
      minimumValue: 0 
      maximumValue: 100 
      stepSize: 10 

      onValueChanged: { 
       zoomScale.xScale = zoomVideo.value 
       zoomScale.yScale = zoomVideo.value 
      } 
     } 
    } 
+0

那麼你的問題是什麼? – folibis

+0

「不能正常工作」是什麼意思?你會得到什麼樣的錯誤/意外行爲? – folibis

+0

你使用什麼設備?基本上所有的相機都支持數碼變焦,只有光學變焦功能的手機相機很少見 – Unknown

回答

0

您是否嘗試使用滑塊,就像一個普通的移動相機應用呢,如果是再考慮下面的未經測試的代碼片段,因爲目前我沒有機器來實現放大/縮小功能安裝了Qt IDE,但它應該可以幫助你理解這個概念。

Camera { 
     id: camera 
     digitalZoom:zoomSlider.value 
     //if opticalZoom is supported uncomment below line 
     //opticalZoom:zoomSlider.value 

     // rest of your settings 
    } 

VideoOutput { 
    id: viewfinder 
    source: camera 
    anchors.fill: parent 
    focus : true 

    } 

    Slider { 
      id:zoomSlider 
      orientation: Qt.Vertical 
      minimumValue: 0 
      maximumValue: camera.maximumDigitalZoom //or camera.maximumOpticalZoom 
      stepSize:camera.maximumDigitalZoom/10 // going through 10 steps 
      value:1.0        // initial zoom level 
      anchors{ 
      left:parent.left 
      leftMargin:5 
      verticalCenter:parent.verticalCenter 
      } 
     } 

而且我希望你看看這些類型的官方文檔。 SliderCamera。如果您在下面發表評論需要進一步澄清。