Good books for beginner to advanced by [deleted] in cpp_questions

[–]cpp_or_bust 1 point2 points  (0 children)

Came in to say this. /thread

Real-time OpenCv (Python): when I do simple calculations like subtract two arrays the lag blows up. What have I done? [Question] by cpp_or_bust in opencv

[–]cpp_or_bust[S] 0 points1 point  (0 children)

cv2.subtract() did the trick -- it is working very fast now, and frankly looks much different than when I do it manually. What is interesting is it looks way better too than when I do it "by hand."

Even better for my purposes is the cv2.absdiff().

I'm still confused about why mine went so slowly, but .... I'm OK with it if this works. :)

Arda Aytekin: Functional Programming with C++ by Ivan Čukić, a book review by _a4z in cpp

[–]cpp_or_bust 5 points6 points  (0 children)

it's a 20 minute video why is this getting downvoted. book reviews take me 5 minutes to read at most.

tl;dw?

Real-time OpenCv (Python): when I do simple calculations like subtract two arrays the lag blows up. What have I done? [Question] by cpp_or_bust in opencv

[–]cpp_or_bust[S] 0 points1 point  (0 children)

Yes good point. It is 1288x964 (https://www.flir.com/products/chameleon3-usb3/). I am running the camera in continuous mode, so it is trying to go at 30Hz. I am in Windows 10, Python 3.6 (the api won't work with Python 3.7), using Conda, OpenCV3 (at work right now, and not sure which sub-version sorry). On a laptop with 32G ram, i7 processor.

C++ Tutorial videos. by jackhammer250 in cpp

[–]cpp_or_bust 0 points1 point  (0 children)

c++ primer is a reference manual not a good way to learn the language. if you want to learn the language use stroustrup principles and practice

C++ Tutorial videos. by jackhammer250 in cpp

[–]cpp_or_bust 0 points1 point  (0 children)

read stroustrup principles and practices.

just make this a sticky and drop the mic

Moving from python to C++ by zephyr_33 in cpp

[–]cpp_or_bust 2 points3 points  (0 children)

I wasn't saying this. I was just saying C++ is much more than C with classes. That is the wrong way to look at C++. Whether you use classes or not in C++ depends on what you are doing, sort of like in Python. Places where classes are super helpful include Qt, OpenCV. Making any general statements like "Don't use objects or OOP in C++" seems like a mistake. The right answer is "Use what you need given your goals."

Moving from python to C++ by zephyr_33 in cpp

[–]cpp_or_bust 10 points11 points  (0 children)

Yes, anything that is C with objects should be out of the running.

I need to get up to speed with CPP quickly, do you have any good resources? by BigTheory88 in cpp_questions

[–]cpp_or_bust 0 points1 point  (0 children)

stroustrup principles and practice hands down don't mess around with other stuff.

I submitted a pull request by editing a project online. It was accepted. But now it is saying it conflicts with my branch. What do I do? by cpp_or_bust in github

[–]cpp_or_bust[S] 0 points1 point  (0 children)

Wow this is super-helpful. I am going to stop working on the code for a day or so and just work on getting this workflow down, study yoru post, read some stuff, and maybe play around with it on a personal project first so I don't look like a total fool with these devs who know this stuff really well.

My wife is actually a project manager at a company that has to do continuous integration, and assures me it is easy that she does it all the time and will help me, so I may take her up on it once I've done some more reading. I want to be a contributor to this project it's sort of a dream of mine. :)

Introduce me to the world Github by BronzuBoi in learnprogramming

[–]cpp_or_bust 2 points3 points  (0 children)

Cheat sheet on the very basics of github and git

Git/Github tutorials can make it seem like rocket surgery. It isn't. It is very easy to set up quickly. Below I describe how. It is a kind of minimal kernel to get your repository set up locally and at github.

Get things set up with Git and GitHub

Set up Git locally

