Skip to content

Commit

Permalink
Merge pull request #57 from PeculiarVentures/codebase-enhancements
Browse files Browse the repository at this point in the history
Codebase enhancements (lint, comments)
  • Loading branch information
apilguk authored Jan 14, 2020
2 parents dbced9b + 385e6d0 commit abce506
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/io/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Tensor from '../program/tensor';

export function imageTensorFromURL(url, type = 'uint8', outShape, cors = false) {
export default function imageTensorFromURL(url, type = 'uint8', outShape, cors = false) {
return new Promise((reolve, reject) => {
const image = document.createElement('img');
const canvas = document.createElement('canvas');
Expand Down
4 changes: 2 additions & 2 deletions lib/io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

export * from './canvas_utils';
export * from './canvas';
export * from './image';
export * from './video';
export { default as imageTensorFromURL } from './image';
export { default as CaptureVideo } from './video';
5 changes: 4 additions & 1 deletion lib/io/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function getMinAvailableSize(r, minWidth, minHeight) {
};
}

export class CaptureVideo {
export default class CaptureVideo {
static IsAvailable() {
const cfg = {
video: {
Expand All @@ -92,6 +92,9 @@ export class CaptureVideo {

const ua = navigator.userAgent;

/* to deal with bug of hard requesting video stream width/height on Safari,
request will be rejected if not actual webcam resolution requested
*/
if (ua.indexOf('Safari') !== -1 && ua.indexOf('Chrome') === -1) {
delete cfg.video.width;
delete cfg.video.height;
Expand Down
2 changes: 2 additions & 0 deletions lib/program/glsl_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function injectAll(kernel, error, useStyles = true) {
}

export default function processError(kernel, kernelName, error) {
/* eslint-disable no-console */ /* due to expected place for console */
try {
const prepared = injectAll(kernel, error);
const stats = prepared.errorsStats;
Expand All @@ -104,4 +105,5 @@ export default function processError(kernel, kernelName, error) {
} catch (err) {
console.warn('Unable to process GLSG compiling error.');
}
/* eslint-enable no-console */
}
2 changes: 2 additions & 0 deletions lib/program/kernel_constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ export default function constructKernel(op) {
}

if (ENV.DEBUG) {
/* eslint-disable no-console */ /* due to expected place for console */
console.groupCollapsed(op.name);
console.log(prepareSourceLines(fullKernel).join('\n'));
console.groupEnd();
/* eslint-enable no-console */
}

return fullKernel;
Expand Down
2 changes: 2 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const isValidOperationShape = shape => shape[0] > 0 && shape[1] > 0;
export class DeprecationError extends Error { }

export function deprecationWarning(name, msg) {
/* eslint-disable no-console */ /* due to expected place for console */
console.warn(`GammaCV Deprecation Warning: "${name}" is deprecated${msg ? `, ${msg}` : ''}. "${name}" will be removed in next major version.`);
/* eslint-enable no-console */
}

export function deprecationError(name, msg) {
Expand Down
2 changes: 2 additions & 0 deletions test/test_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function logTensorAsTable(tensor, channel = 0) {
table.push(raw);
}

/* eslint-disable no-console */ /* due to test util */
console.table(table);
/* eslint-enable no-console */
}

export function imageDiff(input, output) {
Expand Down

0 comments on commit abce506

Please sign in to comment.