tensorflowiOS icon indicating copy to clipboard operation
tensorflowiOS copied to clipboard

Video Orientation

Open john7002 opened this issue 6 years ago • 3 comments

Hi,

Nice work ! the code works fairly well on my device with my own graph. Just one question, I do not know if it is really an issue or a request, but currently it seems that the object recognition only works with landscape orientation on my device. I would like it to work in portrait upside down mode (or portrait). I checked the code, check that in TensorflowGraph.mm:

tensorflowGraph?.runModel(on: pixelBuffer, orientation: UIDevice.current.orientation)

orientation parameter is portrait. But then in Tensorflowgraph.mm, there is this part, where I can not find the way the buffer is read for portrait mode:

if (orientation == UIDeviceOrientationLandscapeRight)
            {
                // landscape right - we start at the end of the buffer and read backwards
                srcPixel  = srcStartAddress - (srcRow * bytesPerRow) - (srcCol * srcChannels);
            }
            else
            {
                // landscape left - we start at the beginning of the buffer and read forward
                srcPixel  = srcStartAddress + (srcRow * bytesPerRow) + (srcCol * srcChannels);
            }

How srcPixel should be set in portrait updsideDown orientation?

Thanks

john7002 avatar Apr 17 '18 12:04 john7002

Did you every resolve this? I have a branch somewhere where I implemented portrait orientation but never pushed. I'll incorporate it into master.

csharpseattle avatar May 17 '18 16:05 csharpseattle

Hi. No success, I've been trying to understand the way the buffer are read, but I can't figure out.

Would be great to have a look at your branch with the portrait orientation ! thanks in advance!

john7002 avatar May 17 '18 19:05 john7002

Hi John, I finally got around to fixing the issue with portrait orientations. The main issue was my width and height were flipped when feeding the image data into the Tensorflow graph in portrait orientations. Let me know if this fixes your issue.

csharpseattle avatar Jul 16 '18 04:07 csharpseattle