1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
psychojs/docs/module-visual.Camera.html
2022-05-23 12:31:01 +02:00

2416 lines
30 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Camera</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Camera</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-visual.html">visual</a>.</span>Camera<span class="signature">(options)</span><span class="type-signature"></span></h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Camera"><span class="type-signature"></span>new Camera<span class="signature">(options)</span><span class="type-signature"></span></h4>
<div class="description">
<p>This manager handles the recording of video signal.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>win</code></td>
<td class="type">
<span class="param-type"><a href="module-core.Window.html">module:core.Window</a></span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">the associated Window</td>
</tr>
<tr>
<td class="name"><code>format</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
'video/webm;codecs=vp9'
</td>
<td class="description last">the video format</td>
</tr>
<tr>
<td class="name"><code>showDialog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to open a dialog box to inform the
participant to wait for the camera to be initialised</td>
</tr>
<tr>
<td class="name"><code>dialogMsg</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
"Please wait a few moments while the camera initialises"
</td>
<td class="description last">default message informing the participant to wait for the camera to initialise</td>
</tr>
<tr>
<td class="name"><code>clock</code></td>
<td class="type">
<span class="param-type">Clock</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
</td>
<td class="description last">an optional clock</td>
</tr>
<tr>
<td class="name"><code>autoLog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to log</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line18">line 18</a>
</li></ul></dd>
<dt class="tag-todo">To Do:</dt>
<dd class="tag-todo">
<ul>
<li>add video constraints as parameter</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="_onChange"><span class="type-signature">(protected) </span>_onChange<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Callback for changes to the recording settings.
<p>Changes to the settings require the recording to stop and be re-started.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line449">line 449</a>
</li></ul></dd>
</dl>
<h4 class="name" id="_prepareRecording"><span class="type-signature">(protected) </span>_prepareRecording<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Prepare the recording.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line470">line 470</a>
</li></ul></dd>
</dl>
<h4 class="name" id="download"><span class="type-signature"></span>download<span class="signature">(filename)</span><span class="type-signature"></span></h4>
<div class="description">
Offer the audio recording to the participant as a video file to download.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last">the filename of the video file</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line365">line 365</a>
</li></ul></dd>
</dl>
<h4 class="name" id="flush"><span class="type-signature"></span>flush<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Submit a request to flush the recording.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line336">line 336</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
promise fulfilled when the data has actually been made available
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="getRecording"><span class="type-signature"></span>getRecording<span class="signature">(tag, flush<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
Get the current video recording as a VideoClip in the given format.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>tag</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">an optional tag for the video clip</td>
</tr>
<tr>
<td class="name"><code>flush</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to first flush the recording</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line429">line 429</a>
</li></ul></dd>
</dl>
<h4 class="name" id="getStream"><span class="type-signature"></span>getStream<span class="signature">()</span><span class="type-signature"> &rarr; {MediaStream}</span></h4>
<div class="description">
Get the underlying video stream.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line85">line 85</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
the video stream
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">MediaStream</span>
</dd>
</dl>
<h4 class="name" id="getVideo"><span class="type-signature"></span>getVideo<span class="signature">()</span><span class="type-signature"> &rarr; {HTMLVideoElement}</span></h4>
<div class="description">
Get a video element pointing to the Camera stream.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line98">line 98</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
a video element
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">HTMLVideoElement</span>
</dd>
</dl>
<h4 class="name" id="isReady"><span class="type-signature"></span>isReady<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<div class="description">
Query whether or not the camera is ready to record.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line72">line 72</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
whether or not the camera is ready to record
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="pause"><span class="type-signature"></span>pause<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Submit a request to pause the recording.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line232">line 232</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
promise fulfilled when the recording actually paused
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="resume"><span class="type-signature"></span>resume<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Submit a request to resume the recording.
<p>resume has no effect if the recording was not previously paused.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>clear</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to empty the video buffer before
resuming the recording</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line279">line 279</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
promise fulfilled when the recording actually resumed
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Submit a request to start the recording.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line132">line 132</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
promise fulfilled when the recording actually started
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<div class="description">
Submit a request to stop the recording.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">
<h6>Properties</h6>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>filename</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last">the name of the file to which the video recording
will be saved</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line188">line 188</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
promise fulfilled when the recording actually stopped, and the recorded
data was made available
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
<h4 class="name" id="upload"><span class="type-signature"></span>upload<span class="signature">(@param)</span><span class="type-signature"></span></h4>
<div class="description">
Upload the video recording to the pavlovia server.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>@param</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">options</td>
</tr>
<tr>
<td class="name"><code>options.tag</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last">an optional tag for the video file</td>
</tr>
<tr>
<td class="name"><code>options.waitForCompletion</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to wait for completion
before returning</td>
</tr>
<tr>
<td class="name"><code>options.showDialog</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last">whether or not to open a dialog box to inform the participant to wait for the data to be uploaded to the server</td>
</tr>
<tr>
<td class="name"><code>options.dialogMsg</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
""
</td>
<td class="description last">default message informing the participant to wait for the data to be uploaded to the server</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="visual_Camera.js.html">visual/Camera.js</a>, <a href="visual_Camera.js.html#line385">line 385</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-core.html">core</a></li><li><a href="module-data.html">data</a></li><li><a href="module-sound.html">sound</a></li><li><a href="module-util.html">util</a></li><li><a href="module-visual.html">visual</a></li></ul><h3>Classes</h3><ul><li><a href="FaceDetector_FaceDetector.html">FaceDetector</a></li><li><a href="module.data.MultiStairHandler.html">MultiStairHandler</a></li><li><a href="module.data.QuestHandler.html">QuestHandler</a></li><li><a href="module-core.BuilderKeyResponse.html">BuilderKeyResponse</a></li><li><a href="module-core.EventManager.html">EventManager</a></li><li><a href="module-core.GUI.html">GUI</a></li><li><a href="module-core.Keyboard.html">Keyboard</a></li><li><a href="module-core.KeyPress.html">KeyPress</a></li><li><a href="module-core.Logger.html">Logger</a></li><li><a href="module-core.MinimalStim.html">MinimalStim</a></li><li><a href="module-core.Mouse.html">Mouse</a></li><li><a href="module-core.PsychoJS.html">PsychoJS</a></li><li><a href="module-core.ServerManager.html">ServerManager</a></li><li><a href="module-core.Window.html">Window</a></li><li><a href="module-data.ExperimentHandler.html">ExperimentHandler</a></li><li><a href="module-data.MultiStairHandler.html">MultiStairHandler</a></li><li><a href="module-data.QuestHandler.html">QuestHandler</a></li><li><a href="module-data.Shelf.html">Shelf</a></li><li><a href="module-data.TrialHandler.html">TrialHandler</a></li><li><a href="module-sound.AudioClip.html">AudioClip</a></li><li><a href="module-sound.AudioClipPlayer.html">AudioClipPlayer</a></li><li><a href="module-sound.Microphone.html">Microphone</a></li><li><a href="module-sound.Sound.html">Sound</a></li><li><a href="module-sound.TonePlayer.html">TonePlayer</a></li><li><a href="module-sound.TrackPlayer.html">TrackPlayer</a></li><li><a href="module-sound.Transcriber.html">Transcriber</a></li><li><a href="module-sound.Transcript.html">Transcript</a></li><li><a href="module-util.Clock.html">Clock</a></li><li><a href="module-util.Color.html">Color</a></li><li><a href="module-util.CountdownTimer.html">CountdownTimer</a></li><li><a href="module-util.EventEmitter.html">EventEmitter</a></li><li><a href="module-util.MixinBuilder.html">MixinBuilder</a></li><li><a href="module-util.MonotonicClock.html">MonotonicClock</a></li><li><a href="module-util.PsychObject.html">PsychObject</a></li><li><a href="module-util.Scheduler.html">Scheduler</a></li><li><a href="module-visual.ButtonStim.html">ButtonStim</a></li><li><a href="module-visual.Camera.html">Camera</a></li><li><a href="module-visual.FaceDetector.html">FaceDetector</a></li><li><a href="module-visual.Form.html">Form</a></li><li><a href="module-visual.GratingStim.html">GratingStim</a></li><li><a href="module-visual.ImageStim.html">ImageStim</a></li><li><a href="module-visual.MovieStim.html">MovieStim</a></li><li><a href="module-visual.Polygon.html">Polygon</a></li><li><a href="module-visual.Rect.html">Rect</a></li><li><a href="module-visual.ShapeStim.html">ShapeStim</a></li><li><a href="module-visual.Slider.html">Slider</a></li><li><a href="module-visual.TextBox.html">TextBox</a></li><li><a href="module-visual.TextStim.html">TextStim</a></li><li><a href="module-visual.VisualStim.html">VisualStim</a></li></ul><h3>Interfaces</h3><ul><li><a href="module-sound.SoundPlayer.html">SoundPlayer</a></li></ul><h3>Mixins</h3><ul><li><a href="module-core.WindowMixin.html">WindowMixin</a></li><li><a href="module-util.ColorMixin.html">ColorMixin</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Mon May 23 2022 12:29:29 GMT+0200 (Central European Summer Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>