• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
ansdpwn / 도로위험상황_모니터링및안내시스템 star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB 1
  • Files
  • Commit
  • Branches
도로위험상황_모니터링및안내시스템srccomponentPhoto.js
Download as .zip file
File name
Commit message
Commit date
.bundle
[FEAT] fogapp
2023-11-14
__tests__
[FEAT] fogapp
2023-11-14
android
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
ios
[FEAT] fogapp
2023-11-14
src
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
.buckconfig
[FEAT] fogapp
2023-11-14
.eslintrc.js
[FEAT] fogapp
2023-11-14
.flowconfig
[FEAT] fogapp
2023-11-14
.gitignore
[FEAT] fogapp
2023-11-14
.node-version
[FEAT] fogapp
2023-11-14
.prettierrc.js
[FEAT] fogapp
2023-11-14
.ruby-version
[FEAT] fogapp
2023-11-14
.watchmanconfig
[FEAT] fogapp
2023-11-14
App.js
[FEAT] fogapp
2023-11-14
Gemfile
[FEAT] fogapp
2023-11-14
app.json
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
babel.config.js
[FEAT] fogapp
2023-11-14
index.js
[FEAT] fogapp
2023-11-14
metro.config.js
[FEAT] fogapp
2023-11-14
package-lock.json
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
package.json
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
test.json
[FEAT] fogapp
2023-11-14
File name
Commit message
Commit date
component
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
context
[FEAT] fogapp
2023-11-14
navigator
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
resoureces
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
screens
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
color.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
File name
Commit message
Commit date
Action.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
BottomDrop.js
[FEAT] fogapp
2023-11-14
Button.js
[FEAT] fogapp
2023-11-14
Checkbox.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
CustomDrawer.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
DriveStatus.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
Input.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
Logo.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
Map.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
ModalComponent.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
Photo.js
[FEAT] fogapp
2023-11-14
Search.js
[FIX] api key 변경, color.js 로 관리 변경
2023-11-14
moonyeju 2023-11-14 d7c9c2b [FEAT] fogapp UNIX
Raw Open in browser Change history
import React, {useRef, useEffect, useCallback, useContext} from 'react'; import {Linking, Text, Alert} from 'react-native'; import {useCameraDevices, Camera} from 'react-native-vision-camera'; import RNFS from 'react-native-fs'; import {url} from '../url'; export default function Photo({onUploadFile}) { const {onQuery, location} = useContext(MapContext); // camera settings const devices = useCameraDevices(); const device = devices.back; const camera = useRef(null); let timerId; const requestCameraPermission = useCallback(async () => { const permission = await Camera.requestCameraPermission(); if (permission === 'denied') await Linking.openSettings(); }, []); const takePicture = async () => { const {path} = await camera.current.takePhoto({ flash: 'off', qualityPrioritization: 'speed', //'quality', }); let pathSplit = path.split('/'); let pathSplitLength = pathSplit.length; let fileName = pathSplit[pathSplitLength - 1]; //확장자까지 붙은 파일명 let splitFileName = fileName.split('.'); // 파일명을 다시 "." 로 나누면 파일이름과 확장자로 나뉜다 let sFileName = splitFileName[0]; // 파일이름 let files = [ { name: 'file', filename: fileName, filepath: path, filetype: 'image/jpg', }, ]; //이미지 서버 전송 let upload = response => { let jobId = response.jobId; console.log('UPLOAD HAS BEGUN! JobId: ' + jobId); }; let uploadProgress = response => { let percentage = Math.floor( (response.totalBytesSent / response.totalBytesExpectedToSend) * 100, ); console.log('UPLOAD IS ' + percentage + '% DONE!'); }; await RNFS.uploadFiles({ toUrl: `${url}/action/image_summit`, files: files, method: 'POST', headers: {}, begin: upload, progress: uploadProgress, }) .promise.then(response => { if (response.statusCode != 200) { throw 'SERVER ERROR'; } console.log('FILES UPLOADED!'); //이미지 분석 요청 return fetch(`${url}/action/image_anal`, { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: JSON.stringify({ filename: sFileName, file_type: '.jpg', gps_x: location.latitude, gps_y: location.longitude, }), }); }) .then(response => response.json()) .then(data => { console.log('fileSend response data : ', data); const {node, fog} = data; if (node === null || fog !== 'fog') { throw 'no data'; } onUploadFile(node); Alert.alert('안개 발생 알람', '전방에 안개가 발생하였습니다.'); // 분석 결과 node remove 요청 return fetch(`${url}/trip/remove`, { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', }, body: JSON.stringify({ gps_x: node[0], gps_y: node[1], }), }); }) .then(response => response.json()) .then(data => { console.log('remove data', data); if (data.done === 'done') { return; } }) .catch(err => { console.log(err); }); }; }

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up