Blog Image

guivi

About the blog

In this blog I will keep track of projects I develop though out this year and may be in the future. For now it is juts a testing ground for developing the blog itself but I hope as I put more material it will become a good place for me to hold information.

Adding folder to Dll in Visual studio Win32 apps

C/C++ Programming, Visual Studio Posted on 08 Jan, 2021 22:19:01
  1. Go to project properties (Alt+F7)
  2. Under Debugging, look to the right
  3. There’s an Environment field.
  4. Add your relative path there (relative to vcproj folder) i.e. ..\some-framework\lib by appending PATH=%PATH%;$(ProjectDir)\some-framework\lib or prepending to the path PATH=C:\some-framework\lib;%PATH%
  5. Hit F5 (debug) again and it should work.


GUI Libraries For C++

C/C++ Programming Posted on 30 Dec, 2020 09:55:02

Qt
Sciter
wxWidgets
GTK+
gtkmm
CEGUI
Dear ImGui
Noesis GUI
Juce
Fox Toolkit
MiniGUI
Nuklear
NanoGUI
LittlevGL
neoGFX
morda
U++
dlib
nana
GWork
libui
Agar
FLTK
IUP
Boost.UI
LCUI
GLUI
TGUI
ivtools
GuiLite
Ultralight
Chromium Embedded Framework
CopperSpice
FlatUI
SFGUI
Lgi
Verdigris



Small program to stop the screen saver or screen blanking by moving cursor.

C/C++ Programming, Uncategorised Posted on 04 Sep, 2020 08:07:31
#include <iostream>
#include <windows.h>

bool iskeypressed(unsigned timeout_ms = 0)
{
    return WaitForSingleObject(
        GetStdHandle(STD_INPUT_HANDLE),
        timeout_ms
    ) == WAIT_OBJECT_0;
}

int main()
{
    POINT cursor;
    GetCursorPos(&cursor);

    std::cout << "Press any key to stop the program!\n";

    while (!iskeypressed(500)) {
        cursor.x += 10;
        SetCursorPos(cursor.x, cursor.y);
        Sleep(1000);

        cursor.x -= 10;
        SetCursorPos(cursor.x, cursor.y);
        Sleep(500);
    }

    std::cout << "Bye, Bye!\n";
    return 0;
}


Simple Server Socket C++

C/C++ Programming, Linux Posted on 01 Jun, 2020 12:01:41

This is a simple sever written in C++ and the original code can be found in “The definitive guide to Linux network programming” book.

#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>

const char APRESSMESSAGE[] = "APRESS - For Professionals, by Professionals!\n";

int main(int argc, char *argv[])
{
	int simpleSocket = 0;
	int simplePort = 0;
	int returnStatus = 0;
	struct sockaddr_in simpleServer;
	
	// make sure we va a port number
	if (argc != 2){
		fprintf(stderr, "Usage: %s <port>\n", argv[0]);
		exit(1);
	}
	
	// Create streaming socket
	simpleSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (simpleSocket == -1){
		fprintf(stderr, "Could not create a socket!\n");
		exit(1);
	}
	else {
		fprintf(stderr, "Socket created!\n");
	}
	// retrieve the port number for listing
	simplePort = atoi(argv[1]);
	
	// Set up address strucuter
	//use INADDR_ANY
	std::memset(&simpleServer, '\0',sizeof(simpleServer));
	simpleServer.sin_family = AF_INET;
	simpleServer.sin_addr.s_addr = htonl(INADDR_ANY);
	simpleServer.sin_port = htons(simplePort);
	
	returnStatus = bind(simpleSocket, (struct sockaddr*)&simpleServer, sizeof(simpleServer));
	
	if (returnStatus == 0){
		fprintf(stderr, "Bind Completed!\n");
	}
	else {
		fprintf(stderr, "Could not bid the address!\n");
		close(simpleSocket);
		exit(1);
	}
	// Listen on the socket for connection
	returnStatus = listen(simpleSocket, 5);
	
	if (returnStatus == -1){
		fprintf(stderr, "Cannot listen to socket\n!");
		close(simpleSocket);
		exit(1);
	}
	
	while(1) {
		struct sockaddr_in clientName = { 0};
		int simpleChildSocket = 0;
		socklen_t clientNameLength = sizeof(clientName);
		
		simpleChildSocket = accept(simpleSocket, (struct sockaddr *)&clientName, &clientNameLength);
		if (simpleChildSocket == -1){
			fprintf(stderr, "Cannot accept connections!\n");
			close(simpleSocket);
			exit(1);
		}
		
		write(simpleChildSocket, APRESSMESSAGE, strlen(APRESSMESSAGE));
		close(simpleChildSocket);
	}
	close(simpleSocket);
	return 0;
}


MFC C++

C/C++ Programming Posted on 04 Mar, 2020 10:23:27

Use DYNAMIC_DOWNCAST to get ribbon objects



OpenCV Aruco Marker Creator

C/C++ Programming Posted on 15 Nov, 2019 16:25:24

This is a link to generate Aruco markers controlling the size of the market in mm

http://chev.me/arucogen/



Simplest Color Balance

C/C++ Programming Posted on 14 Aug, 2019 17:11:06
void SimplestColorBalance(cv::Mat inArray, cv::Mat &outArray, int percent)
{
    if (percent<= 0)
    percent = 5;

    inArray.convertTo(inArray, CV_32F);
    int rows = inArray.rows;
    int cols = inArray.cols;
    int chnls = inArray.channels();
    double halfPercent = percent /200.0;
    std::vector<cv::Mat> channels;
    std::vector<cv::Mat> results;
    if (chnls == 3){
        channels.reserve(3);
        cv::split(inArray, channels);
    }
    else {
        channels.reserve(1);
        inArray.copyTo(channels[0]);
    }

    for (int i = 0; i < chnls; i++){
        cv::Mat flat;
        channels[i].reshape(1,1).copyTo(flat);
        cv::sort(flat, flat, cv::SORT_ASCENDING);
        double lowVal = flat.at<float>(0, floor(flat.cols * halfPercent));
        double topVal = flat.at<float>(0, ceil(flat.cols * (1.0-halfPercent)));
        cv::Mat channel = channels[i];
        for (int m = 0; m < rows; m++){
            for (int n = 0; n < cols; n++){
                if (channel.at<float>(m, n) < lowVal)
                    channel.at<float>(m, n) = lowVal;
                if (channel.at<float>(m, n) > topVal)
                    channel.at<float>(m, n) = topVal;
            }
        }
        cv::normalize(channel, channel, 0, 255, cv::NORM_MINMAX);
        //channel.convertTo(channel, CV_32F);
        results.push_back(channel);
    }
    cv::merge(results, outArray);
    outArray.convertTo(outArray, CV_8U);
}



MFC VfW

C/C++ Programming Posted on 19 Jul, 2019 16:49:05

http://www.orgler.it/webcam.htm



Next »