我有光反射的问题,这是用标准相机拍摄的照片

和我做的过程
1. blur the image
Imgproc.GaussianBlur(blurred, blurred, new Size(17, 17),
Imgproc.BORDER_ISOLATED);
2. create second empty image that using hsv
Imgproc.cvtColor(gray0, gray0, Imgproc.COLOR_BGR2HSV);
3. mix the image color chanel (fromto {0,0})
Core.mixChannels(blurredlist, graylist, fromto);
4. Threshold, Canny, and delate
Imgproc.threshold(gray0, gray0, 126, 255, Imgproc.THRESH_TRUNC);
Imgproc.Canny(gray0, gray0, 50, 70);
Imgproc.dilate(gray0, gray0, Mat.ones(new Size(3, 3), 0));
5. finding the contour
Imgproc.findContours(gray0, contours, new Mat(), Imgproc.RETR_EXTERNAL,
Imgproc.CHAIN_APPROX_SIMPLE);
6. magicall filter for biggest contour and stuff
Run Code Online (Sandbox Code Playgroud)
这是结果
如何从检测到的轮廓中移除背光或连接虚线?
我尝试使用glkview实现视频输入,但是当我尝试旋转旋转时总是从connectionWithMediaType返回nil.
这是我的设置
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
videoFeed = GLKView(frame: self.view.bounds, context: EAGLContext(API: .OpenGLES2))
videoFeed.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
videoFeed.translatesAutoresizingMaskIntoConstraints = true
videoFeed.contentScaleFactor = 1.0
self.view.addSubview(videoFeed)
renderContext = CIContext(EAGLContext: videoFeed.context)
sessionQueue = dispatch_queue_create("dCamSession", DISPATCH_QUEUE_SERIAL)
videoFeed.bindDrawable()
}
override public func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
startSession()
}
func createSession() -> AVCaptureSession {
let cam = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)
var input:AVCaptureInput
do {
input = try AVCaptureDeviceInput(device: cam)
} catch _ as NSError {
print("Cannot Init …Run Code Online (Sandbox Code Playgroud)