C :: Edge Detection Done Using Processes And Pipes

Nov 30, 2014

I don't think my processes are being created the way I want. I'm trying to create a fan of process (i.e. one parent with multiple children).

I want the parent to put together the final output image, and the children are supposed to do the edge detection on various regions of the image. Here is what I have:

Code:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "iplib2New.c"
#define FILTER_SIZE 3
//Function prototypes

[Code] ......

View 10 Replies


ADVERTISEMENT

C :: Pipes Between Child Processes

May 5, 2014

I wrote a C program that is supposed to create a certain number of child processes, each child process having to change 1 letter from a string. The string and the number of child processes are read from the keyboard. I want to do it using pipes.

It should work like this: The parent changes one letter, then the first child takes the string modified by the parent and changes one more letter. The second child takes the string modified by the first one (2 letters are already changed) and changes one more and so on. I am new to C and am not quite sure how it all works, especially pipes. Also can the children be linked between them through the pipe, or can they only be linked to the parent and it has to be something like: first child changes a letter, gives the string back to the parent and then the second child reads from there, modifies letter and gives back.

If it's like that, is there any way to make sure that this doesn't happen: Apples becomes AppleD and then AppleX and then AppleQ? For example:

Code:
Input: Apples
Output: Applex Appldx Aqpldx My problem is: I don't get any output from the children.

Here's my code:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
#include <sys/wait.h>

[Code] .....

View 2 Replies View Related

C/C++ :: Two Way Communication Between Child And Parent Processes (pipes)

Mar 19, 2014

I want parent and child processes to communicate in C linux using pipes. I have created two file descriptors. one for parent to child i.e. readpipe and other writepipe for viceversa. But I am getting null as output for ch and ch1 strings in my code below.

