Skip to content

pinktopaz/peace-watcher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peace Watcher SDK

Peace Watcher SDK provides tools for real-time weapon attack detection and notification using React and React Native.

Installation

Install the package using npm:

npm install peace-watcher

Usage

Initialization

First, initialize the PeaceWatcher SDK in your application:

import PeaceWatcher from 'peace-watcher';

// Initialize the PeaceWatcher SDK
PeaceWatcher.initialize();

Registering CCTV

Register CCTV information using the registerCCTV method:

import PeaceWatcher from 'peace-watcher';

const initCCTV = async (event) => {
  event.preventDefault();
  try {
    await PeaceWatcher.registerCCTV({
      id: 'cctv123',
      location: 'Seoul, South Korea',
    });
    alert('CCTV가 성공적으로 등록되었습니다.');
  } catch (error) {
    console.error('CCTV 등록 중 오류 발생: ', error);
    alert('CCTV 등록에 실패했습니다.');
  }
};

Handling Danger Detection

Set up a listener for danger detection events:

import PeaceWatcher from 'peace-watcher';

// Set up the danger detected listener
PeaceWatcher.onDangerDetected((info) => {
  showAlert('흉기난동 감지!', `위치: ${info.location}. 조심하세요!`);
});

function showAlert(title, message) {
  // Implement your alert logic here
  alert(`${title}\n${message}`);
}

Using RealTimeDetection Component

Integrate the RealTimeDetection component to handle real-time video feed and detect dangerous situations:

import React, { useState } from 'react';
import { RealTimeDetection } from 'peace-watcher';

const App = () => {
  const [isModalOpen, setIsModalOpen] = useState(false);

  const handleModalClose = () => {
    setIsModalOpen(false);
  };

  return (
    <div>
      <h1>Peace Watcher App</h1>
      <button onClick={initCCTV}>Register CCTV</button>
      <RealTimeDetection setIsModalOpen={setIsModalOpen} />
      {isModalOpen && (
        <div>
          <h2>Alert: Dangerous Situation Detected</h2>
          <button onClick={handleModalClose}>Close</button>
        </div>
      )}
    </div>
  );
};

export default App;

Contributing

Feel free to open issues or submit pull requests if you find bugs or have suggestions for improvements.

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%