u/Alone_Percentage7388

I beg of yall somebody help me.

/* Edge Impulse Arduino examples
 * Entegrasyon: ESP32-CAM Ateş Algılama ve Bas Siren Sistemi
 */


#include <kursat-project-1_inferencing.h>
#include "edge-impulse-sdk/dsp/image/image.hpp"
#include "esp_camera.h"


// --- KAMERA MODELİ SEÇİMİ ---
// Eğer ESP-EYE kullanıyorsan üsttekini, standart ESP32-CAM kullanıyorsan alttakini aktif et.
//#define CAMERA_MODEL_ESP_EYE 
#define CAMERA_MODEL_AI_THINKER // Genelde piyasadaki standart kartlar budur.


#if defined(CAMERA_MODEL_ESP_EYE)
#define PWDN_GPIO_NUM    -1
#define RESET_GPIO_NUM   -1
#define XCLK_GPIO_NUM    4
#define SIOD_GPIO_NUM    18
#define SIOC_GPIO_NUM    23
#define Y9_GPIO_NUM      36
#define Y8_GPIO_NUM      37
#define Y7_GPIO_NUM      38
#define Y6_GPIO_NUM      39
#define Y5_GPIO_NUM      35
#define Y4_GPIO_NUM      14
#define Y3_GPIO_NUM      13
#define Y2_GPIO_NUM      34
#define VSYNC_GPIO_NUM   5
#define HREF_GPIO_NUM    27
#define PCLK_GPIO_NUM    25


#elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27
#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22
#else
#error "Camera model not selected"
#endif


/* Constant defines -------------------------------------------------------- */
#define EI_CAMERA_RAW_FRAME_BUFFER_COLS           320
#define EI_CAMERA_RAW_FRAME_BUFFER_ROWS           240
#define EI_CAMERA_FRAME_BYTE_SIZE                 3


/* Ses Ayarları ------------------------------------------------------------ */
const int sesPini = 12; // Amfiye gidecek ses sinyal pini (DAC1)
// NOT: Edge Impulse modelinde ateş sınıfına verdiğin ismi buraya KÜÇÜK/BÜYÜK harf duyarlı olarak yazmalısın.
// Örneğin Edge Impulse'ta etiketin adı "fire" ise burayı "fire" yap.
const char* atesEtiketi = "fire"; 
const float esikDegeri = 0.70; // %70 doğruluk payının üzerindeyse alarmı çal


/* Private variables ------------------------------------------------------- */
static bool debug_nn = false; 
static bool is_initialised = false;
uint8_t *snapshot_buf; 


static camera_config_t camera_config = {
    .pin_pwdn = PWDN_GPIO_NUM,
    .pin_reset = RESET_GPIO_NUM,
    .pin_xclk = XCLK_GPIO_NUM,
    .pin_sscb_sda = SIOD_GPIO_NUM,
    .pin_sscb_scl = SIOC_GPIO_NUM,
    .pin_d7 = Y9_GPIO_NUM,
    .pin_d6 = Y8_GPIO_NUM,
    .pin_d5 = Y7_GPIO_NUM,
    .pin_d4 = Y6_GPIO_NUM,
    .pin_d3 = Y5_GPIO_NUM,
    .pin_d2 = Y4_GPIO_NUM,
    .pin_d1 = Y3_GPIO_NUM,
    .pin_d0 = Y2_GPIO_NUM,
    .pin_vsync = VSYNC_GPIO_NUM,
    .pin_href = HREF_GPIO_NUM,
    .pin_pclk = PCLK_GPIO_NUM,
    .xclk_freq_hz = 20000000,
    .ledc_timer = LEDC_TIMER_0,
    .ledc_channel = LEDC_CHANNEL_0,
    .pixel_format = PIXFORMAT_JPEG, 
    .frame_size = FRAMESIZE_QVGA,    
    .jpeg_quality = 12, 
    .fb_count = 1,       
    .fb_location = CAMERA_FB_IN_PSRAM,
    .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
};


