Skip to content

Commit

Permalink
adicionado exemplo de histograma
Browse files Browse the repository at this point in the history
  • Loading branch information
Piemontez committed May 2, 2024
1 parent 73873bb commit 7b89bdd
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
59 changes: 59 additions & 0 deletions src/plugins/opencvTemplates/histogram-cal.ts
@@ -0,0 +1,59 @@
import { CVVideoCaptureComponent } from '../opencv/inputs/CVVideoCaptureComponent';
import { CvtColorComponent } from '../opencv/conversors/CvtColorComponent';
import { CVFComponent } from '../../ide/components/NodeComponent';
import { ThresholdComponent } from '../opencv/segmentation/ThresholdComponent';

Check failure on line 4 in src/plugins/opencvTemplates/histogram-cal.ts

View workflow job for this annotation

GitHub Actions / app_publish

'ThresholdComponent' is declared but its value is never read.
import { useNodeStore } from '../../core/contexts/NodeStore';
import { ProjectTemplate } from '../../core/types/project-template';
import { CVResizeComponent } from '../opencv/geometricTransformations';

Check failure on line 7 in src/plugins/opencvTemplates/histogram-cal.ts

View workflow job for this annotation

GitHub Actions / app_publish

'CVResizeComponent' is declared but its value is never read.
import { makeXYPosition } from '../../core/utils/makeXYPosition';
import cv from 'opencv-ts';
import { EqualizeHistComponent } from '../opencv/others';
import { HistogramCalcComponent } from '../utils/HistogramCalcComponent';

const group = 'OpenCV';

const HistogramCalcSamplesAction: ProjectTemplate = {
group,
title: 'Histogram Calculator Samples',
action: () => {
let comp: typeof CVFComponent | null;
let pos;

// Add Video
comp = useNodeStore.getState().getNodeType(CVVideoCaptureComponent.name);
pos = makeXYPosition(-3, 0);
const videoId = useNodeStore.getState().addNodeFromComponent(comp!, pos).id;

// Add Convert
comp = useNodeStore.getState().getNodeType(CvtColorComponent.name);
pos = makeXYPosition(-1, 1);
const cvtColorId = useNodeStore.getState().addNodeFromComponent(comp!, pos, { code: cv.COLOR_BGR2GRAY }).id;
// Add Equalize
comp = useNodeStore.getState().getNodeType(EqualizeHistComponent.name);
pos = makeXYPosition(-1, 2);
const eqId = useNodeStore.getState().addNodeFromComponent(comp!, pos, { dsize: new cv.Size(128, 128) }).id;

// Add HistogramCalcComponent
comp = useNodeStore.getState().getNodeType(HistogramCalcComponent.name);
pos = makeXYPosition(0, 0);
const eq1 = useNodeStore.getState().addNodeFromComponent(comp!, pos, { thresh: 100, type: cv.THRESH_BINARY_INV }).id;
// Add HistogramCalcComponent
comp = useNodeStore.getState().getNodeType(HistogramCalcComponent.name);
pos = makeXYPosition(0, 1);
const eq2 = useNodeStore.getState().addNodeFromComponent(comp!, pos, { thresh: 100, type: cv.THRESH_TRUNC }).id;
// Add HistogramCalcComponent
comp = useNodeStore.getState().getNodeType(HistogramCalcComponent.name);
pos = makeXYPosition(0, 2);
const eq3 = useNodeStore.getState().addNodeFromComponent(comp!, pos, { thresh: 100, type: cv.THRESH_TOZERO }).id;

useNodeStore.getState().addEdge(videoId, cvtColorId, 'out', 'src1');
useNodeStore.getState().addEdge(cvtColorId, eqId, 'out', 'src1');
useNodeStore.getState().addEdge(videoId, eq1, 'out', 'image');
useNodeStore.getState().addEdge(cvtColorId, eq2, 'out', 'image');
useNodeStore.getState().addEdge(eqId, eq3, 'out', 'image');

setTimeout(useNodeStore.getState().fitView, 100);
},
};

export default HistogramCalcSamplesAction;
10 changes: 6 additions & 4 deletions src/plugins/opencvTemplates/index.tsx
@@ -1,14 +1,16 @@
import { PluginType } from '../../core/types/plugin';
import morphologySamples from './morphology-samples';
import thresholdSamples from './threshold-samples';
import ThresholdSamplesAction from './threshold-samples';
import MorphologySamplesAction from './morphology-samples';
import HistogramCalcSamplesAction from './histogram-cal';

const OpenCVTemplatesPlugin: PluginType = {
name: 'OpenCV Templates Plugin',
components: [],
templates: [
//
thresholdSamples,
morphologySamples,
ThresholdSamplesAction,
MorphologySamplesAction,
HistogramCalcSamplesAction,
],
};

Expand Down

0 comments on commit 7b89bdd

Please sign in to comment.