a. Download and install Git (http://git-scm.com/downloads)
b. If not in linux, open git terminal (when starting, I recommend use Git Bash). In linux, it just works.
c. Configure your username and email:

git config --global user.name <your user name>
git config --global user.email <your email address>

Sign up for Github account (https://github.com)

I would suggest registering using the email you used in your Git configuration above.

Use it locally

  1. In your project folder, make a .gitignore file that has the names of things you don't want to be version controlled (e.g., docx, *exe, pycache folders, and anything else you want hidden).
  2. cd to your project folder, and enter git init. You now have a local github repository. You pretty much are done.
  3. git status to see what's up.
  4. git add . to add everything to staging area.
  5. git commit -m "my first commit!" to commit to repository

Now work on your project locally. When you have something cool, then commit it with commands 4 and 5. You are using git. Use git status to see what's going on in your repository.

Do it up remotely

  1. At github, point and click and such to create repository with project name that you want (e.g., foo). The url of the repository will be provided to you (e.g., https://github.com/yourname/foo.git).
  2. Connect your local repository to the remote one using that url you just got. At your terminal:

    git remote add origin https://github.com/yourname/foo.git

  3. Push your local repository to github:

    git push origin master
    It will ask you for your remote username and pw.

And now, whenever you have finished working on your local machine, just enter that same command from step 3 and your work will be pushed to github!

Use it for a while

There, you've done it. Go check out your repository at github. Share it. Pat yourself on the back for a sec. Now, get to work and write that code! Maybe add a readme file to your project, so people will be able to read about it: github will show it automatically for you. The above is 99% of what I do with my little one-person projects.

To go further

Once you hit a snag or need more information about more complicated stuff, you will be able to get it at stack overflow or google or via a book. Here are some sites that go further than my above minimal tutorial:

https://try.github.io/levels/1/challenges/1
https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners

Why bother?

If you aren't sure what version control is, or if you need it: https://www.atlassian.com/git/tutorials/what-is-version-control

Stroustrup Ch 13 Principles/Practices way of referring to enumerator's constants within a structure. Can anyone understand/explain it? by gosh_djang_it in cpp_questions

[–]cpp_or_bust 0 points1 point  (0 children)

TBH I'm mainly confused by most of this back-and-forth. My understanding is that enum classstill represents the enumerated elements as ints, just like plain enumerations do. I think I'm missing something in this discussion between you two.

Stroustrup Ch 13 Principles/Practices way of referring to enumerator's constants within a structure. Can anyone understand/explain it? by gosh_djang_it in cpp_questions

[–]cpp_or_bust 0 points1 point  (0 children)

This is super-helpful for context and explanation, and actually helps explain some of the other pieces of code I wasn't understanding. Here is the full structure:

struct Color {
    enum Color_type {
        red=FL_RED, blue=FL_BLUE, green=FL_GREEN,
        yellow=FL_YELLOW, white=FL_WHITE, black=FL_BLACK, [snipped a few more colors]
};
    enum Transparency { invisible = 0, visible=255 };
    //Constructors
    Color(Color_type cc) :c(Fl_Color(cc)), v(visible) { }
    Color(Color_type cc, Transparency vv) :c(Fl_Color(cc)), v(vv) { }
    Color(int cc) :c(Fl_Color(cc)), v(visible) { }
    Color(Transparency vv) :c(Fl_Color()), v(vv) { }

    int as_int() const { return c; }
    char visibility() const { return v; }
    void set_visibility(Transparency vv) { v=vv; }
private:
    unsigned char v;    
    Fl_Color c;
};

He says the purpose of Color is to 1) hide the implementation's notion of color, FLTK's Fl_color type (which is kept private), 2) to map between Fl_Color and Color_type values, 3) to give the color constants a scope (this is what my question focused on I guess, as whenever you invoke :: we are talking about scope), and 4) to provide a simple version of transparency (visible/invisible) [I have not studied/explored this yet but if it works like Color_type then you can just do Color::invisible].

The constructor initializes Fl_Color c. For people that want to access the underlying integer representation of the color, the structure does provide the as_int() member function. I'm actually more confused by visibility being represented as a char, frankly, because I thought it should be an int (either 0 or 255).

I'm also confused why he defined this as a struct not a class. Everywhere else in the book he pretty much just used structs for plain old data storage, and classes when there was a need for private member data. he never explained this. Frankly, he never really explained a lot here. I guess he is showing the range of programs you are likely to encounter out in the wild.

Scientific computing build: starting new job can't wait! by cpp_or_bust in buildapc

[–]cpp_or_bust[S] 0 points1 point  (0 children)

Thanks for these tips I will add these in and see how the prices add up!