I have two EPS files.
One is with gradient and other is without.
When I convert my EPS file (NOTE: without gradient) to PDF using ghostscript. If looks correct in outline mode.
But when I convert EPS file with gradient via ghostscript, it black out my image.
here is my command,
-dBATCH -dNOPAUSE -dEPSFitPage -sOutputFile=output.eps -sDEVICE=ps2write -c '<< /PageSize [500 500] >> setpagedevice' -f" . myeps.eps
What version of Ghostscript, which OS ? Where can we download a specimen file to investigate ?
Command line is useless without specimen file.
Related
I am starting to learn object detection in OpenCV 3.4.2 (.Net C++ 2017).
I am very interested in detecting strawberries in pictures (at the moment I am really interested in detecting just strawberries). I know OpenCV has some pre-trained Haar cascade files in OpenCV directory, but there are not .xml files for strawberries (there are for body parts instead).
So I decided to search on Google, to try to find trained strawberry Haar cascade .xml files. I found this .xml file XML strawberry file but I get error -49 when I try to execute the program. I have executed correctly the program using OpenCV files, but I cannot execute correctly when I try with GitHub XML file.
I have found this thread here on StackOverflow StackOverFlow thread about GitHub XML files in OpenCV and a user claims that it's not possible to use GitHub XML files into OpenCV.
My question is about if there is a way to use the XML GitHub file I have posted in this thread in OpenCV or I need to train my own XML file? I would like to use GitHub file.
Edit(1)
I have found this link strawberry detection in OpenCV where, if you look at the source code, it seems that the same strawberry_classifier.xml is being used. I don't know if the name of the file is just a coincidence (Github filename and the filename shown in the source code of the 3rd link are exactly the same). At least it seems that the programmer (from the 3rd link) has obtained some results while using the (apparently) same .xml file that I want to use. But I don't know how to use that strawberry_classifier.xml file.
Python dev here,
I'm late, but in case anyone still wants to see an answer:
The classifier from GitHub works perfectly fine as shown in this Python code (Sorry, I didn't do it in C++, but I think it won't be much different)
The script uses your webcam as the image source. You can show the webcam some images of strawberries, and it will recognize it:
import cv2 #import library
#define Haar Cascade Classifier
Strawberry_Classifier = cv2.CascadeClassifier(r"C:\Users\Strawberry.xml")
VideoCapture = cv2.VideoCapture(0) #capture video from camera
#set video size
VideoCapture.set(3, 540)
VideoCapture.set(4, 360)
while True:
#Connect video and convert
Connection_Success, Video = VideoCapture.read() #returns a bool and video array in one tuple (sucess, video array)
RGB_video = cv2.cvtColor(Video, cv2.COLOR_BGR2RGB) #converts to suitable format
Detect_Strawberry = Strawberry_Classifier.detectMultiScale(RGB_video, 1.3, 13) #MODIFY THIS FOR LESS/MORE DETECTION ACCURACY
#Detect Strawberry
for(x,y,w,h) in Detect_Strawberry: #x,y width, height
cv2.rectangle(Video, (x, y), (x + w, y + h), (0, 255, 0), 3) #Put a rectangle around Strawberry
cv2.imshow("Window", Video) #show video
#quit if q is pressed, quit
QuitKey = cv2.waitKey(30)
if QuitKey == ord("q"):
VideoCapture.release()
cv2.destroyAllWindows()
I'm trying to plot my data with labels (x and y) and font enhanced (bold) using gnuplot-py (on ubuntu python 2.7). What I did until now is:
g.xlabel("Wavelength (nm)")
g.ylabel("Elipicity (mdegree)")
g('set xrange [190:260]')
g('set xtics font ", 12"')
g("set terminal svg")
g.plot(d1)
I tried some internet protocols, but they did not work, as:
{/:Bold Bold}
or:
g.xlabel("Wavelength (nm) {/Times:Bold boldface-newfont}")
But none of them has worked. How do I do to make those changes using gnuplot-py?
I don't know how to use calibration.cpp in opencv2.4.12 sample in ubuntu.
I tried to write command line
./calibrayion -w 6 -h 4 -pt chessboard -o camera.yml -op -oe stereo_calibl.xml
Result:
Could not initialize video (0) capture
stereo_calib.xml content
"left01.jpg"
"right01.jpg"
"left02.jpg"
"right02.jpg"
"left03.jpg"
"right03.jpg"
"left04.jpg"
"right04.jpg"
...
"left11.jpg"
"right11.jpg"
"left12.jpg"
"right12.jpg"
It seems your xml file is formatted incorrectly, and the program tried to open a camera capture. Consider https://github.com/Itseez/opencv/blob/master/samples/cpp/calibration.cpp for information about expected format, it also provides instructions on how to generate valid xml.
I have a C++ program using an embedded lua script to write data points from the program to file, and I want to simultaneously be able to run a gnuplot instance to plot the data points.
io.output(pfile);
io.write(t, "\t", p_x, "\t", p_y, "\t", p_z, "\n");
The gnuplot file looks like:
set termopt enhanced
set title "Linear Momentum Vector"
set xlabel "t (s)"
set ylabel "p (N-s)"
plot "data/plot_p.dat" using 1:2 title "p_x(t)" with lines, \
"data/plot_p.dat" using 1:3 title "p_y(t)" with lines, \
"data/plot_p.dat" using 1:4 title "p_z(t)" with lines
set style line 81 lt 0 lc rgb "#808080" lw 0.5
set grid xtics ytics mxtics mytics
set grid back ls 81
pause 0.25
reread
The above gnuplot script works for a complete data file, but I want it to plot in real time while the program is running. While the lua script writes to file, sometimes the gnuplot script catches the file with an incomplete last line. And this generates an error:
"liveplot_p.gnu", line 9: x range is invalid
How would I get gnuplot to script the last line or invalid data sets?
Thank you!
Some messing around with lua actually solved it for me. Calling the io.flush() function after the io.write(...) call seems to write the complete line into the file every time.
This ofcourse, doesn't tell gnuplot to SKIP or IGNORE the last line but it makes sure the last line is complete.
This is my first post and I'm quite a novice on C++ and compiling in general.
I'm compiling a program which requires some graphs to be drawn. The program create a .dat file and then i should open gnuplot and write plot '.dat'. That's fine.
Is there a way to make gnuplot automatically open and show me the plot I need? I should use some system() function in the code to call gnuplot but how can I make him plot what I need?
Sorry for my non-perfect English :s
Thanks for the attention anyway!
Depending on your OS, you might be able to use popen(). This would let you spawn a gnuplot process and just just write to it like any other FILE*.
If you have datapoints to plot, you can pass them inline with the plot "-" ... option. Similarly, you may want to explore set data style points/lines/linespoints/etc options.
Without pause or persist, gnuplot will terminate upon end-of-input-stream. In your example case, that would be when the end of the file is reached.
To produce (write) an output file (graph), use:
set terminal png small
set output "filename.png"
There's lots of options to set terminal. Png is usually there. If not, perhaps gif, tiff, or jpeg?
Watch out for overwriting the file!
You may want to use set size 2,2 to make a larger graph. Some set terminal variants also allow you to specify the size.
I'm learning this today too. Here is a small example I cooked up.
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char **argv) {
ofstream file("data.dat");
file << "#x y" << endl;
for(int i=0; i<10; i++){
file << i << ' ' << i*i << endl;
}
file.close();
return 0;
}
Save that as plot.cpp and compile that with g++:
g++ plot.cpp -o plot
Run the program to create the .dat file:
./plot
Save the following gnuplot script as plot.plt:
set terminal svg enhanced size 1000 1000 fname "Times" fsize 36
set output "plot.svg"
set title "A simple plot of x^2 vs. x"
set xlabel "x"
set ylabel "y"
plot "./data.dat" using 1:2 title ""
Run the script with gnuplot to generate your .svg file:
gnuplot plot.plt
The resulting plot will be in plot.svg. If you leave out the first couple lines that specify the output, it will render in a window. Have fun!
Sometimes it is as easy as one may think
gnuplot file
where file is neither your data nor your result file, but a file with the command you would type in the commandline. Just enter there your commands you need (either constant file you have or generate it).
After executing all commands in that file gnuplot exits.
Yes you can. You can make a file that has the commands you would otherwise type in to set up the plot and open gnuplot running from that file. This link has an article that explains how to do it. You can also output to an EPS or other graphical output formats and display the plot using another widget that reads in the file.
You may need to use the '-persist' flag to the command. I know that on *nix systems, this flag is required if you want the plot window to remain after the gnuplot process has completed and exited.
gnuplot -persist commands.gp
Also, you can put as many gnuplot commands as you like in the file. The file acts sort of like a batch script in this regard.
You might need to add a line
pause -1
This will show the plot until return has been pressed.
What you are probably seeing is that gnuplot runs and exits before the plot has time to be displayed.
You might need to set a terminal type. Read the gnuplot documentation about that.