<commit_before>//This variables will be global variable 
var global_width=undefined;
var global_height=undefined;


//Orientation of the device, if is undefined; we assume a pc here
//Else it will be:
//      verticle:0 or 180
//      horizontal:90 or -90
var previousOrientation = window.orientation;



//Video initialization etc
var video = document.createElement('video');
video.autoplay=true;



var videoTexture = new THREE.Texture(video);
var surface_material_video = new THREE.MeshBasicMaterial ({
    map : videoTexture
});

var videoSelect = document.querySelector('select#videoSource');
var selectors=[videoSelect];
//Gets devices
function gotDevices(deviceInfos) {
    var values = selectors.map(function(select) {
        return select.value;
    });
    selectors.forEach(function(select) {
        while (select.firstChild) {
            select.removeChild(select.firstChild);
        }
    });
    for (var i = 0; i !== deviceInfos.length; ++i) {
        var deviceInfo = deviceInfos[i];
        var option = document.createElement('option');
        
        option.value = deviceInfo.deviceId;

        if (deviceInfo.kind === 'videoinput') {
            option.text = deviceInfo.label || 'camera ' + (videoSelect.length + 1);
            // alert( option.text);
            videoSelect.appendChild(option);
        } else {
            console.log('Some other kind of source/device: ', deviceInfo);
        }
    }
    selectors.forEach(function(select, selectorIndex) {
        if (Array.prototype.slice.call(select.childNodes).some(function(n) {
            return n.value === values[selectorIndex];
        })) {
            select.value = values[selectorIndex];
        }
    });
}

//enumerates the devices
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);


//If stream is received
function gotStream(stream) {
    window.stream = stream; // make stream available to console
    video.srcObject = stream;
    // Refresh button list in case labels have become available
    return navigator.mediaDevices.enumerateDevices();
}

function handleError(error) {
    console.log('navigator.getUserMedia error: ', error);
}

//switch value for videoSelect

function start() {
    if (window.stream) {
        window.stream.getTracks().forEach(function(track) {
            track.stop();
        });
    }


    //var audioSource = audioInputSelect.value;
    var videoSource = videoSelect.value;
    
    var constraints = {
        // audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
        video: {deviceId: videoSource ? {exact: videoSource} : undefined}
    };

    //alert(constraints.video);
    navigator.mediaDevices.getUserMedia(constraints).
    then(gotStream).then(gotDevices).catch(handleError);
    //video.addEventListener("loadedmetadata");

    //if the meta data has changed;
    video.onloadedmetadata=function(){
        global_width=this.videoWidth;
        global_height=this.videoHeight;
    
    }
  
    /*
    video.onloadedmetadata = function() {
        console.log('width is', this.videoWidth);
        console.log('height is', this.videoHeight);

        if(this.videoWidth < 10){
            video.width = 480;
        } else {
            video.width = this.videoWidth;
        }

        if(this.videoHeigth <10){
            video.height = 640;
        } else{
            video.height = this.videoHeight;
        }<commit_msg>error 9<commit_after>//This variables will be global variable 
var global_width=undefined;
var global_height=undefined;


//Orientation of the device, if is undefined; we assume a pc here
//Else it will be:
//      verticle:0 or 180
//      horizontal:90 or -90
var previousOrientation = window.orientation;



//Video initialization etc
var video = document.createElement('video');
video.autoplay=true;



var videoTexture = new THREE.Texture(video);
var surface_material_video = new THREE.MeshBasicMaterial ({
    map : videoTexture
});

var videoSelect = document.querySelector('select#videoSource');
var selectors=[videoSelect];
//Gets devices
function gotDevices(deviceInfos) {
    var values = selectors.map(function(select) {
        return select.value;
    });
    selectors.forEach(function(select) {
        while (select.firstChild) {
            select.removeChild(select.firstChild);
        }
    });
    for (var i = 0; i !== deviceInfos.length; ++i) {
        var deviceInfo = deviceInfos[i];
        var option = document.createElement('option');
        
        option.value = deviceInfo.deviceId;

        if (deviceInfo.kind === 'videoinput') {
            option.text = deviceInfo.label || 'camera ' + (videoSelect.length + 1);
            // alert( option.text);
            videoSelect.appendChild(option);
        } else {
            console.log('Some other kind of source/device: ', deviceInfo);
        }
    }
    selectors.forEach(function(select, selectorIndex) {
        if (Array.prototype.slice.call(select.childNodes).some(function(n) {
            return n.value === values[selectorIndex];
        })) {s
            select.value = values[selectorIndex];
        }
    });
}

//enumerates the devices
navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(handleError);

//If stream is received
function gotStream(stream) {
    window.stream = stream; // make stream available to console
    video.srcObject = stream;
    alert("got stream called");
    // Refresh button list in case labels have become available
    return navigator.mediaDevices.enumerateDevices();
    
}

function handleError(error) {
    console.log('navigator.getUserMedia error: ', error);
}

//switch value for videoSelect

function start() {
    if (window.stream) {
        window.stream.getTracks().forEach(function(track) {
            track.stop();
        });
    }


    //var audioSource = audioInputSelect.value;
    var videoSource = videoSelect.value;
    
    var constraints = {
        // audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
        video: {deviceId: videoSource }
    };

    //alert(constraints.video);
    navigator.mediaDevices.getUserMedia(constraints).
    then(gotStream).then(gotDevices).catch(handleError);
    //video.addEventListener("loadedmetadata");

    //if the meta data has changed;
    video.onloadedmetadata=function(){
        global_width=this.videoWidth;
        global_height=this.videoHeight;
    
    }
  
    /*
    video.onloadedmetadata = function() {
        console.log('width is', this.videoWidth);
        console.log('height is', this.videoHeight);

        if(this.videoWidth < 10){
            video.width = 480;
        } else {
            video.width = this.videoWidth;
        }

        if(this.videoHeigth <10){
            video.height = 640;
        } else{
            video.height = this.videoHeight;
        }
{'fraction_non_alphanumeric': 0.11972550737333917, 'fraction_numerical': 0.005986275368666959, 'mean_word_length': 2.6729222520107236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3348309', 'n_tokens_mistral': 1965, 'n_tokens_neox': 1890, 'n_words': 426}