3 Replies Latest reply on Jul 26, 2007 10:10 AM by bugsbycarlin

    Webcam BitmapData problem

    bugsbycarlin
      Hi all,

      I'm trying to make a webcam app, using a microsoft Lifecam VX-1000 and Flash Pro 8. It has 320x240 resolution. I capture the camera image using

      var image:BitmapData = new BitmapData(_root.view.width, _root.view.height);
      image.draw(_root.view);

      where view is my camera object.

      The problem is, in the capture, my image is squished into the top left fourth of the screen, and the rest of the capture is white space.

      I'm doing image processing, so I need the full resolution.

      An image that explains what I'm talking about:
      http://www.bugsby.net/drive/webcamproblem.jpg

      My project files:
      http://www.bugsby.net/drive/scanner.zip


      Thanks for taking the time!
      matt carlin


        • 1. Re: Webcam BitmapData problem
          Rothrock Level 5
          I've run into this as well. It is some ratio between the resolution of the camera and the video instance showing it – I've actually run into it with an external FLV, but I'm sure it is the same issue. I was making that popular reflected video on a polished black surface effect. I don't know why it is and I don't know how to actually fix the problem, but a patch/bandaid approach is:

          bmp = new BitmapData(myVideo._width,myVideo._ height, false, 0xff0000);
          mtx = new Matrix();
          mtx.scale(myVideo._xscale/100,-myVideo._yscale/100);

          bmp.draw(myVideo,mtx);

          In my case I only created the bitmap and the scale matrix once, and then the draw method was called repeatedly later.

          If anybody has an actual solution I would love to fine out!
          • 2. Re: Webcam BitmapData problem
            bugsbycarlin Level 1
            Thanks, that worked like a charm!

            I'd love to know why this happens as well. In the meantime, scaling did the trick.
            • 3. Re: Webcam BitmapData problem
              bugsbycarlin Level 1
              By the way, my apologies for the cross post, and thanks for taking the time.