My Professional Profile

I am Johnson Augustine Sr.Software Engineer and System Architect. I have 10 Yrs of hands on expertise in ASP.net MVC 5 , Angular 5 , C# MVC Razor, WPF MVVM , Android , IOS Swift 3 , IOS11 MSSQL,MySQL Database,,PHP,C/C++/Visual C++/G++/QT++,Com,DirectX,Open CV,EMGU CV , embedded System Development , [Raspberry PI]. ,html,Javascript,Jquery,Ajax.CSS , Networking ,Cyber security, Ethical Hacking You can see my professional profile at http://linkedin.com/in/johnsontaugustine Email : johnsonaugustine@live.com

Friday, 26 April 2013

How to quit from an infinite loop in linux c/c++

How to quit from an infinite loop in linux c/c++ ?

To exit press Ctrl+z  to terminate the process

Thursday, 25 April 2013

Opening File and Reading Text file line by line in c++ streams and storing to the string array


Opening File and Reading Text file line by line in c++ streams and storing to the string array
int m_LineCount=0;
std::string m_Line[7];
std::ifstream m_Settings ("Settings.txt");
if (m_Settings.is_open())
{
while (m_Settings.good()) {
std::getline(m_Settings,m_Line[m_LineCount]);
std::cout<<m_Line[m_LineCount]<<"\n"<<"LineCount"<<m_LineCount;
m_LineCount++;
}
m_Settings.close(); // Closing the openned Txt settins file

Converting INT To String in C++


Converting INT To String in C++

std::string ConvertINTToString(int m_iValue)// Converting Integer to string
{
std::stringstream m_strStream;
std::string m_DateConverted;
m_strStream << m_iValue;
std::string m_strConverted(m_strStream.str());

return m_strConverted;
}

// ALL codes are created by Johnson Augustine

Date and Time in C++/Visual C++/Linux C++ GC++,C


void Get_Date_AndTime()
{
std::string line,m_strDate,m_strTime,m_ImagePathToDB;
int day,month,year,hour,min,sec;
// Getting time current time
time_t theTime = time(NULL);
struct tm *aTime = localtime(&theTime);
day = aTime->tm_mday;
month = aTime->tm_mon + 1; // Month is 0 - 11, add 1 to get a jan-dec 1-12 concept
year = aTime->tm_year + 1900; // Year is # years since 1900
hour=aTime->tm_hour;
min=aTime->tm_min;
sec=aTime->tm_sec;

m_strDate="";
m_strTime="";
m_strDate=m_strDate+ConvertINTToString(year)+"-"+ConvertINTToString(month)+"-"+ConvertINTToString(day);
m_strTime=m_strTime+ConvertINTToString(hour)+":"+ConvertINTToString(min)+":"+ConvertINTToString(sec);
}

// Format YYYY:MM:DD  TIME - HH:MM:SEC

Converting yuyv image to jpeg compressed format in c++


int compress_yuyv_to_jpeg (struct vdIn *vd, FILE * file, int quality)
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
JSAMPROW row_pointer[1];
unsigned char *line_buffer, *yuyv;
int z;
line_buffer = (unsigned char *)calloc (vd->width * 3, 1);
yuyv = vd->framebuffer;

cinfo.err = jpeg_std_error (&jerr);
jpeg_create_compress (&cinfo);
jpeg_stdio_dest (&cinfo, file);

cinfo.image_width = vd->width;
cinfo.image_height = vd->height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;

jpeg_set_defaults (&cinfo);
jpeg_set_quality (&cinfo, quality, TRUE);

jpeg_start_compress (&cinfo, TRUE);

z = 0;
while (cinfo.next_scanline < cinfo.image_height) {
int x;
unsigned char *ptr = line_buffer;

for (x = 0; x < vd->width; x++) {
int r, g, b;
int y, u, v;

if (!z)
y = yuyv[0] << 8;
else
y = yuyv[2] << 8;
u = yuyv[1] - 128;
v = yuyv[3] - 128;

r = (y + (359 * v)) >> 8;
g = (y - (88 * u) - (183 * v)) >> 8;
b = (y + (454 * u)) >> 8;

*(ptr++) = (r > 255) ? 255 : ((r < 0) ? 0 : r);
*(ptr++) = (g > 255) ? 255 : ((g < 0) ? 0 : g);
*(ptr++) = (b > 255) ? 255 : ((b < 0) ? 0 : b);

if (z++) {
z = 0;
yuyv += 4;
}
}

row_pointer[0] = line_buffer;
jpeg_write_scanlines (&cinfo, row_pointer, 1);
}
jpeg_finish_compress (&cinfo);
jpeg_destroy_compress (&cinfo);
free (line_buffer);
return (0);
}

link the library -ljpeg to work this code well ( Linux system)

Assigning std::string to Char * in c++

Converting std::string to Char * in c++

std::string str;
char *variable ;
strcpy(variable,str.c_str());