Commit b7ed96a5 by Иван Кубота

change video size, tune segmentation

parent 20e5195e
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
width: <input type="text" class="callapp_width" size="4" value="1280"> </input> width: <input type="text" class="callapp_width" size="4" value="1280"> </input>
height:<input type="text" class="callapp_height" size="4" value="720"> </input> height:<input type="text" class="callapp_height" size="4" value="720"> </input>
</div> </div>
<button class="callapp_button"> Join </button> <button class="callapp_button"> Join </button>
<div class="callapp_local_video">local video</div> <div class="callapp_local_video">local video</div>
<div class="callapp_remote_video">remote video</div> <div class="callapp_remote_video">remote video</div>
</div> </div>
<!-- <!--
<div id="callapp2"> <div id="callapp2">
<h1>Callapp2:</h1> <h1>Callapp2:</h1>
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
type="image/png" type="image/png"
href="favicon.png"> href="favicon.png">
<meta charset="utf-8"> <meta charset="utf-8">
<script>
window.videoSize = {w: 1280, h: 720, fps: 30};
</script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/control_utils/control_utils.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@mediapipe/control_utils/control_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script>
......
...@@ -30,9 +30,9 @@ Screen.Conference = function() { ...@@ -30,9 +30,9 @@ Screen.Conference = function() {
var resultProcessor = function(canvasElement) { var resultProcessor = function(canvasElement) {
window.canvasElement = canvasElement; window.canvasElement = canvasElement;
const segmentations = [false,false,false,false]; let segmentations = [false,false,false];
let sPointer = 0; let sPointer = 0;
var w = 720, h = 405; var w = window.videoSize.w, h = window.videoSize.h;
var tmpCanvas = D.h('canvas', {width: w, height: h}), var tmpCanvas = D.h('canvas', {width: w, height: h}),
tmpCtx = tmpCanvas.getContext('2d'), tmpCtx = tmpCanvas.getContext('2d'),
...@@ -51,10 +51,16 @@ Screen.Conference = function() { ...@@ -51,10 +51,16 @@ Screen.Conference = function() {
tmpCtx.clearRect(0,0,w,h); tmpCtx.clearRect(0,0,w,h);
tmpCtx.drawImage(image,0,0,image.width,image.height,0,0,w,h); tmpCtx.drawImage(image,0,0,image.width,image.height,0,0,w,h);
segmentations[(sPointer++)%4] = tmpCtx.getImageData(0,0,w,h).data; segmentations = [segmentations[1], segmentations[2], tmpCtx.getImageData(0,0,w,h).data];
sPointer++;
var tresh = 64;//window.tresh || 50;
var pos = canvasElement.position; var pos = canvasElement.position;
var from = w*pos[0]/100, var from = w*pos[0]/100,
to = w*pos[1]/100; to = w*pos[1]/100;
var seg1 = segmentations[ 1 ],
seg2 = segmentations[ 2 ],
seg0 = segmentations[ 0 ];
if(sPointer>3){ if(sPointer>3){
var pointer; var pointer;
for(var j = 0; j < h; j++){ for(var j = 0; j < h; j++){
...@@ -66,7 +72,7 @@ Screen.Conference = function() { ...@@ -66,7 +72,7 @@ Screen.Conference = function() {
composedDataData[ pointer ] = composedDataData[ pointer ] =
composedDataData[ pointer - 2 ] = composedDataData[ pointer - 2 ] =
i<from || i > to || i<from || i > to ||
segmentations[ 3 ][ pointer ] + segmentations[ 2 ][ pointer ] + segmentations[ 1 ][ pointer ] + segmentations[ 0 ][ pointer ] < 120 ? 255 : 0; seg2[ pointer ] + (seg1[ pointer ]>>1) + (seg0[ pointer ]>>2) < tresh ? 255 : 0;
pointer += 4; pointer += 4;
//} //}
} }
...@@ -128,8 +134,8 @@ Screen.Conference = function() { ...@@ -128,8 +134,8 @@ Screen.Conference = function() {
canvasResizerEl = CanvasResizer( canvasResizerEl = CanvasResizer(
cameraCanvas = D.h( 'canvas', { cameraCanvas = D.h( 'canvas', {
cls: "output_canvas", cls: "output_canvas",
width: "720px", width: window.videoSize.w+"px",
height: "480px", height: window.videoSize.h+"px",
style: { style: {
/*display: 'none',*/ /*display: 'none',*/
width: '320px' width: '320px'
...@@ -194,7 +200,8 @@ Screen.Conference = function() { ...@@ -194,7 +200,8 @@ Screen.Conference = function() {
}else{ }else{
var stream = await navigator.mediaDevices.getUserMedia( { var stream = await navigator.mediaDevices.getUserMedia( {
video: { video: {
deviceId: { exact: input } deviceId: { exact: input },
width: window.videoSize.w
} }
} ); } );
...@@ -492,7 +499,7 @@ Screen.Conference = function() { ...@@ -492,7 +499,7 @@ Screen.Conference = function() {
console.log('waiting permission') console.log('waiting permission')
try{ try{
await new Promise(((r1, reject) => { await new Promise(((r1, reject) => {
navigator.mediaDevices.getUserMedia( { video: { width: 1280, height: 720 } } ) navigator.mediaDevices.getUserMedia( { video: { width: window.videoSize.w, height: window.videoSize.h } } )
.then( function( stream ){ .then( function( stream ){
r1(); r1();
resolve(); resolve();
...@@ -522,7 +529,18 @@ Screen.Conference = function() { ...@@ -522,7 +529,18 @@ Screen.Conference = function() {
console.log('Got error :', error); console.log('Got error :', error);
} }
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError); navigator.mediaDevices.enumerateDevices()
/*.then(devices => {
var cameras = devices.filter(device => device.kind == "videoinput");
return Promise.all(cameras.map(async function(camera) {
var constraints = { deviceId: { exact: camera.deviceId }, width: window.videoSize.w };
var media = await navigator.mediaDevices.getUserMedia({ video: constraints })
debugger
return media;
}))
})*/
.then(gotDevices).catch(handleError);
var soundDisablerID = setInterval(function() { var soundDisablerID = setInterval(function() {
D('video').map(a=>a.muted = true) D('video').map(a=>a.muted = true)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</head> </head>
<body> <body>
<canvas id="glcanvas" width="640" height="480"></canvas> <canvas id="glcanvas" width="1280" height="720"></canvas>
</body> </body>
<script src="../bundle/awrtc.js"></script> <script src="../bundle/awrtc.js"></script>
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
config.Audio = false; config.Audio = false;
config.Video = true; config.Video = true;
config.FrameUpdates = true; config.FrameUpdates = true;
config.IdealWidth = 640; config.IdealWidth = 1280;
config.IdealHeight = 480; config.IdealHeight = 720;
config.IdealFps = 30; config.IdealFps = 30;
console.log("requested config:" + JSON.stringify(config)); console.log("requested config:" + JSON.stringify(config));
call.Configure(config); call.Configure(config);
......
...@@ -138,7 +138,7 @@ export function CAPI_MediaNetwork_testapp() ...@@ -138,7 +138,7 @@ export function CAPI_MediaNetwork_testapp()
let lIndex = awrtc.CAPI_MediaNetwork_Create("{\"IceUrls\":[\"stun:stun.l.google.com:19302\"], \"SignalingUrl\":\"ws://because-why-not.com:12776\"}"); let lIndex = awrtc.CAPI_MediaNetwork_Create("{\"IceUrls\":[\"stun:stun.l.google.com:19302\"], \"SignalingUrl\":\"ws://because-why-not.com:12776\"}");
let configDone = false; let configDone = false;
awrtc.CAPI_MediaNetwork_Configure(lIndex, true, true, 160, 120, 640, 480, 640, 480, -1, -1, -1); awrtc.CAPI_MediaNetwork_Configure(lIndex, true, true, window['videoSize']['w'], window['videoSize']['h'], window['videoSize']['w'], window['videoSize']['h'], window['videoSize']['w'], window['videoSize']['h'], -1, -1, -1);
console.log(awrtc.CAPI_MediaNetwork_GetConfigurationState(lIndex)); console.log(awrtc.CAPI_MediaNetwork_GetConfigurationState(lIndex));
let startTime = new Date().getTime(); let startTime = new Date().getTime();
......
...@@ -77,11 +77,11 @@ export class VideoInputApp { ...@@ -77,11 +77,11 @@ export class VideoInputApp {
var config = new awrtc.MediaConfig(); var config = new awrtc.MediaConfig();
config.Audio = false;//audio; config.Audio = false;//audio;
config.Video = video; config.Video = video;
config.IdealWidth = 640; config.IdealWidth = window['videoSize']['w'];
config.MinWidth = 640; config.MinWidth = window['videoSize']['w'];
config.MinHeight = 480; config.MinHeight = window['videoSize']['h'];
config.IdealHeight = 480; config.IdealHeight = window['videoSize']['h'];
config.IdealFps = 30; config.IdealFps = window['videoSize']['fps'];
if (this.sVideoDevice !== null) { if (this.sVideoDevice !== null) {
config.VideoDeviceName = this.sVideoDevice; config.VideoDeviceName = this.sVideoDevice;
} }
......
...@@ -528,8 +528,8 @@ export class BrowserMediaStream { ...@@ -528,8 +528,8 @@ export class BrowserMediaStream {
var videoElement: HTMLVideoElement= document.createElement("video"); var videoElement: HTMLVideoElement= document.createElement("video");
//width/doesn't seem to be important //width/doesn't seem to be important
videoElement.width = 640; videoElement.width = window['videoSize']['w'];
videoElement.height = 480; videoElement.height = window['videoSize']['h'];
videoElement.controls = true; videoElement.controls = true;
videoElement.setAttribute("playsinline", ""); videoElement.setAttribute("playsinline", "");
videoElement.id = "awrtc_mediastream_video_" + this.mInstanceId; videoElement.id = "awrtc_mediastream_video_" + this.mInstanceId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment