File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ import express from 'express' ;
2
+ import * as OpenCV from 'opencv4nodejs' ;
3
+
4
+ const router = express . Router ( ) ;
5
+ const cv = new OpenCV . CV ( ) ;
6
+
7
+ router . post ( '/image-processing' , async ( req , res ) => {
8
+ const { image } = req . body ;
9
+ const processedImage = await cv . processImage ( image , 'grayscale' ) ;
10
+ res . json ( { processedImage } ) ;
11
+ } ) ;
12
+
13
+ router . post ( '/object-detection' , async ( req , res ) => {
14
+ const { image } = req . body ;
15
+ const detections = await cv . detectObjects ( image , 'yolo' ) ;
16
+ res . json ( { detections } ) ;
17
+ } ) ;
18
+
19
+ router . post ( '/image-segmentation' , async ( req , res ) => {
20
+ const { image } = req . body ;
21
+ const segmentation = await cv . segmentImage ( image , 'kmeans' ) ;
22
+ res . json ( { segmentation } ) ;
23
+ } ) ;
24
+
25
+ export default router ;
You can’t perform that action at this time.
0 commit comments