Compare commits

..

4 Commits

5 changed files with 58 additions and 1 deletions

View File

@ -3,7 +3,7 @@
## Other ## Other
- [seconds_to_minutes_and_hours.c](seconds_to_minutes_and_hours.c) - Преобразование секунд в минуты и часы - [seconds_to_minutes_and_hours.c](seconds_to_minutes_and_hours.c) - Преобразование секунд в минуты и часы
- [get_ram_usage.c](get_ram_usage.c) - Получение используемой приложением RAM
## SQLite 3 ## SQLite 3
- [CREATE TABLE](sqlite/sqlite3_create.c) - [CREATE TABLE](sqlite/sqlite3_create.c)

23
code/C/disk_usage.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <sys/statvfs.h>
#define PATH "/media/user/Samsung USB"
int main(int argc, const char *argv[]) {
const unsigned int GB = (1024 * 1024) * 1024;
struct statvfs buffer;
int ret = statvfs(PATH, &buffer);
if (!ret) {
const double total = (double)(buffer.f_blocks * buffer.f_frsize) / GB;
const double available = (double)(buffer.f_bfree * buffer.f_frsize) / GB;
const double used = total - available;
const double usedPercentage = (double)(used / total) * (double)100;
printf("Total: %f --> %.0f\n", total, total);
printf("Available: %f --> %.0f\n", available, available);
printf("Used: %f --> %.1f\n", used, used);
printf("Used Percentage: %f --> %.0f\n", usedPercentage, usedPercentage);
}
return ret;
}

11
code/C/get_ram_usage.c Normal file
View File

@ -0,0 +1,11 @@
#include <sys/resource.h>
#include <stdio.h>
int main() {
struct rusage r_usage;
getrusage(RUSAGE_SELF, &r_usage);
printf("Memory usage: %ld kilobytes\n", r_usage.ru_maxrss);
return 0;
}

9
code/SFML/appIcon.cpp Normal file
View File

@ -0,0 +1,9 @@
// ...
auto image = sf::Image{};
if (!image.loadFromFile("cat.png"))
{
// Error handling...
}
window.setIcon(image.getSize().x, image.getSize().y, image.getPixelsPtr());
// ...

View File

@ -0,0 +1,14 @@
#include <SFML/Graphics.hpp>
#include <opencv2/opencv.hpp>
sf::Texture getTextureFromCvFrame(cv::Mat frame) {
cv::Mat frameRGBA;
sf::Image image;
sf::Texture texture;
cv::cvtColor(frame, frameRGBA, cv::COLOR_BGR2RGBA);
image.create(frameRGBA.cols, frameRGBA.rows, frameRGBA.ptr());
texture.loadFromImage(image);
return texture;
}