BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.87k stars 608 forks source link

Camera frame #134

Open ALexanderLonsky opened 7 years ago

ALexanderLonsky commented 7 years ago

My RenderView size is 900x1153 and camera output does not fill the view, it looks like AspectFit mode. How to change this? I tried Crop filter, cropSizeInPixels works fine, if I crop width, the output fills my view, but I can't understand how to translate point into pixel: my screen width is 387 pixels but to fit the RenderView I need to set cropSizeInPixels width to 560.

self.camera = try Camera(sessionPreset:AVCaptureSessionPresetHigh) self.cropFilter = Crop()
let screen = NSScreen.main()! let description = screen.deviceDescription
let displayPhysicalSize = CGDisplayScreenSize(CGDirectDisplayID((description["NSScreenNumber"] as! NSNumber).intValue)) let w = self.cameraView.frame let width = 560 // how to get this based on self.cameraView.frame.size? let height = 700.0// how to get this based on self.cameraView.frame.size? self.cropFilter.cropSizeInPixels = Size(width: Float(width), height: Float(height))
self.camera --> self.cropFilter --> self.cameraView self.camera.startCapture()

Thanks in advance for any explanation.

omarojo commented 7 years ago

check the RenderView.fillMode options. it has stretch, preserveAspectRatio, preserveAspectRatioAndFill

by default is . preserveAspectRatio