attachCamera issue: Tiny size

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default attachCamera issue: Tiny size

    I'm having a weird issue. I have a Proof of Concept app that had issues with
    the video area for a live camera showing at 10x10 on both a Mac & PC. I was
    able to use scaleX/scaleY to make it a reasonable size, but the quality suffers
    somewhat (it is better than 10x10 simply resized, but moderate pixelation). I
    eventually switched my code around a little and got things to work (no idea
    what fixed it). Now I am seeing the same behavior in the same code in the full
    application. Was wondering if anyone had any ideas.



    private function onConnectWebcam():void {
    camera_status.text = "";
    if (Camera.names.length > 0 && video == null)
    {
    if(Camera.names.length > 1) {
    // show camera chooser
    }
    // but always connect to default
    onCameraChoosen(Camera.names[0]);
    }
    else
    {
    camera_status.text = "No webcam was found. Please connect a webcam and try
    again.";
    }
    }

    private function onCameraChoosen(camName:String):void {
    onDisconnectWebcam();
    videoHolder = new UIComponent();
    cam = Camera.getCamera(); //(camName) Always connect to default per Adobe
    Docs
    if(cam) {
    cam.addEventListener(StatusEvent.STATUS, attachHandler);
    cam.setMode(480, 360, 30);
    video = new Video(cam.width, cam.height);
    video.attachCamera(cam);
    videoHolder.addChild(video);
    // I HAVE TO SCALE HERE TO GET 10x10 to work
    videoHolder.scaleX = 48;
    videoHolder.scaleY = 36;
    video_canvas.addChildAt(videoHolder,0);
    } else {
    camera_status.text = "Unable to connect to webcam. Perhaps it is busy?";
    }
    }


    Here is the mxml portion its own component. The video_canvas is the container
    for the videoHolder component:
    <mx:Canvas id="webcam" visible="false" y="64" x="14">
    <mx:Canvas backgroundColor="#FFFFFF" width="500" height="380">
    <mx:Canvas id="video_canvas" width="480" height="360" x="10" y="10"
    backgroundColor="#000000" clipContent="true"/>
    <mx:Image id="webcam_image" width="480" height="360" x="10" y="10"/>
    <mx:Text id="camera_status" color="#FFFFFF" x="88" y="88" width="310"
    height="182" fontSize="20" textAlign="center"/>
    </mx:Canvas>
    </mx:Canvas>


    This is the WORKING proof of concept code, which I can't really tell has any
    differences, other than nesting of the video_canvas:
    private function onComp():void {

    if (Camera.names.length > 0)
    {
    videoHolder = new UIComponent();
    cam = Camera.getCamera();
    cam.setMode(480, 360, 30);
    video = new Video(cam.width, cam.height);
    video.attachCamera(cam);
    videoHolder.addChild(video);
    video_canvas.addChild(videoHolder);
    }
    else
    {
    trace("User has no cameras installed.");
    }
    }
    <mx:Application...
    <mx:Canvas id="video_canvas" height="360" width="480" clipContent="true"/>

    slaingod Guest

  2. Similar Questions and Discussions

    1. AttachCamera
      Is there a way to completely detach from your local camera once you have accepted it in the Flash player without closing the swf? ie So another...
    2. PDF file size issue
      I've created two separate versions of the same basic 400 page file in Quark. The first uses a single 700K eps file 3 times on each page and creates a...
    3. Tiny, wrong size, PDF images
      Lori, Jacko, how are you creating your PDF's? What software are you creating from, Quark, in-Design????? What is the final Purpose of the PDF,...
    4. EPS size issue
      I use FH10 as my design tool of choice. I just got a copy of an EPS from a sign co to use. It was 30000 x 30000 pixels. Freehand wouldn't open...
    5. (Tiny) Size issues with laptop WUXGA screen
      Harv, Yes, I have tried setting the display to a lower resolution. Text and graphics look fuzzy, though. Why? Because laptop displays have one...
  3. #2

    Default Re: attachCamera issue: Tiny size

    I've actually narrowed it down to a single thing: Adding any VideoDisplay
    component bugs out the camera. Anyone else ever seen this or know of a
    workaround?

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="onComp()"
    >
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.FaultEvent;
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;
    import mx.core.UIComponent;

    private var cam:Camera;
    private var video:Video;
    private var videoHolder:UIComponent;

    private function onComp():void {

    if (Camera.names.length > 0)
    {
    videoHolder = new UIComponent();
    cam = Camera.getCamera();
    cam.setMode(320, 240, 30);
    video = new Video(cam.width, cam.height);
    video.attachCamera(cam);
    videoHolder.addChild(video);
    video_canvas.addChild(videoHolder);
    }
    else
    {
    trace("User has no cameras installed.");
    }
    }


    ]]>
    </mx:Script>

    <mx:Canvas id="video_canvas" height="240" width="320" clipContent="true"/>

    <mx:VideoDisplay /> <!-- Remove this line and the problem goes away -->

    </mx:Application>

    slaingod Guest

  4. #3

    Default Re: attachCamera issue: Tiny size

    Looks like plain old
    VideoDisplay.attachCamera works here...it is the combo of the 2 that screws
    things up. I originally switched to just Video because I was seeing the same
    thing with VideoDisplay...weirdness. Maybe two different problems, because I
    did reinstall my cam drivers after switching to vid.

    slaingod Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139