bool ei_camera_init(void);
void ei_camera_deinit(void);
bool ei_camera_capture(uint32_t img_width, uint32_t img_height, uint8_t *out_buf);


void setup()
{
    Serial.begin(115200);
    pinMode(sesPini, OUTPUT); // Ses pinini çıkış olarak ayarla
    
    while (!Serial);
    Serial.println("Edge Impulse Yangın Algılama Sistemi Başlatılıyor...");
    
    if (ei_camera_init() == false) {
        ei_printf("Kamera başlatılamadı!\r\n");
    }
    else {
        ei_printf("Kamera başarıyla başlatıldı.\r\n");
    }


    ei_printf("\n2 saniye içinde sürekli analiz başlayacak...\n");
    ei_sleep(2000);
}


void loop()
{
    if (ei_sleep(5) != EI_IMPULSE_OK) {
        return;
    }


    snapshot_buf = (uint8_t*)malloc(EI_CAMERA_RAW_FRAME_BUFFER_COLS * EI_CAMERA_RAW_FRAME_BUFFER_ROWS * EI_CAMERA_FRAME_BYTE_SIZE);


    if(snapshot_buf == nullptr) {
        ei_printf("ERR: Bellek allocation hatası!\n");
        return;
    }


    ei::signal_t signal;
    signal.total_length = EI_CLASSIFIER_INPUT_WIDTH * EI_CLASSIFIER_INPUT_HEIGHT;
    signal.get_data = &ei_camera_get_data;


    if (ei_camera_capture((size_t)EI_CLASSIFIER_INPUT_WIDTH, (size_t)EI_CLASSIFIER_INPUT_HEIGHT, snapshot_buf) == false) {
        ei_printf("Fotoğraf çekilemedi\r\n");
        free(snapshot_buf);
        return;
    }


    ei_impulse_result_t result = { 0 };


    EI_IMPULSE_ERROR err = run_classifier(&signal, &result, debug_nn);
    if (err != EI_IMPULSE_OK) {
        ei_printf("ERR: Sınıflandırıcı çalıştırılamadı (%d)\n", err);
        free(snapshot_buf);
        return;
    }


    bool atesTespitEdildi = false;


    // --- YAPAY ZEKA ÇIKTILARINI KONTROL ETME VE SES TETİKLEME ---
#if EI_CLASSIFIER_OBJECT_DETECTION == 1
    // Eğer nesne algılama (Object Detection - FOMO) modeli kullandıysan:
    for (uint32_t i = 0; i < result.bounding_boxes_count; i++) {
        ei_impulse_result_bounding_box_t bb = result.bounding_boxes[i];
        if (bb.value == 0) continue;
        
        // Model ateş etiketini belirlediğin eşik değerinden yüksek buldu mu?
        if (strcmp(bb.label, atesEtiketi) == 0 && bb.value >= esikDegeri) {
            atesTespitEdildi = true;
            ei_printf("YANGIN ALGILANDI! Konum -> x:%u y:%u Skor: %.2f\r\n", bb.x, bb.y, bb.value);
        }
    }
#else
    // Eğer standart nesne sınıflandırma (Image Classification) modeli kullandıysan:
    for (uint16_t i = 0; i < EI_CLASSIFIER_LABEL_COUNT; i++) {
        if (strcmp(ei_classifier_inferencing_categories[i], atesEtiketi) == 0) {
            if (result.classification[i].value >= esikDegeri) {
                atesTespitEdildi = true;
                ei_printf("YANGIN TEHLİKESİ! Olasılık: %.2f\r\n", result.classification[i].value);
            }
        }
    }
#endif


    // --- SES AKSİYONU ---
    if (atesTespitEdildi) {
        // 30 Hz'den 100 Hz'e bas siren sesi üretimi
        for (int frekans = 30; frekans <= 100; frekans += 2) { 
            tone(sesPini, frekans); 
            delay(15); // Frekans geçiş hızı
        }
        for (int frekans = 100; frekans >= 30; frekans -= 2) {
            tone(sesPini, frekans);
            delay(15);
        }
    } else {
        // Ateş yoksa sesi tamamen kapat
        noTone(sesPini);
    }


    free(snapshot_buf);
}


