No announcement yet.

Camera Zoom

  • Filter
  • Time
  • Show
Clear All
new posts

  • Camera Zoom

    This is for discussion of the Camera Zoom code I posted in the Source Code forum.

  • #2
    A problem with using the SetWindowPosition solution is that it implements a digital zoom, which causes pixelation when zooming in.

    If you have a camera with optical zoom, then using the built-in zoom should give much better results.

    However, I'm not sure if the IAMCameraControl interface can be used to control a camera's optical zoom. I'd think so but I've not demonstrated it on a camera to know for sure. I hope to try it out later today and will post something on how the test goes.


    • #3
      Two options ought to work for zooming in on a specific point of an image.

      1. Resize the xy position of the resized video window so that the selected point is centered in the graphic control.

      2. Use a virtual Graphic control so the user can pan over any part of the zoomed image.

      Code examples are in order!


      • #4
        Shoot your video at a higher resolution and you can zoom up to the resolution with no quality loss.
        hutch at movsd dot com
        The MASM Forum


        • #5
          Howdy, Steve!

          Yes, if it comes in at 1920x1080 but is displayed by default at a lower resolution, then "zooming" in won't look worse.

          Some of the webcams I work with won't deliver more than 640x480, so the approach won't work there.

          To complicate it even more, I also have some screens I deal with whose resolutions are 2560x1440.


          • #6
            The low res stuff does not leave you with many options, colour adjustments and gamma corrections and some very careful sharpening will probably make it look a bit better depending on the source quality. 1440 at a normal 16/9 ratio can be very good quality as long as the bitrate is not too low. I have seen the approach with low res footage where you enlarge it to the display size you want then super impose the normal sized one in the middle of the screen, something like how portrait mode footage from a mobile phone is usually displayed in landscape mode.
            hutch at movsd dot com
            The MASM Forum



            • #7
              Hey Steve!

              Question. How does the bitrate affect the quality of the image?

              The enlarge/super impose idea is interesting. Does the lower quality perimeter content make the inner image appear to be a higher quality? A trick the brain plays on the user?


              • #8
                Bitrate generally effects the amount of movement in the video. Slow moving scenes have very little change so they can look OK at a much lower bitrate than a fast moving scene where each frame has to be completely rewritten each frame which requires a far large amount of data to change. When the bitrate is lower than the data, you get pixelation and some blurring.

                What I have found if I had some 720 that was just barely watchable, if you blew it up to 1080 it looked really bad so I put something in the background and super imposed the 720 in the middle of the screen. Its based on how eyesight works, the centre of a field of view has the best focus where the edges get progressively out of focus so if the centre looks OK, the background video below it simply fills out the screen.

                I gather you are processing video data from web cams and I don't know how easy it is to process the data in terms of colour modifications (gamma, sharpening etc ...) but if you can control the contrast and do some sharpening on low res video, it may look OK. Now the next problems is that you cannot process high res video the same way, 1440 would look terrible if you processed it the same as low res video so you may need to detect the resolution before you display it and have a number of options available.
                hutch at movsd dot com
                The MASM Forum



                • #9
                  Hi Gary.
                  You been into video for awhile now.
                  I have had my hands full but had a thought you might be using or could use.
                  Would it help just to offload the input video as your program received it In a thread to storage and let the thread shuffle some frames for your visual monitoring part. That way you may be able deal higher rates and more resolution for raw input and output storage when you get that capability in camera equipment.
                  p purvis


                  • #10
                    Disclaimer: I have not tried your example.
                    2 cents. I'm thinking you'll want to capture 1 frame a second and then work your way up the ladder from there.
                    3 cents. Zooming would likely be very efficient and quick if you crop the data with region boundaries and inflate the region to match the display control size.

                    Do I have an example of that? Sorry no.

                    I could probably do that with a modified version of Pixel Pipe Demo. The trick would be the inflation algorithm. Likely my method would take much more code. Ha Ha

                    Just tried it. Nice job.
                    Last edited by Jim Fritts; 29 Oct 2019, 11:45 PM.


                    • #11
                      Hi Gary,
                      Can you tell me where you get the file.

                      I am trying to compile your program and I am getting an undefined TYPE error for IGraphBuilder.
                      I don't see a file in the my Win32api folder, but I tried compiling with the Jose Roca version without success.

                      Thanks ahead of time for any info anyone can provide.


                      • #12
                        Howdy David!

                        It's part of Jose's include files, which I use on all my apps.


                        • #13
                          Thanks. I had Jose's older include files. Once updated, the software runs well.

                          I have always used VideoCapX for DirectShow video -- which I highly recommend. But there are some situations where it is more useful to work directly with the DirectShow calls. Thanks for the sample PB code -- this is a great resource.


                          • #14
                            Howdy, David!

                            I own a copy of VideoCapX but haven't tried it out in some time.

                            I'd be interested in seeing a few short code examples of using VideoCapX, if you have some you could share.

                            No hurry - I'm swamped with some gbThreads issues that may take a while to resolve. But I am definitely interested.

                            I've not even opened the VideoCapX file to see if they've included any PowerBASIC examples. That shows how much priority I've given to it!


                            • #15
                              Hi Gary,

                              I posted a sample program using the VideoCapX OCX here:

                              It demonstrates basic camera control (brightness, contrast, gamma) and event handling (mouse down and mouse up). A good starting point.


                              • #16
                                Howdy, David!

                                Thank you so much for the code. I probably can't give it a try until this weekend, but I am definitely interested!


                                • #17
                                  Howdy, David!

                                  Well, I didn't get to it quickly but I am looking at your posted file. I'm having trouble with this line ...

                                  LicKey_VideoCapX = UCode$(" *** COPY THE LICENSE FILE HERE *** ")
                                  My license file just contains a bunch of text - a license agreement - nothing I would consider a license ID or password. Does your "videocapx.lic" file have something else in it?


                                  • #18
                                    Re Paul's suggestion in Post #9 this thread..

                                    Would it help just to offload the input video as your program received it In a thread to storage
                                    OR.. you can load the video to a QUEUE. A pipe might be simples.. one end acepts the video, the other end removes and processes it.

                                    Search Source code section keyword 'queue' in title and you will find numerous (several? multiple?) demos just from me.

                                    Not saying that will be right for your app but if you get data delays or have to perform extesive processing of the raw video this might be a solution.
                                    Michael Mattias
                                    Tal Systems (retired)
                                    Port Washington WI USA
                                    [email protected]


                                    • #19
                                      Howdy, David!

                                      Problem solved. The software developer gave me the answer. I must admit that was the most unusual license key I've ever seen.

                                      With that, I was able to get your posted code working. Thanks again!

                                      I need to take some time to digest your code and see if I can extract some much simpler examples from it

                                      Along the way, I plan to send the developer some of the examples. His distribution has no examples for PowerBASIC users.


                                      • #20
                                        Hi Gary,

                                        Just noticed your post. Glad you were able to figure out loading the license code with the help of Admir. I spent quite a bit of of time experimenting at the beginning to figure that one out.

                                        Let me know if you have any other questions about the code or VideoCapX. The OCX has some idiosyncrasies, but once you get used to the structure it's quite powerful and really easy to use in combination with PB Win.

                                        We use VideoCapX in combination with DirectShow filters to do real-time image processing and overlays (interactive measurements tools, CAD drawings, transparent images, freehand annotation) on live video with resolution as high as 4k at 30 frames/second.