2.0.1 • Published 5 months ago

helldivers2-screenshots-analyzer v2.0.1

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

Helldivers 2 Screenshots Analyzer

A utility for analyzing screenshots from the game Helldivers 2 and identifying key elements by color detection.

Find and count every completed primary and secondary missions

Detected missions

Installation

npm install helldivers2-screenshots-analyzer

Usage

import { parseImage } from 'helldivers2-screenshots-analyzer';

const primaryParseResult = await parseImage({
  filename: 'screenshot1',
  label: 'mission-icons',
  sourcePath: 'https://raw.githubusercontent.com/wlp2s0/war-crime-counter/d21873b269f555d599977210f87e18aa7663b89f/test/fixtures/0_3_5.png',
  targetColor: { r: 255, g: 135, b: 36, tolerance: 32 }
});

const secondaryParseResult = await parseImage({
  filename: 'screenshot1',
  label: 'mission-icons',
  sourcePath: 'https://raw.githubusercontent.com/wlp2s0/war-crime-counter/d21873b269f555d599977210f87e18aa7663b89f/test/fixtures/0_3_5.png',
  targetColor: { r: 113, g: 245, b: 255, tolerance: 42 }
});

console.log({ primaryMissions: primaryParseResult.success, secondaryMissions: secondaryParseResult.success });
/*
Expected output:
{ primaryMissions: 3, secondaryMissions: 5 }
*/

API Reference

parseImage(options)

Parses an image to detect and classify areas matching a target color.

Options

ParameterTypeDefaultDescription
filenamestringRequiredName of the file to be parsed
labelstringRequiredLabel used for debugging and console output
sourcePathstringRequiredFull path to the source image, it can either be a local fs path or an url
targetColorTargetColourRequiredThe target color to detect in the image
minMergeThresholdRationumber0.001Minimum threshold ratio for merging detected regions
maxMergeThresholdRationumber0.4Maximum threshold ratio for merging detected regions
minWidthThresholdRationumber0.015Minimum threshold ratio for detected region width
minHeightThresholdRationumber0.015Minimum threshold ratio for detected region height
maxWidthThresholdRationumber0.14Maximum threshold ratio for detected region width
maxHeightThresholdRationumber0.14Maximum threshold ratio for detected region height
allowedBoxProportionnumber3Proportion threshold for width/height ratio
cropRatioWidthnumber0.275Width ratio for cropping the image
cropRatioHeightnumber0.35Height ratio for cropping the image
noiseThresholdPercentagenumber7.5Percentage threshold for noise detection
plainColorThresholdPercentagenumber90Percentage threshold for plain color detection
marginThresholdRationumber0.005Margin threshold ratio for detected regions
yCropOffsetRationumber0.025Vertical offset ratio for cropping
debugbooleanfalseEnable debug mode to save intermediate images
baseDebugPathstring"./debug"Base path for saving debug images

Returns

{
  success: number, // Count of successfully detected icons
  plain: number,   // Count of plain color boxes
  small: number,   // Count of boxes that are too small
  big: number,     // Count of boxes that are too large
  noisy: number,   // Count of noisy boxes
  abnormal: number // Count of boxes with abnormal proportions
}

License

MIT

2.0.1

5 months ago

2.0.0

5 months ago

1.0.10

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago