JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2013, 06:03 AM
Stefan1 Stefan1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 399 Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 7 sec
Reputation Power: 19
GetImageData - crossOrigin error

Hi,
I am trying to get a frame from a video and store it as a variable so that I can draw that image onto a canvas every 100ms for a while. As far as I know the only way to do this is:
Code:
context.drawImage( video, x, y, witdh, height );
frame = context.getImageData( x, y, width, height );

and then later do:
Code:
context.putImageData( frame, x, y );

However this gives me the following error:
Quote:
Unable to get image data from canvas because the canvas has been tainted by cross-origin data.

I am working locally without using a webserver. I understood this error is because it only allows to get image data if the image is on the same domain and since I am working locally I don't have a domain so the browser assumes the document and images are on different domains.

I need this to work locally (without a webserver of any kind). Is there anyway to avoid this problem without giving warning messages to the user? Or is there another way to achieve what I want?

Thanks in advance
Stefan

Reply With Quote
  #2  
Old March 8th, 2013, 01:44 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
Look into Canvas CORS; to allow you to get image data from a foreign origin.

CORS Enabled Image

I am not sure, if this is achievable locally, but I am sure; if you do some reading up on this; you can find the details about that.

Reply With Quote
  #3  
Old March 8th, 2013, 06:32 PM
Stefan1 Stefan1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 399 Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 7 sec
Reputation Power: 19
Thanks.
Unfortunately it turns out that it does not work locally.

So there is no other way, possibly without getImageData, to get a frame from a video and displaying it for like 10 seconds on a canvas while other things are added and removed from that canvas (so that the frame from the video needs to be drawn over and over again)?

I want to draw that frame every 30 ms orso, but somehow I need a handle/variable to store it in, so I can say I want to print that particular frame.

Reply With Quote
  #4  
Old March 8th, 2013, 09:03 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
Why don't you just embed the video; within a page, locally and why do you need to even do this locally? I am just wondering what the purpose of doing this is. If it's about money; you do know there are free web hosting sites/servers out there... right?

Last edited by web_loone08 : March 8th, 2013 at 09:06 PM.

Reply With Quote
  #5  
Old March 9th, 2013, 09:07 AM
Stefan1 Stefan1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 399 Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 7 sec
Reputation Power: 19
The thing is i'm making an assignment and don't know whether it will be graded on their local pc or on a server.

I do embed the video but I need to take frames from that embeded video and show them on a canvas for some time while the canvas is being cleared every so many miliseconds. In the meanwhile I am redrawing the videoframes and other elements.

Reply With Quote
  #6  
Old March 9th, 2013, 08:04 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
I am not sure if you can use jQuery or not; for your school project, but if you can..., then check this example out. This HTML5 video url is cross domain / cross origin and is embedded in this page; yet it works just fine. Have a look at it and see what you think:
http://jsbin.com/ujovu4. And if you cannot use jQuery; it looks pretty simple to convert to normal JavaScript.

Edit: Just tested offline/locally and it works just fine.

Last edited by web_loone08 : March 9th, 2013 at 08:09 PM.

Reply With Quote
  #7  
Old March 10th, 2013, 04:58 AM
Stefan1 Stefan1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 399 Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 7 sec
Reputation Power: 19
Hey thanks for the replies

I took a look at that example but this uses drawImage() to draw a frame from a playing video onto the screen every 33 ms orso. I noticed before that drawImage doesn't have this crossOrigin problem. I guess because it doesn't let you store the image data, it just draws it right away without doing anything with it.

I need to store the image data for a while so that I can redraw that same frame later on. In this example a different frame is taken from the video everytime drawImage is called.

I think I'll just let go of the idea that I'm having, as it doesn't seem possible without using a webserver. I appreciate the effort though!

Grtz Stefan

Reply With Quote
  #8  
Old March 10th, 2013, 08:28 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
You could use the example I provided you and incorporate it with your code; to save the images. You would need to create another canvas to clone and/or save the first canvases image. I think I would at least try something like that. You cannot just give up, in web development; just because there are barriers..., you have to find away around them; even if the path is narrow (that's my two cent ). Good luck, which ever way; that you decide to go.
Comments on this post
Stefan1 agrees!

Reply With Quote
  #9  
Old March 11th, 2013, 12:20 PM
Stefan1 Stefan1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 399 Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level)Stefan1 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 7 sec
Reputation Power: 19
Hehe, you're right. Though I don't have too much time for just this problem as it is just for a minor part of the assignment :-).

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > GetImageData - crossOrigin error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap