Capturing Image from WebCam

nehakochhar10

nehakochhar10

@nehakochhar10-OwRkC0 Oct 16, 2024
Hello
I have developed a HTML Page and using Javascript ,i m capturing an image from Webcam.Problem is that when we open more tahn one instance of Page ,it flickers.single Page works fine.What I felt is that flickering is due to that when we open more than one instance ,sometimes requesting image from webcam gives no image or corrupted ,s it shows Red Cross instead of image n Page and sometimes shows images and keeps flickering.I am using <img> tag and in javascript ,I am creating instance of Image Class in javascript and setting its src.Problem is that when I write Document.getElementbyId("CamImage").src=ImageName.src
then ImageName.src sends again a request for an Image .So is there a workaround that I can capture an image in a variable,retain previous image and if corrupted is received ,I can show the Previous Image instead of Red Cross.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Jun 28, 2011

    Before the document loads, try to pre-load the images, using the same way as you declared a new Image(). Another thing is, make sure the connectivity is fine, else you won't be getting the image, but a Red X Cross!!! 😔
  • nehakochhar10

    nehakochhar10

    @nehakochhar10-OwRkC0 Jul 1, 2011

    In the start I used to preload image as follows:-

    Image imagename=new Image();
    imagename.src="CamImage.jpg";
    Imagecounter=0;
    and then in the refresh() function is used
    refresh()
    {
    if(imagename.complete==true)
    {
    Imagecounter++;
    document.getElementByID("img1").src=imagename.src+"?Rq="+Imagecounter;
    }

    But in the above line of code when on Right hand side I am using imagename.src ,I think it is again sending a request and not getting image at that time,then displaying red cross in the Web Page.I do'nt want that red cross ,I want to check that if image not found from ipcam then ,instead of displaying red cross,display the last image that it got from the IPCAM
  • PraveenKumar Purushothaman

    PraveenKumar Purushothaman

    @praveenkumar-66Ze92 Jul 1, 2011

    Hey, refresh() is a core JavaScript function. Don't use that... Try something else...