#include <stdio.h>
#include<stdlib.h>
#include
#include<unistd.h>
int main(){
pid_t pid;

[Code] .....

View 1 Replies View Related

C++ :: Writing To 2D Array Of Pipes In Child Process

Apr 15, 2014

I am writing a program that is supposed to open a directory as a command line argument, read that directory, open each file and count a number of occurrences of a certain character, taken from the user as cin, fork the parent process to create a child process for each file. a pipe is created for communication with the parent and a 2 dimensional array of pipes is needed for communication with each child process (each file), one for the pipe number and the other is the read/write descriptor(0 or 1). My program is looping through all the files ok, but it seems it isn't writing the "char a" to the pipe correctly. f

For every child, do_child_stuff() is called, and it reads the file name, opens it, counts the # of occurrences and returns that count to the parent to hold a total for all the files. normally to write to a pipe, it should be write(pipe_name[1], &a, sizeof(a)) but I don't know how to do this with an array of pipes. i try to write to it by doing write(child_pipe[pc][1], &a...) pc is the array position for that pipe and it gets incremented after reading each file.

struct dirent *d;
struct stat sb;
int adult_pipe[2];
int child_pipes[1000][2];

[Code]....

View 5 Replies View Related

C++ :: Shared Memory Between Processes

Apr 13, 2014

Say now I have a dll, loaded and run by a 32bit program. One of the things that I access from the program in the dll are several 1024x1024 int buffers. However I would like to put some data into those buffers from a external process. And I would like a separate thread in that external process for each buffer. Is there any way I can make that memory space accessible to the external process so I can use my own multi threaded memory transfers to pass that data over provided I ensure that the original process doesn't try to do anything with that data? And I would like to do this without resorting to the Read/WriteProcessMemory functions which are not threadsafe. In short, I want to set up direct memory access between the 2 programs without creating any intermediate shared memory buffers ie I want to set permissions for an existing memory space. Is this possible?

View 1 Replies View Related

C++ :: Implement Bidirectional Communication Between Two Processes?

Mar 29, 2012

I have two command line apps, one of them is multithreaded. I need to implement a bidirectional communication between them. Currently I can do

Code:
ProgramA 1> ProgramB

for the first programA to direct output into ProgramB, however I also need ProgramB to send messages to ProgramA.

how to implement it in a easiest way.

btw, I am on Ubuntu. I'd rather not to use third party libraries, Boost, etc.

View 7 Replies View Related

Visual C++ :: Getting A List Of Active Processes?

Apr 14, 2015

how to get a list of the active processes on a computer?

What I need to do is check for a specific process to see if it's running on the system.

I just need to know if a certain process is present.

View 1 Replies View Related

C++ :: Showing All Running Processes Like In Task Manager

Oct 7, 2014

I want to show all running processes of windows.

my motive is whenever any running process closes/quits whether it be console or window based on windows it notify(s) me or user that some .exe has been closed.

View 1 Replies View Related

C :: Create 9 Child Processes And Eventually Write From Each Process To Another?

Nov 18, 2013

I want to create 9 child processes and eventually write from each process to another. How can I specifically create 9 child processes and leave them running? Right now, I am using a loop from i=0 to i=8 and running fork() within that loop, but each child process also runs the loop, which spawns dozens (maybe hundreds?) of processes. I specifically only want to create nine of them. How can I do this?

Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>

[Code].....

View 7 Replies View Related

C/C++ :: Using Semaphores On Critical Region - Processes Not In Correct Order

Mar 2, 2014

I'm trying to use semaphores on three different processes so that each process won't enter the critical region at the same time and also go in the order: process 1 -> process 2 -> process 3. However, everytime i run the code the process 3 keeps going before process 2.

Here's my code:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>

[Code].....

the processes should print out like this:

process 1: 100000
process 2: 300000
process 3: 600000

View 1 Replies View Related

C/C++ :: Shared Memory Project Not Getting Accurate Count For Processes

Jan 30, 2014

I'm working on a project that is supposed to create 3 processes. Process 1 should count from 1 to 100,000. Process 2 from 1 to 200,000. Process 3 from 1 to 300,000. I've written the basic code of it but my processes aren't printing out very accurate numbers.

Here's my code:

/*ass1*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <unistd.h>
/* change the key number */
#define SHMKEY ((key_t) 8450)
typedef struct

[code]....

View 4 Replies View Related

C++ :: USB Printer Detection?

May 16, 2014

take a look at this project : [URL] i want to change this project for this purpose : when a USB PRINTER is connected show a message that tell us -> hey this is a printer. which part of this project should i change and how can i separate printer devices from the others?

note: if you are using visual studio 2010 or higher and get error for this line after conversion :

#define _WIN32_WINNT 0x403

just replace all of such these lines to stdafx.cpp file. means stdafx.cpp at last should be like this :

// stdafx.cpp : source file that includes just the standard includes
// HWDetect.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#define _WIN32_WINNT 0x403
#include "stdafx.h"

View 1 Replies View Related

C++ :: Map Collision - Camera Detection

Jan 20, 2015

Still working with SDL2 and c++ my map collision is messed up since I implemented my Camera.

I do understand that everything has a relative Position on the Screen, depending on the camera.

Problem No. 1: The camera is not moving as fast as the Player, despite having the absolutly same velocity (4/-4)??? How can this be O_o

Problem No. 2: My tile collision is totally messed now. Probably its because of the difference between the Player Position and the camera :/ So if you can solve Problem no. 1, Problem number 2 might work out on its own :)

I will upload the code to github [URL] .....

View 11 Replies View Related

C# :: Algorithm For Plagiarism Detection

Mar 21, 2015

I actually want some latest algorithms, methods or techniques which can be used in plagiarism detection software for detecting the text plagiarism offline.

View 4 Replies View Related

C++ :: Detection Of Integer Values?

Jun 23, 2013

i am having trouble finding a way to detect integers from an external text file. i currently have this code:

while(inputfile.get(wc))
{
char character = inputfile.get(wc);
if (character + 1 != NULL)
{
cout << character << endl;
}
}

this does not work as if (character + 1 != NULL) comes up with errors.

is there a way to detect ints?

View 3 Replies View Related

C++ :: 2D Platformer Collision Detection?

May 4, 2013

I've been working on my 2D platformer for a while, and I'm running into a couple of problems. It seems to become laggy even when only about 25 entities need to do collision detection with the 8 walls in the area.

Only one thing to note: the BOOST_FOREACH(const Edge& edge, this->GetCollisonBoxEdges()) { sections actually aren't a loop, all players and enemies are basically a vertical line for purposes of hitting walls, so that's why there is some weird stuff in there (like assuming the edge is oriented a certain way, etc).

Asset::WallCollision Asset::GetClosestWallCollision(const std::vector<const Room::Wall*>& walls) const {
typedef std::pair< sf::Vector2<CoordT>, sf::Vector2<CoordT> > Edge;
const Room::Wall* wall_hit = NULL, * landing_wall = NULL;
util::intersect_ret temp, closest;
VelocityT para_vel;
if(this->m_StandingOn) para_vel = this->m_StandingOn->get_unit_parallel_vector() * this->mVelocity.x;
else para_vel = this->mVelocity;

[code].....

View 3 Replies View Related

C++ :: Repeated Word Detection Program?

Mar 6, 2015

In the C++ book Programming: Principles and Practice Using C++, there's an example code like this for detecting repeated words:

Code:
#include "std_lib_facilities.h"
int main() {
int number_of_words = 0;
string previous = " "; // previous word; initialized to "not a word"
string current; // current word
while (cin >> current) // read a stream of words

[Code].....

The header file in there is sort of like a set of training-wheels for students who are complete beginners to the language; the function keep_window_open() is defined in there and it does just that on Windows systems where the output window closes too fast (in the case of the function, it's just like cin.ignore(), except it waits for you enter a character, like 'j', before it exits); programs on my Windows laptop work fine on Code::Blocks, but when I create a .exe file for them and double-click that file, it does actually close too quickly for me to be able to see the output (if it's a program like the generic "Hello World!" program that just outputs text to the screen and then exits - so all I see is the output window just flash-by really fast in those cases).

Anyway, as for the problem I'm having with the code: there are no error and compile- or link-time, but it does behave strangely at runtime, where the part inside the curly-braces of the while-loop doesn't execute at all.

View 3 Replies View Related

C :: Simple Deadlock Detection Program

May 1, 2013

I'm trying to write a program that detects deadlock. Some of the code I already tested in an earlier stage but at this point when I run the code it somehow gets stuck. I believe that it has something to do with a negative integer value. Anyhow, the program should still work if a negative integer comes up. Here's my code so far.

Code:

#include <stdio.h>
#define FALSE 0
#define TRUE 1
int ALLOC[5][5], REQ[5][5], TOT_RES[5], process, resource, NUMB_RES=5, NUMB_PRO=5;
int TMP[5]={0}, AVAIL[5], CNTR=0, FIN[5]={FALSE}, FLAG;
}

[code]....

The program usually gets stuck after producing output displaying the "Available: " text. After that a list of tabbed numbers should appear, but it doesn't.

View 4 Replies View Related

C++ :: SDL - Tile Based Collision Detection

Oct 14, 2014

I'm still working on my Project and the next Problem has occured: How do I detect collisions on a tilebased map? My tiles are 16x16 and the map is based on the tutorial of [URL] ..... I really like this Approach because I can define for each tile of what type it should be (so a earth tile can be walkable and lead to a secret passage).

The first Number stands for what Kind of tile it should be (e.g. Grass, Earth, Water, Blank,...) and the number after ":" stands for the type of the tile (e.g. solid, walkable, do dmg to the Player,...).

e.g.
0:0 0:0 0:0 0:0 0:0 //No tile and walkable
0:0 0:0 0:0 0:0 0:0
0:0 0:0 0:0 0:0 0:0
1:1 1:1 1:1 1:1 1:1 //Grass tile and solid
2:1 2:1 2:1 2:1 2:1 //Earth tile and solid

It's working just fine with loading the Images, but i've got no clue about the collision. I've already read a lot of stuff on the Internet but I don't get how to Combine it the structure from above. For example lazyfoo describes the collision with one object like one wall. So how can I check the Player Position with each tile?

For now there's no camera, but I plan to implement one later...

I'm trying to make a 2D platformer

View 5 Replies View Related

C++ :: Implementing Collision Detection Correctly

Sep 10, 2014

I'm making a 2D Terraria-like (side-scrolling RPG with destroyable blocks) game with SFML 2.1, and I have no clue how to correctly implement collision detection. Meaning that I have been successful at making it work, but it's not clean and definitely not dynamic.

By example, I mean design wise. What parameters should collision functions take? Where should these functions be located? The same 2 questions for collision reaction. Since I have multiple things that need to collide with each other (player with enemy, player with items, enemy with items, enemy with enemy, player with player, etc...), and the world has to be treated differently, things get complicated. There is no block class, just a vertex array, so collision with the world is based purely on coordinates taken from that array in the world class, which, considering it's the world and not something like a player or an enemy, doesn't inherit from the same base class that they do.

View 7 Replies View Related

C# :: EMGU - Small Symbol Detection

Sep 16, 2014

I am trying to find the best way to detect a small symbol such as :

Just for testing features I tried to load these into SURF example that comes with EMGU and it does not pick it up... And I think the technology used for SURF is better for objects with more details and color gradients...

View 8 Replies View Related

C :: Redirecting Multiple Pipes With Multiple Children

Mar 21, 2014

I've been working on a function that works like a pipeline of a shell but receives a directory, go over it an search for every file to send it to a filter, something like this in bash "cat dir/* | cmd_1 | cmd_2 | ... | cmd_N", The only problem i have with the code is the redirection of the pipe descriptors.

Code:

int main(int argc, char* argv[]){
char** cmd;
int Number_cmd;
cmd = &(argv[2]); /*list of cmds*/
Number_cmd = argc-2; /*number of cmds*/
}

[code]....

The code is seems to work fine except when i run it with more than one command in example ("./filter DIR wc rev") in this case it returns

wc: standard input: Bad file descriptor
wc: -: Bad file descriptor
0 0 0

View 2 Replies View Related

C :: Numbers Detection In Input - Segmentation Fault

Oct 29, 2014

I need to distinguish between number (float) and other non number characters. I was trying to use this:

Code:
#include <stdio.h>
#include <ctype.h>

float Ax;
...
scanf("%f
",&Ax);
if (isdigit(Ax)) {....}

And whatever I type I receive "Segmentation fault". How can I detect that the float input is correct? Is there any built in function?

View 7 Replies View Related

C/C++ :: Find Number Of 1 In Array For Error Detection

Mar 24, 2015

I'm receiving a char array consist of 8 characters, what I want to do is find the number of set bits in that array and then send it(total number) as a character to the transmitter so he can check, data is transmitted using serial port(RS232), where processing of data is done by DE0 FPGA.I've tried to use TestBit but the compiler doesn't know this function(I added #include "bit-manipulation.h" but it doesn't recognize this either) ...

-- the code of my project:

filed = open( "/dev/uart_0", O_RDWR );
if (filed < 0){
printf("the port can't be opened
");

[Code] .....

View 1 Replies View Related

C Sharp :: Physically Connected Printers Detection?

Oct 24, 2012

How do I get the printer connected with my computer physically using cables?

View 2 Replies View Related

Visual C++ :: Low-Level Keyboard Input Detection?

Mar 13, 2014

I am writing an software that should be able to detect all keyboard inputs by the user. i.e., both hardware and software/on-screen keyboard.

This software is going to be written in a platform independent way and supposed to run on Windows, Linux, Android & iOS.

The idea is to capture the keyboard inputs from a low level, there by making sure that it doesn't miss any inputs even if it's a on-screen keyboard like in a mobile device.

I am looking at possible open source libraries that can be used.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved