klimi
Oh ok sorry my first time
I mean if you have something you want to share in private, you can DM me, but i think it will have lower impact.
5iiii
My problem is my project is about yolov8 to auto select the moving car and draw a box for it ,but mouse can’t keep up with the moving car
5iiii
But static cars are normal.
Abbasi
If it works with static then the issue might be objects' life-time.
Chat Boss
5iiii sent a code, it has been re-uploaded as a quote class PIDController { public: PIDController(double sensitivity, double Ki, double Kd) : sensitivity(sensitivity), Ki(Ki), Kd(Kd), lastError(0), integral(0) {} void updatePosition(cv::Point2f& current, const cv::Point2f& target, double dt) { float errorX = target.x - current.x; float errorY = target.y - current.y; double pTermX = sensitivity * errorX; double pTermY = sensitivity * errorY; integral += (errorX + errorY) * dt; double iTermX = Ki * integral; double iTermY = Ki * integral; double dTermX = Kd * (errorX - lastError) / dt; double dTermY = Kd * (errorY - lastError) / dt; float moveX = static_cast<float>(pTermX + iTermX + dTermX); float moveY = static_cast<float>(pTermY + iTermY + dTermY); current.x += moveX; current.y += moveY; lastError = (errorX + errorY) / 2; } void setSensitivity(double newSensitivity) { sensitivity = newSensitivity; } cv::Point2f stabilize(const cv::Point2f& moveVector) { double errorX = moveVector.x; double errorY = moveVector.y; double moveX = sensitivity * errorX + Kd * (errorX - lastErrorX); double moveY = sensitivity * errorY + Kd * (errorY - lastErrorY); lastErrorX = errorX; lastErrorY = errorY; return cv::Point2f(moveX, moveY); } private: double sensitivity; double Ki, Kd; double lastError; double integral; double lastErrorX; double lastErrorY; }; static PIDController normalPid(sensitivity, 0, 0.5); // main 循環 if (mouseControlInitialized) { cv::Point2f currentPos(frame.cols / 2, frame.rows / 2); float maxDistance = frame.cols * currentFov / 2; bool hasValidTarget = (closest.x != -1 && closest.y != -1); if (hasValidTarget && !targets.empty()) { cv::Point2f targetPos(closest.x, closest.y); float distance = cv::norm(targetPos - currentPos); if (isAiming && autoAim && distance <= maxDistance) { cv::Point2f moveVector = targetPos - currentPos; // 使用 normalPid 進行穩定化 cv::Point2f stabilizedMove = normalPid.stabilize(moveVector); // 執行移動 if (abs(stabilizedMove.x) > 0.01 || abs(stabilizedMove.y) > 0.01) { control->SelectBox( static_cast<short>(stabilizedMove.x), static_cast<short>(stabilizedMove.y) ); } }
5iiii
My actual time is 1 a.m. I go to bed first and get up in the morning to reply. Sorry
consteval
If it works with static then the issue might be objects' life-time.
they likely meant 'static cars' as in 'cars that do not visually move'
Redeemer
Hey
Never Spam Bot
YA sent multiple messages that looks like a spam. Why was my message deleted? Spam deleted in this group: 2805
Natxo
Yesterday, Happy Birthday to Bjarne Stroustrup, inventor of C++: bit.ly/2E33g6O
Natxo
2025 is a mathematically perfect number. It is the square of the sum of the numbers in the decimal metric system: (1+2+3+4+5+6+7+8+9)² = (45)² = 2025 It is also the sum of the same numbers raised to the cube: (1³+2³+3³+4³+5³+6³+7³+8³+9³) = 2025 Have a perfect 2025, full of health and lots of 8-bit tinkering! HAPPY NEW YEAR!
You can't birader
Helo I'm also developer I make a website can anyone rate this
You can't birader
quotica . life
You can't birader
Please check
ⁱᵃᵐ|ýᥙ𝗴₂.₀⚡𒆜
Hy is anyone from india here who is coder/programmer/developer
Pavel
Hy is anyone from india here who is coder/programmer/developer
No, not from India, also for general questions/discussions not about C or C++ use the OT group
Pavel
#ot
Rose
#ot
Offtopic discussions should be done in the C/C++ Offtopic group. Please take your discussion/questions there.
Rose
Another one bites the dust...! Banned #𝐯𝐞𝐟𝐭𝐮. Reason: spam & abusive
Anunay
quotica . life
off-topic, please use the OT chat for such stuff
CELINCERS
Why ?
A
Program to print the reverse of a given array without using an extra array ? Anyone gimme some hints
Blue
Why is my message deleted which I asked on c++?
Pavel
Why is my message deleted which I asked on c++?
The antispam bot is quite dumb and can delete stuff randomly the first day
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
char *termcmd[] = {"xterm", "+sb", NULL}; char *roficmd[] = {"rofi", "-show", "run", NULL}; how can I make something like this in a config.h file and then import it in multiple files without errors?
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
what errors do you get?
multiple definition (I import config.h in several files)
Pavel
multiple definition (I import config.h in several files)
If it is C++, you can mark them as inline, if it is C, you need to define the values in the .c file and put the definitions with extern to the .h file
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
If it is C++, you can mark them as inline, if it is C, you need to define the values in the .c file and put the definitions with extern to the .h file
because I wanted to make something similar to this: https://git.suckless.org/dwm/file/config.def.h.html
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
so the user could change the values inside the config.h instead of doing it in the c file
Pavel
because I wanted to make something similar to this: https://git.suckless.org/dwm/file/config.def.h.html
Well, you can mark them static as well, but I wouldn't recommend that for big arrays, as that would create different instances in memory for each translation unit for what I know
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
so the best approach is to make them extern and modify everything in the config.c? but this is confusional, isn't it?
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
Why confusional, it is how global variables/constants are usually done
because if I need to customize my dwm config.h I only make edits in the config.def.h not in the config.c
Anonymous
Welcome
zakaria
I have a question in c++
Pavel
because if I need to customize my dwm config.h I only make edits in the config.def.h not in the config.c
If you have definitions in .c and want to change only the values, you would need to change them only in that one place. If you really-really want the values in .h and you can use only C, then I guess you can mark them as static and trying not to think about the memory overhead.
zakaria
I can't send messages !!
Never Spam Bot
zakaria sent multiple messages that looks like a spam. Why was my message deleted? Spam deleted in this group: 2826
Pavel
I have no idea how to make the bot not delete the messages, it should stop eventually I guess
FriedRice
Unordered map is overall a terrible implementation of a lookup table in almost all cases unless you need reference stability. If you do not need reference stability, use Google's dense hash map or Malte Skarupke's bytell hashtable
unordered map is easy to use and is simple enough to not introduce overhead, I recommend using it when you don't have specific requirements. what is reference stability?
FriedRice
It depends on your data set, if you have clustered data you probably want b+ tree instead of hash table.
Abbasi
because if I need to customize my dwm config.h I only make edits in the config.def.h not in the config.c
You can put the declaration in the header with extern and the definition in one translation unit. That way you will get better compile time and link time performance compared to using inline. As well as, you can make changes on those object(s) in the TU instead of modifying the header.
Abbasi
i made them static const char*cmd[] thanks
That way, there will be an independent const char* cmd[] in each TU where the header is included. That's different from using extern or inline.
Ludovic 'Archivist'
unordered map is easy to use and is simple enough to not introduce overhead, I recommend using it when you don't have specific requirements. what is reference stability?
Reference stability means: if a reference to an item in the map is taken, should that reference be invalidated by insertions or by the removal of other items in the map. The standard mandates that it must never be invalidated before either the removal of the item from the map or the destruction of the map. This however forces the implementation to be closed-addressing linked list chaining, which as terrible performance (a dense open addressing hashtable will be an order of magnitude faster at the same fill-rate)
Never Spam Bot
..... Malik sent multiple messages that looks like a spam. Why was my message deleted? Spam deleted in this group: 2829
Jojo
Considering to use c prime prime as a way through re-embarking on C, what you think?
Engine
Lang integration question: I know multiple ways to integrate C++ in python to maintain runtime speed, what is the best way to do that and why? Is there also a way to do the opposite (Write libs in python then use them in C or C++)?
Ludovic 'Archivist'
Lang integration question: I know multiple ways to integrate C++ in python to maintain runtime speed, what is the best way to do that and why? Is there also a way to do the opposite (Write libs in python then use them in C or C++)?
I do not see why you would do that, but I imagine integrating a python runtime in your application is a way to do it(?) the python runtime tends to be the one riding on C++ performance and not the other way around as python is notoriously slower than every programming language except Ruby
david
hi guys
Ludovic 'Archivist'
hi guys
nohello.net
david
well,ok then
Sarthak
Should I follow some website for practice if I am not a beginner or not an intermediate, like code chef, Leet code
MᏫᎻᎯᎷᎷᎬᎠ
Why std::string_view is normally passed by value when its sizeof returns 16 bytes (since it contains both the pointer and the size)
MᏫᎻᎯᎷᎷᎬᎠ
I mean it's better to just pass it by reference
MᏫᎻᎯᎷᎷᎬᎠ
It isn't
the size of the reference is 8 bytes
Vlad
Stack is preallocated and is free anyway
Vlad
All modern cpus have simd to copy 16 bytes in 1 cycle
Vlad
Even if you don't and it's 2 cycles
Vlad
It is definitely not a big deal
Vlad
Double de-referencing will be probably worse
MᏫᎻᎯᎷᎷᎬᎠ
What do you mean by the being being preallocated, I thought that the stack grows and shrinks with functions calls
Vlad
So allocating a variable is basically add ebp, 16
Vlad
Or whatever
MᏫᎻᎯᎷᎷᎬᎠ
OS already allocated 2 megabytes or so for your stack
So a stack frame with recursive call and std::string_view called 50 times will have extra 50x8 bytes for nothing
Vlad
If you do recursive calls like that it's your skill issue tbh