I am trying to get the pixel locations from their latitude and longitude coordinates in an .NTF raster DigitalGlobe image. I'm trying to use gdallocationinfo, however, when I enter it into the command line I am getting no output.
Here are the commands that return nothing:
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -wgs84 stereo1ntf.NTF -156.7727265 71.25074096
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -xml -wgs84 stereo1ntf.NTF -156.7727265 71.25074096
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -l_srs wgs84 stereo1ntf.NTF -156.7727265 71.25074096
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -l_srs EPSG:4326 stereo1ntf.NTF -156.7727265 71.25074096
Here is what commands return errors:
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -geoloc stereo1ntf.NTF -156.7727265 71.25074096
ERROR 1: Cannot get geotransform
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -wgs84 -geoloc stereo1ntf.NTF -156.7727265 71.25074096
ERROR 1: Cannot get geotransform
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo -l_srs 4326 stereo1ntf.NTF -156.7727265 71.25074096
ERROR 1: Translating source or target SRS failed:
4326
I tried running just the command with just pixel location, and that returned something, so I know it is reading the file, I just don't know why it's not working to give it coordinates:
(pygdal) D:\Snowmelt_Utqiagvik_2021\Stereo_Pairs\March_21_tasking\pipeline>gdallocationinfo stereo1ntf.NTF 0 1
Report:
Location: (0P,1L)
Band 1:
Value: 612
Here is what gdalinfo returns about the image's coordinate system:
Driver: NITF/National Imagery Transmission Format
Files: stereo1ntf.NTF
Size is 43008, 43008
GCP Projection =
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]
Related
Expected Behavior (local environment: fresh MacOS 12.4 installation)
With no environment updates except $ pip3 install matplotlib, I can successfully run this simple plot from the Matplotlib documentation:
Example Code:
# testplot.py
import matplotlib.pyplot as plt
import numpy as np
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
fig, ax = plt.subplots()
ax.plot(t, s)
ax.set(xlabel='time (s)', ylabel='voltage (mV)',
title='About as simple as it gets, folks')
ax.grid()
fig.savefig("test.png")
plt.show()
Actual Output (saved to a .png after window opens):
Run $ python3 testplot.py in the terminal:
Observed Behavior (vscode python 3.8 dev container)
Disclaimer: This post does not address notebook-based plots (which work fine but are not always preferred)
However, when I run this in my dev container, I get the following error:
testplot.py:16: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
First Attempted Solution:
Following this previously posted solution, I specified the backend (export MPLBACKEND=TKAgg) before running the interpreter, but the error persists.
Second Attempted Solution:
Following the comments, I added the following lines to the script:
import matplotlib
matplotlib.use('tkagg')
In the v3.8 dev container, this addition changes the error to:
Traceback (most recent call last):
File "testplot.py", line 5, in <module>
matplotlib.use('tkagg')
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/__init__.py", line 1144, in use
plt.switch_backend(name)
File "/usr/local/python/lib/python3.8/site-packages/matplotlib/pyplot.py", line 296, in switch_backend
raise ImportError(
ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'headless' is currently running
Note: adding these two lines broke the local script as well. The point of the local example was to show that it plots stuff without installing anything except matplotlib.
I have Ubuntu 20.02 with following configuration:
-CUDA Version: 11.2
-Driver Version: 460.91.03
-CuDNN version: cuDNN v8.1.1
-OpenCV 4.5.4-dev
I compiled OpenCV for Cuda and then used cmake & make to build the darknet files. YOLOV4 training works perfectly but when I start the training with -map then it quits.
The training command is as following:
!./darknet detector train "CV-SMART/Training-Stage01-23-Sep-2021/obj.data" "custom-train.cfg" "weights/yolov4.conv.137" -dont_show -mjpeg_port 8090 -gpus 0,1 -clear -map
The error is generated at iteration 3402 saying the following:
calculation mAP (mean average precision)... Detection layer: 139 -
type = 28 Detection layer: 150 - type = 28 Detection layer: 161 -
type = 28 4 cuDNN status Error in: file:
/home/oem/mlworks/darknet/src/convolutional_kernels.cu : () : line:
555 : build time: Oct 29 2021 - 23:02:57
cuDNN Error: CUDNN_STATUS_BAD_PARAM Darknet error location:
/home/oem/mlworks/darknet/src/dark_cuda.c, cudnn_check_error, line
#204 cuDNN Error: CUDNN_STATUS_BAD_PARAM: Transport endpoint is not connected Close socket: out = 0, in = 0 MJPG_sender: close clinet: 0
Close socket: out = 0, in = 0 MJPG_sender: close acceptor: 0
I am out of ideas and don't know how to get rid of this error.
I will greatly appreciate any guidance to resolve this error.
I am running a Docker instance of Cocalc on a Ubuntu 16 server. Everything seems to be working but I am trying to debug why sage -pip install --user ffmpeg did not make the "OSError: Error: ffmpeg does not appear to be installed." message go away, even though it said it had been installed. Here is the full message.
Error in lines 9-9
Traceback (most recent call last):
File "/usr/local/sage/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/usr/local/sage/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 2944, in show
s = show0(objs, combine_all=True)
File "/usr/local/sage/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 2903, in show0
b = show0(a)
File "/usr/local/sage/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 2868, in show0
show_animation(obj, **kwds)
File "/usr/local/sage/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py", line 2642, in show_animation
obj.ffmpeg(t, delay=delay, **kwds)
File "/usr/local/sage/local/lib/python2.7/site-packages/sage/plot/animate.py", line 885, in ffmpeg
raise OSError(msg)
OSError: Error: ffmpeg does not appear to be installed. Saving an animation to
a movie file in any format other than GIF requires this software, so
please install it and try again.
For reference, here is the code that gives the error:
n = var("n")
frames = []
xr = (x, 0, 1)
for k in srange(1, 50):
g = plot((sum((-1)^(n-1)*sin(n*x)/n,n,1,k)), xr, color="blue", legend_label='k = %d' % k)
g += plot(x/2, xr, color="green", legend_label="x/2")
frames.append(g)
a = animate(frames, ymin=0.0, ymax=1.0, legend_loc=(0.2,0.8))
a.show()
Try installing the ffmpeg package systemwide?
sudo docker exec -it <name of cocalc container> bash
apt-get install ffmpeg # or something like that
I am new to OpenCV and Google Colab. I have been working on a project that requires me to take the real-time image frames from the webcam and process it. But the problem is from the below code the 'frame' always returns a 'None' type and my webcam does not seem to switch on. But using the example code from Colab to capture images works fine:
How to use cap = cv2.VideoCapture(0) in Google Colab
Here is the code that fails:
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
---> 19 frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
try replace the first line with
frame = cv2.imread('your_image.png',0)
If it works, then the high chance is your camera issue.
There could be multiple reason. try
sudo apt-get install ffmpeg
sudo apt-get install cheese
cheese
to see if you can get video feed in ubuntu. If can, then its opencv config issue. if cannot then its either driver or hardware issue.
If its driver issue. follow https://help.ubuntu.com/community/Webcam to driver
If hardware broke down, not much you can do software
I'm working on a project that I found online (Yolo Object Detection with OpenCV, one of Pyimageresearch projects). So, I downloaded the whole code and saved it in the Downloads folder as it was recommended the run the cmd line script:
python /home/ubuntu/Downloads/yolo-object-detection/yolo_video.py \
> --input /home/ubuntu/Downloads/yolo-object-detection/videos/WS-1sec.mp4 \
> --output /home/ubuntu/Downloads/yolo-object-detection/output/WS-1sec.avi \
> --yolo /home/ubuntu/Downloads/yolo-object-detection/yolo-coco
but the output was:
[INFO] loading YOLO from disk...
OpenCV(3.4.1-dev) Error: Parsing error (Unknown layer type: shortcut) in ReadDarknetFromCfgFile, file /home/ubuntu/src/opencv/modules/dnn/src/darknet/darknet_io.cpp, line 503
Traceback (most recent call last):
File "/home/ubuntu/Downloads/yolo-object-detection/yolo_video.py", line 42, in <module>
net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
cv2.error: OpenCV(3.4.1-dev) /home/ubuntu/src/opencv/modules/dnn/src/darknet/darknet_io.cpp:503: error: (-212) Unknown layer type: shortcut in function ReadDarknetFromCfgFile
I'm running the same exact version of OpenCV 3.4.1 on another machine and it worked there! This time I'm working on the Tetson TX2 but didn't rum!
Link to original project is here.
Any idea why these error occurs please!?
I think you might have the wrong OpenCV version. Check this answer:
OpenCV unknown layer type running darknet detect
"Support for running YOLOv3 has been added to OpenCV master branch (3.4.3)."