// --- Kamera Fonksiyonları (Dokunulmadı) ---
bool ei_camera_init(void) {
    if (is_initialised) return true;
#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif
    esp_err_t err = esp_camera_init(&camera_config);
    if (err != ESP_OK) {
      Serial.printf("Camera init failed with error 0x%x\n", err);
      return false;
    }
    sensor_t * s = esp_camera_sensor_get();
    if (s->id.PID == OV3660_PID) {
      s->set_vflip(s, 1);
      s->set_brightness(s, 1);
      s->set_saturation(s, 0);
    }
#if defined(CAMERA_MODEL_M5STACK_WIDE)
    s->set_vflip(s, 1);
    s->set_hmirror(s, 1);
#elif defined(CAMERA_MODEL_ESP_EYE)
    s->set_vflip(s, 1);
    s->set_hmirror(s, 1);
    s->set_awb_gain(s, 1);
#endif
    is_initialised = true;
    return true;
}


void ei_camera_deinit(void) {
    esp_err_t err = esp_camera_deinit();
    if (err != ESP_OK) {
        ei_printf("Camera deinit failed\n");
        return;
    }
    is_initialised = false;
    return;
}


bool ei_camera_capture(uint32_t img_width, uint32_t img_height, uint8_t *out_buf) {
    bool do_resize = false;
    if (!is_initialised) {
        ei_printf("ERR: Camera is not initialized\r\n");
        return false;
    }
    camera_fb_t *fb = esp_camera_fb_get();
    if (!fb) {
        ei_printf("Camera capture failed\n");
        return false;
    }
   bool converted = fmt2rgb888(fb->buf, fb->len, PIXFORMAT_JPEG, snapshot_buf);
   esp_camera_fb_return(fb);
   if(!converted){
       ei_printf("Conversion failed\n");
       return false;
   }
    if ((img_width != EI_CAMERA_RAW_FRAME_BUFFER_COLS) || (img_height != EI_CAMERA_RAW_FRAME_BUFFER_ROWS)) {
        do_resize = true;
    }
    if (do_resize) {
        ei::image::processing::crop_and_interpolate_rgb888(
        out_buf,
        EI_CAMERA_RAW_FRAME_BUFFER_COLS,
        EI_CAMERA_RAW_FRAME_BUFFER_ROWS,
        out_buf,
        img_width,
        img_height);
    }
    return true;
}


static int ei_camera_get_data(size_t offset, size_t length, float *out_ptr)
{
    size_t pixel_ix = offset * 3;
    size_t pixels_left = length;
    size_t out_ptr_ix = 0;
    while (pixels_left != 0) {
        out_ptr[out_ptr_ix] = (snapshot_buf[pixel_ix + 2] << 16) + (snapshot_buf[pixel_ix + 1] << 8) + snapshot_buf[pixel_ix];
        out_ptr_ix++;
        pixel_ix+=3;
        pixels_left--;
    }
    return 0;
}


#if !defined(EI_CLASSIFIER_SENSOR) || EI_CLASSIFIER_SENSOR != EI_CLASSIFIER_SENSOR_CAMERA
#error "Invalid model for current sensor"
#endif

this is the code BUT the esp32-cam module doesn't work. I swear. It does WORK I mean but the camera does not take it's photo and analyze with my trained AI and I am so frustated... Just take the photo, analyze it and kaboom open the valve and let the problem be gone!

reddit.com

cA stupid arguement but I sometimes think that school shooters or similar criminals are right or that they are the result of the society's acts that they think it has no consequences.

Male / 19

The reason is that society became so ruthles, so unresponsible, so unkind and all that shit. They think that those people who killed people are just BORN evil but they don't realize people treat them wrong most of the time, their family or personal problems, bullying, even just accidently doing something, I mean they think that being mean does nothing to a person it just satisfies their ego but let me tell you, they don't forget that act. Or maybe I don't.

but maybe my opinion is wrong, I know that doesn't give the right to kill BUT thats the result. Of someone that cant keep this anymore.

If I had to be honest I used to be something similar to this, like my family got divorced when I was 11, I used to get bullied a lot and people always tried to pull me down. I never had aa clos one that I could trust or someone that could understand me. I was like 7/24 alert, maybe I did something wrong? what's gonna happen? etc.

at 15 I tried to... End all I must say but failed once, didn't try for the 2. time because of my girlfriend since her story is quite rough and I thought if I leave her, what if she gets too much hurt and cant keep it anymore?

Also I mean wish I had a great childhood where I didn't feel alone from 1. to 12th grade, I doN't know how I still got here.

I mean, maybe my life and other things I didn't write here is the reason why I think that my opinion is right. At the end of the day everything must have a reason behind or something like that.

reddit.com
u/Alone_Percentage7388 — 3 days ago

Is this tool great?

3 in 1 but looks like that the isolation is quite poor and not for 1000V...

Even though I'm 16 and I'm going to work somewhere where I'm going to install basic electrical stuff such as lights, sockets and similar. (Since I'm a internship student, borusan holding's highschool student.)

Well If this one is not good for the job due to its safety issues, I'll buy izeltaş then. (Turkiye's 1000V certified handtool company.)

I mean wish there was a model that had 3 in 1 and 1000V isolation

u/Alone_Percentage7388 — 9 days ago

3. Ay (1 ayda 5 kilo) müqimmel (önceden 9 ay kalistenik ama çok bişi elde edemedim ondan)

Fotoyu yakından çekseydim, neyse yeni başlayan olarak şunu anladım beyler

Ne kadar fazla kilo o kadar güçlüsün değildir

Yani hareket yanlış olduğu sürece anlamı yok.

Ego lifting yapmayın nedeni ben yaptım çok kötü hissediyorum.

Hareket düzgün olsun, yaparkene yavaş ve sabırlı yapın hızlı yağınca laktik asit kası skiyo ve yorulmuş kas, tendom ve az gelişme oluyor.

Beslenmede ek bilgi, fıstık ezmesi ve bal müqimmel tutuyor beni bu spora migros büyük olanda bal ve fıstık ezmesi karışık satılıyor 100 gramda 26 gram protein mükemmel eğlenceli ve çok güzel

u/Alone_Percentage7388 — 10 days ago
▲ 2 r/Epson

The iron barrel is full of something thats hard to get it off! Its really hard to scrape and what am I gonna do now?!

My god I hate printers...

u/Alone_Percentage7388 — 12 days ago
▲ 1 r/Epson

Epson 3251 paper problem.

Theres no paper inside or maybe a very small bit might be stuck inside but I am checking it from behind and forward and still no evidence... It feels like its just empty and its doing it on purpose. The ink is 50% already, the A4's I use is normal and I cleaned the inside! I mean not like unscrewing it I mean basicly just checking inside and getting the last paper bit but now all I got is just a empty printer with a paper feeding problem.

(edit) NOW ALL LIGHTS ARE SCREAMING AT ME I FUCKED IT UP NOOO

u/Alone_Percentage7388 — 12 days ago

45 kilo biceps de yapıyorum makinada ama bira zorlanıyorum. 3x10 daykene 2. veya 3. repde zarzor repi bitiryorum yada repi 2 ye bölüyorum. az kilo koyunca bana ağır koyuyor psikolojik olarak ya mesela adama bakıyorum aman tanrım 80 kilo nedir biceps resmen kütük. önceden vücudum hakkında çok dalga geçildiğinden (cılızlıktan) ve benzeri kişisel sorunlarımdan bana çok koyuyor bir genç olarak :( yani ne desem, ne yapmalıyım? yeni değilim ama öyle heybetli biriside değilim spor hakkında ama çok özgüvensizim canım spor salonuna bile gitmek istemiyor insanlar var diye. E evdede ağırlık yok oda sıkıntı ben ne yapacağım :(

reddit.com
u/Alone_Percentage7388 — 21 days ago