-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(log-services): 🎉 update log services and camera libs
- Loading branch information
1 parent
063f51a
commit 2402da9
Showing
7 changed files
with
124 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as NodeWebcam from "node-webcam"; | ||
|
||
export default async function cam() { | ||
const opts = { | ||
width: 1280, | ||
height: 720, | ||
quality: 100, | ||
device: "/dev/video0", | ||
}; | ||
|
||
const Webcam = NodeWebcam.create(opts); | ||
|
||
Webcam.capture("/home/gokhangunduz/Desktop/test.jpg", (err, data) => { | ||
if (err) { | ||
console.error(err); | ||
} else { | ||
console.log("Kamera başarıyla açıldı."); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// import cv from "opencv4nodejs"; | ||
|
||
// // Video kaydı için kullanılacak dosya adı ve FPS (kare hızı) | ||
// const videoFileName = "output.mp4"; | ||
// const fps = 30; | ||
|
||
// // Video çekimine başlayın | ||
// const camera = new cv.VideoCapture(0); // 0, varsayılan kamera cihazını temsil eder | ||
|
||
// const videoWriter = new cv.VideoWriter( | ||
// videoFileName, | ||
// cv.VideoWriter.fourcc("X", "2", "6", "4"), | ||
// fps, | ||
// new cv.Size(640, 480), | ||
// true | ||
// ); | ||
|
||
// const delay = 1000 / fps; | ||
|
||
// function captureFrame() { | ||
// const frame = camera.read(); | ||
// if (!frame.empty) { | ||
// videoWriter.write(frame); | ||
// } | ||
// setTimeout(captureFrame, delay); | ||
// } | ||
|
||
// console.log(`Video kaydediliyor: ${videoFileName}`); | ||
// captureFrame(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,67 @@ | ||
import { Request, Response } from "express"; | ||
import setResponse from "../helpers/setResponse.helper"; | ||
import getRosLogs from "../functions/getRosLogs.function"; | ||
import { RobotLog } from "../types/types"; | ||
import fs from "fs"; | ||
|
||
async function get(req: Request, res: Response) { | ||
const files = await getRosLogs(); | ||
try { | ||
const files: RobotLog[] | null = await getRosLogs(); | ||
|
||
if (files) { | ||
setResponse(res, 200, "ROS logs retrieved successfully.", files); | ||
} else { | ||
setResponse(res, 500, "Error while getting ROS logs.", null); | ||
if (files) { | ||
setResponse(res, 200, "ROS logs retrieved successfully.", files); | ||
} else { | ||
setResponse(res, 500, "Error while getting ROS logs.", null); | ||
} | ||
} catch (error) { | ||
setResponse(res, 500, "An error occurred", null); | ||
} | ||
} | ||
|
||
async function getWithName(req: Request, res: Response) { | ||
fs.readFile( | ||
`/home/${process.env.USER}/.ros/log/${req.params.name}`, | ||
"utf8", | ||
function (err: any, data: any) { | ||
if (err) { | ||
setResponse(res, 500, "Error while getting ROS logs.", null); | ||
return; | ||
} | ||
setResponse(res, 200, "ROS logs retrieved successfully.", data); | ||
} | ||
); | ||
} | ||
|
||
async function remove(req: Request, res: Response) { | ||
try { | ||
const files: RobotLog[] | null = await getRosLogs(); | ||
|
||
files?.map((file) => { | ||
try { | ||
fs.rmSync(`/home/${process.env.USER}/.ros/log/${file.name}`); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}); | ||
|
||
setResponse(res, 200, "ROS logs removed successfully.", null); | ||
} catch (error) { | ||
setResponse(res, 500, "Error while removing ROS logs.", null); | ||
} | ||
} | ||
|
||
async function removeWithName(req: Request, res: Response) { | ||
try { | ||
fs.rmSync(`/home/${process.env.USER}/.ros/log/${req.params.name}`); | ||
setResponse(res, 200, "ROS log removed successfully.", null); | ||
} catch (error) { | ||
setResponse(res, 500, "Error while removing ROS log.", null); | ||
} | ||
} | ||
|
||
export default { | ||
get, | ||
getWithName, | ||
remove, | ||
removeWithName, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters