Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frame that is got by using videoProcessFrame is blurred #399

Open
ynaka01-max opened this issue Sep 25, 2020 · 3 comments
Open

frame that is got by using videoProcessFrame is blurred #399

ynaka01-max opened this issue Sep 25, 2020 · 3 comments

Comments

@ynaka01-max
Copy link

I want to detect AR marker using image frame by using videoProcessFrame.
So, I want convert CVPixelBuffer to UIImage.
However, UIImage that converted from CVPixelBuffer was blurred (See images).
How should I convert it? Or is it possible to get a clear image?

drone: Mavic 2 Zoom
code

func videoProcessFrame(_ frame: UnsafeMutablePointer<VideoFrameYUV>!) {
        if (self.gloVar.landingMode == 1 && autoLandingStarted == true) {
            if (videoFrameCount % 10 == 0) { 
                var pixelBuffer:CVPixelBuffer;
                var image:UIImage;
                if frame.pointee.cv_pixelbuffer_fastupload != nil {
                    pixelBuffer = unsafeBitCast(frame.pointee.cv_pixelbuffer_fastupload, to: CVPixelBuffer.self)
                    image = imageFromPixelBuffer(imageBuffer: pixelBuffer)! <-- here
func imageFromPixelBuffer(imageBuffer:CVPixelBuffer) -> UIImage? {
        let sourceImage = CIImage.init(cvPixelBuffer: imageBuffer, options: nil)
        let size = sourceImage.extent.size
        UIGraphicsBeginImageContext(size)
        let rect = CGRect(origin: .zero, size: size)
        let remImage = UIImage(ciImage: sourceImage)
        remImage.draw(in: rect)
        let result : UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        return result
    }

image1
sample1

image2
s2

@dji-dev
Copy link
Contributor

dji-dev commented Sep 27, 2020

Agent comment from Luce Luo in Zendesk ticket #39553:

Dear Yuki,

Thank you for contacting DJI.
I have found some related issues for you, please try to refer to it if any help first.
#383
dji-sdk/DJIWidget#9

Thanks,

Luce Luo
DJI Developer Support

@ynaka01-max
Copy link
Author

ynaka01-max commented Sep 27, 2020 via email

@afullerriis
Copy link

@ynaka01-max

I'm not certain this will resolve you issue, but we were having a similar issue. It turned out that the DJI video frame was incorrectly reporting its frame size. Changing the camera aspect ratio to 16 by 9 instead of 4 by 3 corrected our issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants