Upload 3 files
Browse files- TPLINK_TL_WR940N.7z +3 -0
- drone-rf.zip +3 -0
- processs.m +105 -0
TPLINK_TL_WR940N.7z
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4170dcdc88524335c251c9b37753da5d0f44a7d01ee46e5f6e961828c959aa8
|
| 3 |
+
size 1164393407
|
drone-rf.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:08931ed4cfe8919f036b30083d260da91e3944f0d746c7ba8ac2db1bf2b82d6f
|
| 3 |
+
size 1452052853
|
processs.m
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
clc; clear; close all;
|
| 2 |
+
|
| 3 |
+
%% 1. CẤU HÌNH ĐƯỜNG DẪN & THAM SỐ
|
| 4 |
+
input_folder = "E:\uav_detect\drone-rf\DAUTELEVONANO"; % Folder chứa file .iq
|
| 5 |
+
output_root = "E:\uav_detect\drone-rf\DAUTELEVONANO"; % Folder tổng chứa kết quả
|
| 6 |
+
|
| 7 |
+
% --- Global Scale (CỐ ĐỊNH CHO CẢ TẬP) ---
|
| 8 |
+
GLOBAL_MIN_DB = -120; % Mức sàn nhiễu (Nền Xanh)
|
| 9 |
+
GLOBAL_MAX_DB = 50; % Mức tín hiệu (Đỏ)
|
| 10 |
+
|
| 11 |
+
% --- Tham số STFT ---
|
| 12 |
+
fs = 100e6;
|
| 13 |
+
duration_ms = 30;
|
| 14 |
+
overlap_time = 0.5;
|
| 15 |
+
|
| 16 |
+
nfft = 1024;
|
| 17 |
+
window = hamming(3072);
|
| 18 |
+
spec_overlap = nfft/2;
|
| 19 |
+
cmap = colormap(jet(256));
|
| 20 |
+
|
| 21 |
+
% Tính toán kích thước cắt
|
| 22 |
+
samples_per_image = round(fs * (duration_ms / 1000));
|
| 23 |
+
step_size = round(samples_per_image * (1 - overlap_time));
|
| 24 |
+
bytes_back = (samples_per_image - step_size) * 8;
|
| 25 |
+
|
| 26 |
+
%% 2. QUÉT FILE TRONG FOLDER
|
| 27 |
+
% Tìm tất cả file .iq trong folder drone-rf
|
| 28 |
+
file_pattern = fullfile(input_folder, 'pack1_*.iq');
|
| 29 |
+
file_list = dir(file_pattern);
|
| 30 |
+
|
| 31 |
+
if isempty(file_list)
|
| 32 |
+
error('Không tìm thấy file .iq nào trong folder "%s"', input_folder);
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
% Tạo folder output gốc nếu chưa có
|
| 36 |
+
if ~exist(output_root, 'dir')
|
| 37 |
+
mkdir(output_root);
|
| 38 |
+
end
|
| 39 |
+
|
| 40 |
+
fprintf('Tìm thấy %d file trong "%s".\n', length(file_list), input_folder);
|
| 41 |
+
fprintf('Scale áp dụng: [%d dB, %d dB]\n', GLOBAL_MIN_DB, GLOBAL_MAX_DB);
|
| 42 |
+
|
| 43 |
+
%% 3. BẮT ĐẦU XỬ LÝ HÀNG LOẠT
|
| 44 |
+
% Mẹo: Nếu máy mạnh, đổi "for" thành "parfor" để chạy song song (nhanh gấp 4-8 lần)
|
| 45 |
+
for k = 1:length(file_list)
|
| 46 |
+
|
| 47 |
+
% Lấy tên file và đường dẫn đầy đủ
|
| 48 |
+
current_filename = file_list(k).name;
|
| 49 |
+
full_path = fullfile(file_list(k).folder, current_filename);
|
| 50 |
+
|
| 51 |
+
% Tạo folder con: dataset_spectrograms/spectrogram01, 02...
|
| 52 |
+
sub_folder_name = sprintf('spectrogram%02d', k);
|
| 53 |
+
output_dir = fullfile(output_root, sub_folder_name);
|
| 54 |
+
|
| 55 |
+
if ~exist(output_dir, 'dir')
|
| 56 |
+
mkdir(output_dir);
|
| 57 |
+
end
|
| 58 |
+
|
| 59 |
+
fprintf('--> [%d/%d] Đang xử lý: %s >>> Lưu vào: %s\n', ...
|
| 60 |
+
k, length(file_list), current_filename, sub_folder_name);
|
| 61 |
+
|
| 62 |
+
% Mở file
|
| 63 |
+
fid = fopen(full_path, 'r');
|
| 64 |
+
if fid == -1
|
| 65 |
+
warning('Lỗi mở file %s', full_path);
|
| 66 |
+
continue;
|
| 67 |
+
end
|
| 68 |
+
|
| 69 |
+
fseek(fid, 0, 'eof'); file_size = ftell(fid); fseek(fid, 0, 'bof');
|
| 70 |
+
img_count = 0;
|
| 71 |
+
|
| 72 |
+
% --- VÒNG LẶP CẮT ẢNH ---
|
| 73 |
+
while ~feof(fid)
|
| 74 |
+
img_count = img_count + 1;
|
| 75 |
+
|
| 76 |
+
raw_data = fread(fid, [2, samples_per_image], 'float32');
|
| 77 |
+
if size(raw_data, 2) < samples_per_image
|
| 78 |
+
break;
|
| 79 |
+
end
|
| 80 |
+
|
| 81 |
+
% Xử lý tín hiệu
|
| 82 |
+
iq_chunk = complex(raw_data(1,:), raw_data(2,:));
|
| 83 |
+
[s, ~, ~] = spectrogram(iq_chunk, window, spec_overlap, nfft, fs, 'centered');
|
| 84 |
+
mag = 20*log10(abs(s) + eps);
|
| 85 |
+
|
| 86 |
+
% --- CHUẨN HÓA GLOBAL ---
|
| 87 |
+
mag(mag < GLOBAL_MIN_DB) = GLOBAL_MIN_DB;
|
| 88 |
+
mag(mag > GLOBAL_MAX_DB) = GLOBAL_MAX_DB;
|
| 89 |
+
mag_norm = (mag - GLOBAL_MIN_DB) / (GLOBAL_MAX_DB - GLOBAL_MIN_DB);
|
| 90 |
+
|
| 91 |
+
% Tạo ảnh màu RGB
|
| 92 |
+
img_rgb = ind2rgb(gray2ind(mag_norm, 256), cmap);
|
| 93 |
+
|
| 94 |
+
% Lưu file (Quality 95 để giữ chi tiết cho SAHI)
|
| 95 |
+
fname = sprintf('seq%02d_%05d.jpg', k, img_count);
|
| 96 |
+
imwrite(img_rgb, fullfile(output_dir, fname), 'Quality', 95);
|
| 97 |
+
|
| 98 |
+
% Lùi đầu đọc (Overlap)
|
| 99 |
+
fseek(fid, -bytes_back, 'cof');
|
| 100 |
+
end
|
| 101 |
+
|
| 102 |
+
fclose(fid);
|
| 103 |
+
end
|
| 104 |
+
|
| 105 |
+
fprintf('\n=== HOÀN TẤT! KIỂM TRA FOLDER "%s" ===\n', output_root);
|