C++ :: Creating Databases And Indexing One Image Per Database - Multithreading Synchronization

Nov 1, 2013

My below code is createing databases(database here is a kd tree) and indexing one image per database. I have two classes LastDatabaseTndexingPolicy and another forwardingDatabaseaccessor.cpp .

I am calling the GetDatabaseToAccess() function from forwardingDatabaseAccessor.cpp class .GetDatabaseToAccess() function is present in LastDatabaseTndexingPolicy class and it returns the database created as a pointer and using that database pointer we call another function which actually indexes the image to the database .

Now my issue is i am not able to have multiple threads act on the following functions as DatabaseAccessor_ptr db which is in the following file is coupled with two functions and however i put locks in the LastDatabaseTndexingPolicy file as below i end up getting synchronization issue ..........

Hence now i am using a single lock in forwardingDatabaseAccessor.cpp and serializing the code,. How can i change my design to parallelize this code .........

In ForwardingDatabaseAccessor.cpp we are calling function from LastDatabaseTndexingPolicy as shown below:-

DatabaseAccessor_ptr db is something which needs to be synchroinized. I tried createing 256 databases with one image each and when i run this code i ended up creating 175 databses and though i was restricting in code with locks that every database has only one image i ended up having two images in single database ..... ideally i had to get only one image per database but i got two images in few of them hence instead of 256 database this code created 175 or so databases.

indexing::IndexReturnValue ForwardDatabaseAccessor::index(cv::Mat image,
const std::string& imageName, features::Camera::Type indexCameraType,
features::Camera::Type recogCameraType) {
DatabaseAccessor_ptr db = this->IndexingPolicy_ptr->GetDBToIndex();

[Code] .....

View 1 Replies


ADVERTISEMENT

C# :: Best Way To Store And Load Image Into Access Database?

Dec 12, 2014

I have:

An Access database in which the picture right now is saved by its directory, together with other field like title, publisher, developer,..

Visual Studio form in which a load button gets that directory as text

Details button that reads the ID of a selected item (I have a list of games) and displays the corresponding picture by reading the directory

The problem right now is that once someone else opens the program on his/her computer, the directory changes, making the whole thing useless.

Is there a way to get around this problem? The books I've been reading don't really adress this.

Directory is a string in class 'Game'; it's short text in the database

private void buttonFoto_Click(object sender, EventArgs e) {
LoadNewFile();
}
private void LoadNewFile() {
OpenFileDialog ofd = new OpenFileDialog();

[code].....

View 9 Replies View Related

C# :: Retrieve Image From Database And Display In Picturebox

Sep 18, 2014

I am creating an employee details project, the image is getting stored in the database but i am not able display it in the picture box.

private void button1_Click(object sender, EventArgs e) {
SqlConnection con = new SqlConnection(Connectionstring);
con.Open();
SqlCommand cmd = new SqlCommand("select photo from emprecordtable where eid='"+comboBox1.Text+"'", con);
//SqlDataAdapter da = new SqlDataAdapter(cmd);
//DataSet ds = new DataSet();

[code] ....

In sql server i have table called emprecordtable and i have the fields eid, rfid, empname, designation, phno, addres, and photo which is the image field and i have given the datatype as image but in the database the image is getting stored as Binary Data.. So, how to display in the picturebox from the database.

View 11 Replies View Related

Visual C++ :: How To Insert And Read Image From Database (SQL Server) Using MFC

Jan 25, 2015

How to insert and read images to/from database (sql server) using MFC ?

View 5 Replies View Related

Visual C++ :: Synchronization Objects In MFC?

Jul 16, 2013

I want to understand synchronization objects in MFC in detail. I want to understand Mutex / Semaphores / Events / Critical Section in detail....How to use implement and use in practical examples.

View 12 Replies View Related

C :: Creating PPM Image - Black Rectangle With A Circle

Mar 12, 2013

I'm trying to create a PPM image for a class assignment. A black rectangle with a circle at the point 225, 175 with a radius of 75. I have to use certain specific methods, so I can't use like Bresenham's really famous method for creating a circle.

The problem is that it compiles fine, and transfers to an image fine, but always says that I have a negative or zero image size.

Code:

#include "shapes.h"
int main () {
int i, j, x, y;

fprintf(stdout,"P6 width height 255
");

[Code] ....

And my header is:

Code:
#include <stdio.h>#include <math.h>
#define height 480
#define width 640
#define cy 175
#define cx 225
#define radius 75

The circle has to be filled in. I made it white. Also, i and j are unsused so far, so just ignore them.

View 1 Replies View Related

C++ :: Creating Script That Can Rotate Image Through Some Number Of Degrees

Dec 3, 2014

Create a script that lets you rotate an image through some number of degrees(out of a maximum of 360 degrees). The script should let you specify that you want to spin the image continuously. It should let you adjust the spin speed dynamically.

<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>Final</title>
</head>
<body>
<canvas id = "drawRectangle" width = "200" height = "200"
style = "border: 5px solid black;">
</canvas>

[code]....

View 2 Replies View Related

C/C++ :: How To Use Map In Multithreading

Jan 11, 2013

I have one input file having almost trillions of records.

Input:
Key Value
a XYZ
b xyz
. ...
. ...

How to store the above data in multithreaded map and retrieve in the same manner?

View 2 Replies View Related

C++ :: Reading From A Map Using Indexing?

Sep 12, 2013

I would like to validate one of my approach.

I am creating a map like

std::map<unsigned int, double> key_value_pair;

I insert the value like as follows

1 25.0
0 30.0
5 90.0
2 22.0

Then i would like to read the value like as follows

double value = key_value_pair[0];

I am able to compile & there is no error.

question is does this will give 30.0 always.?

I am using VS2005.

View 7 Replies View Related

C++ :: Multithreading - Demonstrate Use Of Semaphores

Feb 27, 2014

I have come across below code to demenostrate the use of semaphores

#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#define NITER 1000000
int count = 0;
void * ThreadAdd(void * a)

[Code] ....

Why the question of syncronising threads and mutexes and semaphores come into the picture when we join threads?

Like in the above example we have joined the first thread and then second thread so that main process will pause for the first thread to finish as its joined and then main process resumes and gives control to second thread and pauses till its finished as this thread is also joined.

Then where is question of simultaneous access?

First thread does its job and ends itself.
Second thread does its job and ends itself.

I wonder why there is need to use semaphores or mutexes in this example? I am very new to Multithreading and this question bothers me as to why we have to worry about simeltaneous access when we can join threads and can make control wait till that thread ends?

View 10 Replies View Related

C/C++ :: Sorting And Indexing Arrays?

Apr 22, 2014

I am trying to create a program that will read data from a text file into a string. Afterwards I need to sort the data in ascending order and print it. So far my program reads the data but I'm not sure how to go about indexing the array.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

[Code].....

View 3 Replies View Related

C# :: Indexing Through Rectangle List?

Mar 11, 2014

I have having trouble looping through the list in the update section to update each object in the rectangleList. I am not sure how to format it because it is only drawing one and it does not move across the screen. I thought this section of code would work and loop through each object and make each one move but it does not.

for (int i = 0; i < rectangleList.Count; i++) {
enemyPosition = new Rectangle(rectangleList[i].X + 2, rectangleList[i].Y ,enemyPosition.Width,enemyPosition.Height);
} List<Rectangle> rectangleList;
protected override void Initialize() {
rectangleList = new List<Rectangle>();

[code].....

View 5 Replies View Related

C++ :: Multithreading - How To Modify Shared Object

Aug 24, 2014

class MyOwner {
...
int m_count;
bool b_locked;
};

[Code] ....

I am using an API where I create many MyObjects on the heap, and the API uses a separate thread to send messages to each object. Each MyObject contains a pointer to MyOwner.

Suppose I want to keep a count of all messages received in all MyObjects: How can I do this in a thread safe way?

I am assuming that the code I have written above will not be safe--at the very least it seems that it would potentially miss message counts when it was locked--not the worse case scenario for me. I am most concerned about not causing the application to crash.

View 5 Replies View Related

C++ :: Program Crashing On Exit While Multithreading

May 11, 2014

I was writing a program and it started crashing on exit (segment fault), after the 'return 0' in main(). I figure it's an std destructor.

I started with the program I was writing and just stripped out as much as I could, while making sure the crash persisted. If I remove any of the remaining code the crash disappears, even the seemly unrelated or scoped code.

#include <iostream>
#include <fstream>
#include <condition_variable>
#include <mutex>
#include <thread>

/* Call stack results:

[Code] ....

View 2 Replies View Related

C++ :: Template To Hold Two Dimensional Arrays - Automatic Indexing

Mar 6, 2015

For the past couple of weeks I have been working on a template to hold two-dimensional arrays. Right now I am puzzling over an indexing question.

There are many places in the template where I would like to use initializer_lists to refer to user-specified row and column ranges, particularly in member function arguments. A typical example would be a member function whose declaration would be along the lines of:

Code:
Array<Type>::some_function(std::initializer_list<int> columns, std::initializer_list<int> rows); which could get called via

Code:
arrayInstance.some_function({3:4}, {5:8});

It would be really nice to be able to use Matlab-style indexing to specify the last column, or the last row, in the Array object -- along the lines of

Code:
arrayInstance.some_function({3:4}, {5:END}); where END takes the value -1, and can be defined in Array, or somewhere else.

The way I have tackled this so far was to write myself an Indices PODS class with two elements to hold start and finish values, and a constructor-from-initializer_list that looks something like this:

Code:
Indices::Indices(std::initializer_list<int> range, int replace_value) {
int const *it = range.begin();

start = (*it == END) ? replace_value : *it ; ++it;
finish = (*it == END) ? replace_value : *it ;
...
}

So the elements of "range" give the values of Indices::start and Indices::finish -- but if either of them are entered as END by the user, they will be replaced by replace_value. (The default value of replace_value is END, so Indices::start and Indices::finish will never change if it is omitted.)

I also defined an Indices::endset(int) function to do the same thing for existing Indices objects:

Code:
Indices::endset(int replace_value) {
if (start == END) start = replace_value;
if (finish == END) finish = replace_value;
} Using Indices::endset, you can code up Array::some_function by modifying the above signature to something like

Code:
Array<Type>::some_function(Indices columns, Indices rows) {
columns.endset(this->M);
rows.endset(this->N);
...
}

This does work, and I've been able to use it in practice. However, it is klutzy. What I would really like to be able to do is have the Indices constructor handle value-replacements in "columns" and "rows", instead of needing to put calls to Indices::endset in every single Array<Type> member function that uses this approach.

The basic problem is that, when Array<Type>::some_function is called, there is no easy way of inserting Array<Type>::M and Array<Type>::N into the optional argument of the Indices constructor when "columns" and "rows" are being built.

The Indices class needs somehow to get access to these, and know which one is being used, M or N. So it needs to have some sort of deeper connection to Array<Type>, but I don't know what that connection should be.

View 2 Replies View Related

C/C++ :: Simultaneous Reading And Write From And To Text File Using Multithreading

Feb 13, 2013

Simultaneous Reading and write from and to a text file using Multithreading in c/C++

View 1 Replies View Related

Visual C++ :: Loading A File And Indexing Line Starts

Jun 14, 2013

I've spent some time trying to performance test various methods of loading / accessing a file, either into memory or through a memory mapped file, but I am having some trouble.

FILE * pFile;
std::ifstream ifs;
MapViewOfFile

I'm have trouble because Windows appears to cache the file, so I am getting very mixed results. Sometimes a huge file (100's MB's) will load quickly, other times almost instantly.

How to stop Windows from doing whatever it's doing, so I can see the real time taken to load/access a file from disk?

View 8 Replies View Related

C# :: Compare The Image Of A Button To Another Image In Visual Studio

Jul 3, 2014

Im trying to compare the image of a button to another image in Visual Studio like so...

//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");

[Code]...

btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))

I do have a feeling ive done something wrong here (Yes im a noob /> )

Variable active, is the same image as the buttons default (Well should be)

View 1 Replies View Related

C# :: How To Add More Than One Database In A Program

Mar 5, 2014

Is it possible to add more than one database in a C# program if so, how?

View 7 Replies View Related

C++ :: How To Create A Database

Feb 28, 2013

I'm trying to make a database that stores the information without overwrite it. I want this program to store the client’s selection in somewhere that doesn't change and also that creates a new storage for the new value any time the client enters a new selection instead of overwriting it. I did something like that in my code but any time the program runs again and the client enters a new selection, the client’s selection is overwritten with the new value. I don’t know if it’s possible to do that (store the client’s selection in somewhere where doesn't change) with C++. I've been reading and I think I can create a database for my program.

THIS IS MY CODE:
#include <iostream>
#include <string>
using namespace std;
// FUNCTIONS

[Code]...

View 2 Replies View Related

C# :: SQL Database Not Saving?

Oct 5, 2014

My program add something in a data base, but after program is closed all data is removed.

conturiSQLDataSet.LoginsRow newUserRow = conturiSQLDataSet.Logins.NewLoginsRow();
...
conturiSQLDataSet.Logins.Rows.Add(newUserRow);

There is a method that program can save all data?

View 2 Replies View Related

C/C++ :: How To Use Database In Programs

Oct 18, 2014

I am trying to experiment with programs and databases. Right now I am trying to set up a database so that my program, which currently just appends its results onto a text file, will instead store each result into a database, because this will make things much easier to access than trying to read specific results from an ever-larger, disorganized text file.

View 2 Replies View Related

C# :: Using SQLTransaction When Reading Database?

Jul 30, 2012

Is it useful to use SqlTransaction and transaction.commit() or rollback when only reading from a database? Have some code here that does that

View 1 Replies View Related

C :: Sorting Structures In Database

Nov 26, 2013

A user is supposed to enter student name, id, and grade then sort them by name, id, or grade. I managed to get it to sort by name and id correctly, but not by grade.

Code] .....

#include <string.h>
#include <stdio.h>
struct student{
int student_id;
char name[30];
char grade[15];

[Code] ....

View 8 Replies View Related

C++ :: Functions Searching A Database

Aug 8, 2013

I am trying to write a program to search a library file with the name of a book or author and return the books that match the searched string in some way. For instance, if I search "Develop" it should display Game Development Essentials(Novak) and Developing Games in Java(Brackeen) and tell me that 2 records were found. Currently, it shows all the records regardless of what i search for, even if it is jibberish. Am I missing something in my functions? should I include the code that accesses these functions?

//If the user chooses A or a
int showBooksByAuthor (int count, string name)
{
char choice;
int index = 0;
}

[code]....

View 1 Replies View Related

C++ :: How To Connect To MySQL Database

Mar 26, 2013

I have so far tried MySQL++, ODBC, SimpleDB, and the MySQL C++ Connector. All of them give me a FLOOD of errors in the output. Is there an easy way to connect?

View 7 Replies View Related







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