C++ :: Comparing Images In Current Directory And Sub-directories
Jun 4, 2012
I am currently working on a program that will take an image and compare it with all other images in the current directory and sub-directories. I decided to use Qt for this as Qt has a QImage class with an overloaded == operator. This seems to work well if there are duplicates of the same size.
However, my goal is to not only find duplicate images of the same size, but the same image which may be a different size. To do this, I shrink the larger image to the size of the smaller image using the QImage scaled function.
The concern I have with this is that the scaling isn't done the same way the smaller image may have been scaled. I tested this by shrinking a copy of a picture in Paint, that image does not get deleted. I believe that == is looking for an identical image, so when I do the shrinking (via that scaled function), even if it is of the same picture I shrunk in Paint, the two methods of shrinking are not identical, and so the images appear different.
Any better method I can try? Something that can allow for slight deviations, such as an image being 99% "the same" as another. (I admit here that I will need to define some metric for what "the same" means.) In this case, the method assumes they are "identical" and gets rid of one of them.
The main way I can think of doing this is to go through each image, one pixel at a time. If the two pixels from the different images at the same index are the same, then I can increment a same pixel counter. If this number is 99% (or some other threshold) of the total pixel count, I can make the assumption the images are the same.
View 6 Replies
ADVERTISEMENT
Nov 20, 2013
I'm trying to output only a few files, using regex, from the current directory, this is my main code:
Code:
// main.cpp
{
char * _dir = new char[MAX_PATH];
getcwd(_dir, MAX_PATH);
unique_ptr<CExtractor> _ptr(new CExtractor(_dir));
delete[] _dir;
}
Code:
// CExtractor.cpp
DIR *pdir = NULL;
struct dirent *pent = NULL;
pdir = opendir(_cwd.c_str());
while ((pent = readdir(pdir)) && (pent->d_type != DT_DIR)) {
if (regex_match(pent->d_name, regex(".(in|txt)$"), std::regex_constants::icase)) {
cout << pent->d_name << endl;
}
}
closedir(pdir);
My code is compiled correctly, but when I run my binary, nothings is outputed..here are my files in the current directpory:
aclocal.m4 config.guess config.status depcomp m4 NEWS
AUTHORS config.h config.sub INSTALL Makefile README
autom4te.cache config.h.in configure install-sh Makefile.am src
ChangeLog config.h.in~ configure.ac libtool Makefile.in stamp-h1
compile config.log COPYING ltmain.sh missing
I have a few "in" files
View 1 Replies
View Related
Jun 8, 2012
I've forgotten how to include a path to a folder from my current directory!
I mean, instead of loading my dice images as "dice6.png", I'm trying to load them from a file, as ".Imagesdice6.png"
Not sure why, but this isn't working. Google searching has got me nowhere.
View 1 Replies
View Related
Feb 8, 2014
I have tried to use File.Copy and File.Move but non of them would work as I expected .....
View 1 Replies
View Related
Mar 6, 2015
I'm stuck on unix system programming and am beginner about it. Assume that there is a directory which X. There are a file(text1.txt) and another directory which is Y in X. Last, there are two files(text2.noExtension) and text3.noExtension) and another directory which is Z in Y. My goal is that read files and enter directories until there is no directory. How to go on. Example:
Code:
#include <stdio.h>
#include <dirent.h>
int main (int c, char *v[]) {
struct dirent *pDirent;
DIR *pDir;
if (c < 2) {
printf ("Usage: testprog <dirname>");
return 1;
[Code]...
View 6 Replies
View Related
Sep 30, 2014
So first, I'm sending files from a server to a client. Basically, the server says "Incoming file" and tells the client "The name of the file is: ". So taking the name, I need to create folders, if they don't exist, for the received file to be placed in (since std::ofstream doesn't allow creating directories).
My current code below is working. My trouble is listed below the code.
std::stringstream ss (name);
//name is the recv'd name
std::string token;
[Code].....
View 1 Replies
View Related
Oct 5, 2013
[URL] ....
I've been getting these errors on two computers through four different compilers. It seems the directories arnt set up. If that's the cause, I have no clue how to resolve that.
Its a very simple prog too; it just calculates a dist, using dist formula.
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
void calcDistance (int x1, int y1, int x2, int y2);
[Code] ....
View 6 Replies
View Related
Apr 3, 2014
I have a program where I want to export the .lib file in a "Lib" folder, and the .dll file in the "bin" folder. How can I choose where the lib file and .dll file go?
View 3 Replies
View Related
Apr 12, 2014
I'm using the code found on the site here:
//* remove example: remove myfile.txt */
#include <stdio.h>
int main () {
if( remove( "myfile.txt" ) != 0 )
perror( "Error deleting file" );
[Code] ....
I replaced the myfile.txt with the directory of the file I want deleted.
"C:SOUNDSsavegame.dat"
It returns: Error deleting file. No such file or directory exists.
I've triple checked the directory. Its correct. I must be using this incorrectly. How?
View 5 Replies
View Related
Oct 23, 2013
I have these two files:
/project/protocol/guarddog/report.h
/project/protocol/sky/report.h
I have two report.h files located in two different directories. However the contents of them are different. How can I include the report.h file located in guarddog into the report.h file located in sky?
I assume just doing this would be ambiguous:
#include "report.h"
View 1 Replies
View Related
Dec 28, 2014
Using CodeBlocks. I've added the path to the library files in 'search directories' in 'linker' tab.
E:DataCompLibrarySDL2-2.0.3libx86
I also added the include files location in 'search directories' and that works fine.
But still when I add 'SDL2.lib' in linker settings and try to compile I get: cannot find -lSDL2.lib
View 3 Replies
View Related
Nov 19, 2012
For each project in a VS solution it's possible to stipulate per-project folders that get searched in addition to the folders that you've set globally for Visual Studio.
Which folders take priority? Do the project's folders get searched first? Or do the global folder get searched first? Or is it possible to select one set as having priority over the other?
(this is VS 2005 BTW)
View 4 Replies
View Related
Jul 21, 2013
The code below is suppose to create directories and upload files, but it is not working. What can I do to make the code work?
Code:
void CRECURSIONDlg::Recursion(CString sPath) {
hInternet = InternetOpen(TEXT("BEAR FTP"),
INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
// Make sure there are no errors
hIConnect = InternetConnect(hInternet,"192.168.1.4", 211,
"******", "*****", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
[Code] ....
View 6 Replies
View Related
Jul 25, 2013
I need a code in c++ . It should count the Files and Directories in root folder with every folder information i need the below information
1) no of files and folder
2) how many files are there in each folder
3) with size of every folder and files it contains
I am new in c++ ....
View 1 Replies
View Related
Aug 31, 2014
I'm new in C and I want to know how to get the current weekday where sunday=0, monday=1,...,.(using time.h if possible)/I want to do something like
Code:
#include<stdio.h>
#include<time.h>
int main(void)
{
[Code]....
View 3 Replies
View Related
Oct 6, 2013
My code is:
#include <iostream>
#include <string>
#include <cstdlib>
[Code]....
The problem is that the images don't display and the window doesn't respond.
View 5 Replies
View Related
Feb 27, 2015
I am new to GUI programming, I am using mono winforms
using System.Windows.Forms;
using System.Drawing;
using System.IO;
[Code]...
I tried sw.WriteLine(this.to.Text); but that did not work
View 4 Replies
View Related
Jan 29, 2015
What's the best performance library for loading images in PNG?
View 5 Replies
View Related
Feb 21, 2013
I want to import images in my program and what function I will use.
Compiler: Turboc 3.0
View 2 Replies
View Related
Apr 8, 2013
I don't mean how do I load a bmp, I mean how does SDL manage to do this?
View 2 Replies
View Related
Jun 9, 2013
Since SDL doesn't have it's own function for rotating images and I'm tired of storing multiple angles of the same sprite in a file, I created my own function for doing so:
//XY Class
class XY {
public:
XY(){}
XY(float x, float y);
[Code] ....
The problem is while Spin does spin the surface correctly, some pixels are rotated to the same new position so gaps appear in the returned surface. I need a way of filling in the gaps so the returned image looks better. A link to a program I made that uses this function is below so you can see the problem that I'm talking about. [URL] ....
I currently use SDL 1.2. Could my problem be fixed if I used 2.0? For example, does SDL 2.0 have a built in function for rotating surfaces?
View 3 Replies
View Related
Feb 16, 2014
RLE(Run Length Encoding)
using namespace std;
class Bitwriter{
private:
[Code]....
View 1 Replies
View Related
May 3, 2013
I have a database of images and I want to store paths of all those images to a text file (lets say "images.txt"). I can then use this text file in c++ to extract images one by one by using getline() in a loop.
I don't know how to store image paths to a text file.
View 4 Replies
View Related
Nov 24, 2014
I want to store the images in folder.... but I don't know how to do it
View 7 Replies
View Related
Sep 10, 2013
The question is pretty simple. I'd like to integrate an image into a C++ program.
View 11 Replies
View Related
Jun 25, 2012
I have written a socket witch send an image 256x256 and now i want to send many images and i don't know what loop to write to make the socket after have sent the first image to send another and not to write the same program many times for every image ......
this is the part that read the binary image
if( !(fp=fopen("Anemos.bmp","rb"))) {
printf("Unable to load bin file: %s...
","Anemos.bmp");
[Code] ....
View 2 Replies
View Related