{"action":"created","issue":{"url":"https://api.github.com/repos/headupinclouds/gatherer/issues/104","labels_url":"https://api.github.com/repos/headupinclouds/gatherer/issues/104/labels{/name}","comments_url":"https://api.github.com/repos/headupinclouds/gatherer/issues/104/comments","events_url":"https://api.github.com/repos/headupinclouds/gatherer/issues/104/events","html_url":"https://github.com/headupinclouds/gatherer/issues/104","id":123990563,"number":104,"title":"qmlvideofilter: texture orientation and display size","user":{"login":"headupinclouds","id":554720,"avatar_url":"https://avatars.githubusercontent.com/u/554720?v=3","gravatar_id":"","url":"https://api.github.com/users/headupinclouds","html_url":"https://github.com/headupinclouds","followers_url":"https://api.github.com/users/headupinclouds/followers","following_url":"https://api.github.com/users/headupinclouds/following{/other_user}","gists_url":"https://api.github.com/users/headupinclouds/gists{/gist_id}","starred_url":"https://api.github.com/users/headupinclouds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headupinclouds/subscriptions","organizations_url":"https://api.github.com/users/headupinclouds/orgs","repos_url":"https://api.github.com/users/headupinclouds/repos","events_url":"https://api.github.com/users/headupinclouds/events{/privacy}","received_events_url":"https://api.github.com/users/headupinclouds/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/headupinclouds/gatherer/milestones/2","html_url":"https://github.com/headupinclouds/gatherer/milestones/0.2","labels_url":"https://api.github.com/repos/headupinclouds/gatherer/milestones/2/labels","id":1335210,"number":2,"title":"0.2","description":"Improve ogles Android sample (camera thread, ...)","creator":{"login":"ruslo","id":4346993,"avatar_url":"https://avatars.githubusercontent.com/u/4346993?v=3","gravatar_id":"","url":"https://api.github.com/users/ruslo","html_url":"https://github.com/ruslo","followers_url":"https://api.github.com/users/ruslo/followers","following_url":"https://api.github.com/users/ruslo/following{/other_user}","gists_url":"https://api.github.com/users/ruslo/gists{/gist_id}","starred_url":"https://api.github.com/users/ruslo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ruslo/subscriptions","organizations_url":"https://api.github.com/users/ruslo/orgs","repos_url":"https://api.github.com/users/ruslo/repos","events_url":"https://api.github.com/users/ruslo/events{/privacy}","received_events_url":"https://api.github.com/users/ruslo/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":3,"state":"open","created_at":"2015-10-02T16:43:14Z","updated_at":"2016-01-06T15:44:00Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-12-27T18:05:39Z","updated_at":"2016-01-06T15:47:11Z","closed_at":"2016-01-06T15:44:00Z","body":"QML has various methods for scaling and orienting video output which all works for the default video configuration.  If we change the video texture orientation in our shader pipeline for processing we need to find appropriate properties in QT to get an upright aspect ratio preserving stretch for the display.\r\n\r\nThis configuration provides upright video if the VideoOutput texture is unaltered:\r\n```\r\n  VideoOutput {\r\n    id: output\r\n    source: camera\r\n    filters: [ infofilter, videofilter ]\r\n    anchors.fill: parent\r\n    fillMode: Image.PreserveAspectFit\r\n    width: parent.width\r\n    autoOrientation: true\r\n  }\r\n```\r\nAnd the C++ looks like this:\r\n```\r\n    QQuickView view;\r\n    view.setSource(QUrl(\"qrc:///main.qml\"));\r\n    view.setResizeMode( QQuickView::SizeRootObjectToView );\r\n```\r\nBut if we change the orientation of the video textures from C++ (outside of QT) using this:\r\n```\r\ntransformProc.setOutputRenderOrientation(ogles_gpgpu::RenderOrientationDiagonalMirrored);\r\n```\r\nwe need the QML or C++ code to adapt appropriately.\r\n\r\nHere is the default qmlvideofilter display with the above settings (fan == circular):\r\n![img_8779](https://cloud.githubusercontent.com/assets/554720/12011683/84dac77a-ac9d-11e5-8268-fa5bf79eaf56.PNG)\r\n\r\nIn iOS if we create and rotate a texture in our ogles_gpgpu shader pipeline with this `ogles_gpgpu::RenderOrientationDiagonalMirrored` then we get this (fan != circular):\r\n\r\n![img_8780](https://cloud.githubusercontent.com/assets/554720/12011684/94386920-ac9d-11e5-8f66-78b454ae6b05.PNG)\r\n\r\nThe FBO is configured for the rotated/upright portrait mode aspect ratio:\r\n```\r\nogles_gpgpu::TransformProc - render - input tex 1, target 3553, framebuffer of size 960x1280\r\nogles_gpgpu::GrayscaleProc - render - input tex 7, target 3553, framebuffer of size 960x1280\r\n```\r\nAnd the output texture is configured with the appropriately transposed size here:\r\n\r\nVideoFilterRunnable.cpp:141\r\n```\r\n return TextureBuffer::createVideoFrame(m_outTexture, m_size.transposed() /*m_size*/);\r\n```\r\n\r\nBut it looks as if the texture itself is still being treated with the native iOS camera landscape orientation of the original `VideoOutput`.\r\n\r\nThis could be fixable (glViewport(), etc) if we were drawing to the screen in OpenGL, but the rendering is currently handled by QT.  Perhaps that is a way to overload a method and draw to the display directly.  That could be an option, but seems to go against the grain of the QML approach.\r\n\r\nChanging the TextureBuffer output size from `m_size` to `m_size.transposed()` does not fix the stretching aspect ratio problem above, so I'm assuming the `VideoOutput` size is configured in the QQuickView object at startup."},"comment":{"url":"https://api.github.com/repos/headupinclouds/gatherer/issues/comments/169363640","html_url":"https://github.com/headupinclouds/gatherer/issues/104#issuecomment-169363640","issue_url":"https://api.github.com/repos/headupinclouds/gatherer/issues/104","id":169363640,"user":{"login":"headupinclouds","id":554720,"avatar_url":"https://avatars.githubusercontent.com/u/554720?v=3","gravatar_id":"","url":"https://api.github.com/users/headupinclouds","html_url":"https://github.com/headupinclouds","followers_url":"https://api.github.com/users/headupinclouds/followers","following_url":"https://api.github.com/users/headupinclouds/following{/other_user}","gists_url":"https://api.github.com/users/headupinclouds/gists{/gist_id}","starred_url":"https://api.github.com/users/headupinclouds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headupinclouds/subscriptions","organizations_url":"https://api.github.com/users/headupinclouds/orgs","repos_url":"https://api.github.com/users/headupinclouds/repos","events_url":"https://api.github.com/users/headupinclouds/events{/privacy}","received_events_url":"https://api.github.com/users/headupinclouds/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T15:47:11Z","updated_at":"2016-01-06T15:47:11Z","body":"Fixed using the `scale` property (adaptively from C++) as shown here:\r\n\r\n```\r\n    assert(qmlCamera != nullptr);\r\n    \r\n    QCamera* camera = qvariant_cast<QCamera*>(qmlCamera->property(\"mediaObject\"));\r\n    assert(camera != nullptr);\r\n    \r\n    QObject * qmlVideoOutput = root->findChild<QObject*>(\"VideoOutput\");\r\n    assert(qmlVideoOutput);\r\n\r\n    const QCameraInfo cameraInfo(*camera);\r\n    const bool hasTranspose = (cameraInfo.orientation() / 90) % 2;\r\n    const auto &resolution = camera->viewfinderSettings().resolution();\r\n    double scale = hasTranspose ? double(resolution.width())/resolution.height() : 1.0;\r\n    qmlVideoOutput->setProperty(\"scale\", scale);\r\n    qmlVideoOutput->setProperty(\"rotation\", cameraInfo.orientation());\r\n```\r\nOutput:\r\n![img_8785](https://cloud.githubusercontent.com/assets/554720/12146632/ae123840-b462-11e5-8f28-442cf6f57f4f.PNG)"}}