Sign In

peace-watcher

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

peace-watcher

Real-time detection and alerting

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 20 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts